I have seen more than one hundred posts about i18n issues and no solution seems to solve my problem.
I have an app running with Django 1.3.1 and it works Fine at my develop machine. But when I bring to heroku nothing happens. The files are not translated at all. It seems that the locale folder in my project is not being found.
Locale folder is at my project level and this is my settings:
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
LANGUAGE_CODE = 'pt-br'
USE_I18N = True
USE_L10N = True
ugettext = lambda s: s
LANGUAGES = (
('en-us', ugettext('English')),
('pt-br', ugettext('Portuguese')),
)
LOCALE_PATHS = (
os.path.join(BASE_PATH, "locale"),
)
Locale folder follows this structure:
locale
pt_BR
LC_MESAGES
django.mo
django.po
I've found different platforms prefer different language folder names. I was pulling my hair out on my development system (Mac OS X) because '/pt-br/LC_MESSAGES/' wouldn't work, even though makemessages created the folders that way and compile messages worked fine too. It finally sprang to life once I renamed the languages as '/pt_br/LC_MESSAGES/' (notice the underscore).
Migrating the same project to production (Ubuntu), it stopped working again, I tried everything under the Sun thinking the folder names must already be correct since they work on my dev. machine. I finally, out of desperation tried uppercasing the country component like '/pt_BR/LC_MESSAGES/', and, boom, it started working again.
Even thought my Python and Django and all of my various Python/Django libraries and apps were (by design) identical versions, I suspect that each system has different versions/builds of gettext beneath them, which is likely responsible for the differences.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With