Reputation: 5656
One of my translations is not working even though: 1) It's in tranlsation file:
#: core/permissions/decorators.py:138
#, python-format
msgid ""
"You are missing permission(s) \"%(permstring)s\" for %(modelname)s %(obj)s"
msgstr ""
"Sul puudub (puuduvad) õigus(ed) \"%(permstring)s\" %(modelname)s %(obj)s "
"suhtes"
2) It's not fuzzy, translations file is compiled, apache is restarted.
3) Correct language is in fact chosen at the time this string is translated - both request.LANGUAGE_CODE
and translation.get_language_from_request(request)
print out same, correct, expected language code.
4) Even tested code prints one string out in the correct language but not in the 2nd:
my_string = u"%s" % _("Time array")
logger.debug(my_string)
Prints out:
DEBUG 2013-07-04 12:17:28,554 Jada aegadest
mystring = u"%s" %_('You are missing permission(s) "%(permstring)s" for %(modelname)s %(obj)s' % d)
logger.debug(mystring)
Prints out:
DEBUG 2013-07-04 12:22:53,522 You are missing permission(s) "User can access this object" for Obj <idcode>
Does anybody have any idea what could cause this or how I could test some more things why this is not working.
Django version 1.4.2.
Alan
Edit1:
I removed quote marks from translations file, making translation look like this:
#: core/permissions/decorators.py:138
#, python-format
msgid "You are missing permission(s) %(permstring)s for %(modelname)s %(obj)s"
msgstr "Sul puudub (puuduvad) õigus(ed) %(permstring)s %(modelname)s %(obj)s suhtes"
Compiled and restarted apache and still not working.
Edit2: It seems to be a bigger, repeating problem. Common attribute in these cases is that the string contains several variables.
Upvotes: 2
Views: 836
Reputation: 24324
replace:
mystring = u"%s" %_('You are missing permission(s) "%(permstring)s" for %(modelname)s (obj)s' % d)
logger.debug(mystring)
with:
mystring = _('You are missing permission(s) "%(permstring)s" for %(modelname)s (obj)s') % d
logger.debug(mystring)
you need to get the translation before you do the interpolation / format, otherwise you would need to put the interpolated string in your translation (not recommended):
msgid "You are missing permission(s) \"User can access this object\" for Obj <idcode>"
msgstr "Sul puudub (puuduvad) õigus(ed) %(permstring)s %(modelname)s %(obj)s suhtes"
Upvotes: 2