0

I want to use a string which is not in use yet. so there is no any {% trans 'word_I_want_to_use' %} in template nor in views/models yet.

can I just create it like this in views.py?

from django.utils.translation import ugettext as _
_("word_I_want_to_use")

and makemessages and compilemessages.

and later on, I will put the {% trans 'word_I_want_to_use' %} in template.

will this work?

doniyor
  • 36,596
  • 57
  • 175
  • 260
  • Yes this will. You goal is to make it available for translation while not using it anywhere? – aumo May 04 '15 at 10:57

1 Answers1

3

Yes. That will work. You can also use lazy translation, so that you have no performance impact for the unused translation:

from django.utils.translation import ugettext_lazy as _
_("word_I_want_to_use")

Alternatively, you can use ugettext_noop for only translating but never directly using the string. This depends on you plans and use case.

Boldewyn
  • 81,211
  • 44
  • 156
  • 212