I want to translate in any language django permission names. To do this i extend django.contrib.auth.models.Permission model in django like this :
class ExtendedPermission(Permission):
translation_name = models.CharField(_('translation_name'),max_length=255)
Then i want to update this table in management commands. First 'name' field taken from Permission model, than it must be translated into another language for instance tr to use in ExtendedPermission model as translation_name field.This function in management/commands:
def try_translate(self,permission):
translation.activate(settings.LANGUAGE_CODE)
translation.activate('tr')
translated_str =translation.ugettext(permission)
translation.deactivate()
return translated_str
When run this command the variable does not appear in .po file.But if i give string that i want to translate like this : ugettext("name")
msgid = "name" appears in .po file and i can edit msgstr but i can not get the translated msgstr from .mo file with using ugettext.
I add 'django.middleware.locale.LocaleMiddleware', to settings file.I also run commands makemessages and compilemessages.