i18n doesn't work at production environment on heroku

i18n react
i18n javascript
vue-i18n
i18n angular
i18n-js
i18n locale
i18n react native
rails-i18n html

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

In the sample above you wrote LC_MESAGES instead of LC_MESSAGES (notice the double S), I believe this very well could be your issue.

If not then read on!

I had this issue (again!) recently, and the answer was found in this part of the django documentation

I suspect you have the same issue since your "admin" app was translated but not your own (project) app.

It seems that Django is looking for your translations like so:

  1. The directories listed in LOCALE_PATHS have the highest precedence, with the ones appearing first having higher precedence than the ones appearing later.
  2. Then, it looks for and uses if it exists a locale directory in each of the installed apps listed in INSTALLED_APPS. The ones appearing first have higher precedence than the ones appearing later.
  3. Finally, the Django-provided base translation in django/conf/locale is used as a fallback.

With the settings you described above, you must make sure your tree looks something like this (with the most important being settings.py is in the dir above the 'locale' dir):

+-project_top/
  |
  +-project_app/
  | |
  | +-locale/
  | | |
  | | +-pt_BR/
  | |   |
  | |   +-LC_MESSAGES/
  | |     |
  | |     +-django.po
  | |  
  | +-settings.py
  |
  +-manage.py

Rails Internationalization (I18n) API, with_locale which does not have this leak issue. The locale can be set in an around_action in the ApplicationController : around_action  Internationalization (i18n) is the process of preparing software so that it can support local languages and cultural settings. An internationalized product supports the requirements of local markets around the world, functioning more appropriately based on local norms and better meeting in-country user expectations.

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.

What Is I18n: A Simple Definition of Internationalization – Phrase Blog, It doesn't just mean being able to change languages. Instead, it means being  Internationalization (sometimes shortened to "I18N , meaning "I - eighteen letters -N") is the process of planning and implementing products and services so that they can easily be adapted to specific local languages and cultures, a process called localization.

By default, compiled translation files (*.mo) are ignored by git. Verify that you have this exception removed from your .gitignore file.

If that is the case, remove this exception, add these files to git, commit and push to Heroku to have them available to the app in Heroku.

i18n, In an express app, you might use i18n.init to gather language settings Notice: the "example" object in your json doesn't use any "one", "other"  Vue-i18n doesn't work properly in the data method? Ask Question Asked 2 years, 8 months ago. Active 2 years, 7 months ago. Viewed 3k times 0. Multilingual

First of all, your language settings are wrong.

It should be like:

LANGUAGES = (
    ('zh', 'China'),
    ('en', 'English'),
    ('ja', 'Japanese'),
)

Next, check if the domain in your cookie settings are correct.

I had the same problem and thought Heroku's virtual environment would never support i18n, but finally found out that my 'django-language' value in the session cookie belongs to my local testing server '0.0.0.0:5000'.

After changing the settings, my translations done on the local server worked out of the box.

What Is i18n? | What Is Internationalization?, What Does Software i18n Involve? Typical software internationalization tasks include: Developing software to be independent from a specific  The Ruby I18n (shorthand for internationalization) gem which is shipped with Ruby on Rails (starting from Rails 2.2) provides an easy-to-use and extensible framework for translating your application to a single custom language other than English or for providing multi-language support in your application.

I want to highlight a comment by @msaad above. If you're developing on Mac OS X and your translation directory is all lower case then change it from es_es -> es_ES and redeploy. This solved the problem for me. On OS X the system is case insensitive, but on linux systems it is not.

What is i18n, what is l10n, Localization, per se, doesn't require internationalization to be done, however, if the application hasn't been internationalized first, then that means the localization​  I18N Internationalization is the process (or the concept of the process) to make an application "international"; that is, make it able to support virtually any language or local setting on Earth. It always involves changes in the source code, that is it involves developers (who need to be also knowledgeable of the i18n problematic).

Why my i18n doesn't work?, I believe locales should only have the main language (in your case zh ) without the region. Rename your file locales/devise.zh.yml and set your locale with  * = scarce support in browsers ** = Lapp doesn't have a 2-letter code, a three letter code (lap) is proposed in NISO Z39.53. *** = Serbian can be written in Latin (most commonly used) and Cyrillic (mostly windows-1251) Note that UTF-8 can be used for all languages and is the recommended charset on the Internet. Support for it is rapidly increasing.

Localizing JavaScript Apps With jQuery.i18n, I18n does not have any serious bugs, and it is production-ready. Creating a Demo App. For the purposes of this demo, I'll create a single index. // if I18n.defaultLocale = "en" and translation doesn't exist // for I18n.locale = "de-DE" this key will be taken from "de" locale scope // or, if that also doesn't exist, from "en" locale scope I18n. t ("some.missing.scope");

Fallback, Per default locals containing region or script will take a translation from the pure language file if not found. en-GB.json. {. "i18n": "Internationalisation". } en.json. i18next goes beyond just providing the standard i18n features such as (plurals, context, interpolation, format). It provides you with a complete solution to localize your product from web to mobile and desktop.

Comments
  • you could use a mini middleware that quickly sets the language of your choice, I did it and proved that my files were ok and was something else: language middleware
  • I took off the English language and set only Portuguese. My whole application stayed in English but Django Administration was working fine!
  • Django docs says that if I only use my native language and set it in LANGUAGE_CODE, middlewares are not required. So, doesn't it prove that the files are not being found? Also, I checked at the server, and the files were there.
  • In my case the solution was with the most important being settings.py is in the dir above the 'locale' dir and adding it's path to the LOCALE_PATHS. This is the only configuration I was able to get to work on Heroku. I don't know if it is the same for the other servers.
  • Thanks dude, this saved my life !
  • If you're in 2018 and still fighting this (specifically for zh_Hans / zh_Hant), there's more to it. If you're developing on mac (which is case insensitive), everything will work. As soon as you deploy this elsewhere in my case Heroku / docker running linux), translations won't be found if your path is named zh_Hans or any variation of it. Make sure you use zh_hans/zh_hant as your folder name. You might need to use git mv so that if picks up the change ;)
  • .mo files are no source files. They shouldn't be part of a repository.
  • So then what would be the alternative? Should it be compiled at the server?
  • 'zh' is not accepted as language code. You need to use 'zh-cn' or other aliases listed here: github.com/django/django/blob/master/django/conf/…