Note that there are some explanatory texts on larger screens.

plurals
  1. POTemplate tags successfully translated but ugettext_lazy() in utils not translating
    primarykey
    data
    text
    <p>I successfully managed to get trans and blocktrans to translate text.</p> <p>However...</p> <p>I have a function defined in utils.py that returns a dictionary containing strings of which some of them I need converted to the current language. EDIT: *This is a utils.py that I've created in my project directory that are called by views to perform certain auxillary functions on a dict and then return the updated dict</p> <p>I have done something like this:</p> <pre><code> try: path = default_storage.save(customercode + '/' + file.name, ContentFile(file.read())) results['status'] = 'success' results['message'] = _(u'Your file has been successfully uploaded') except Exception as e: results['status'] = 'error' results['message'] = _(u'There was an error uploading your file: ') + str(e) return results </code></pre> <p>I have also added <code>from django.utils.translation import ugettext_lazy as _ to the top of this utils.py file..</code></p> <p>And this "results" dictionary is used in one of my views wherein the whole dictionary after some further processing is passed as a context variable to the template.</p> <p>I have correctly set the translation in the .po file. All other template tags translate perfectly. Only the above mentioned strings do not translate.</p> <p>Any help would be greatly appreciated.</p> <p>UPDATE: I tried the same process in a forms filed label and it translated just fine. It's only the aforementioned areas where it won't translate!</p> <p>PS: This is my first question on stackoverflow. I apologize in advance if I've made mistakes asking this question.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload