django-rosetta
django-rosetta copied to clipboard
Problem with language code sr-Latn.
There is no way I can see translation for this language code sr-Latn or sr-latn. Probably django is expecting folder name sr_Latn to look for translation files.
I change this line of code in poutil.py: if u'-' in lang: _l,c = map(lambda x:x.lower(),lang.split(u'-')) #add capitalize() langs += (u'%s%s' %(_l, c), u'%s%s' %(_l, c.upper()), u'%s%s' %(_l, _c.capitalize()), )
after this sr-Latin is working.
@ikresoft I'm not sure, are you suggesting this is a bug in Rosetta or Django? All locale directories in Django have an underscore, regardless of whether the locale name (in settings.py) is defined with a dash (-) or an underscore (_).
I am also confused, in django locale directories are underscored but in i18n for my country is sr-latn and that coresponds to sr_Latn directory in django, and only way rosseta works for me is this capitalize() function in poutil.py
Same issues worked for me.
The problem is when Django sees languages, rosetta doesn't and vise versa for dashed languages as 'zh-cn', 'zh-tw'. (Django expects zh_CN, zh_TW)
Steps to fix:
- Rename created by rosetta directories to suit django, i .e. zh-cn - > zh_CN, zh-tw -> zh_TW
- Apply fix which is proposed by @ikresoft to poutil.py. This way rosetta still sees renamed dirs.
P.s. you can't just insert 'zh_CN' and 'zh_TW' into settings.py LANGUAGES list because these are invalid language codes.