Herman Schaaf
Herman Schaaf

Reputation: 48425

How to force Django internationalization with languages not part of the official Django project?

I'm trying to activate Django translations in a language that is not yet part of the Django distribution. I'm more than happy to do Django translations in that language from now on, but since I need it now, I'd like to know if it's possible to activate a certain language even though the admin panel and Django messages have not yet been translated (since I don't need that).

I would like to not fiddle with the django installation, unless absolutely necessary.

If I set the LANGUAGES variable in settings.py to the following, for example:

LANGUAGES = (
    ('en', _('English')),
    ('de', _('German')),
)

then it works fine and I can choose either German or English, with my own custom translations. If I do the following, however:

LANGUAGES = (
    ('en', _('English')),
    ('af', _('Afrikaans')),
)

then the language in neither the session nor the cookie can be set to the af value, and it remains on en. I would think it would be possible to use af translations where available (as defined in my application locale files), then fall back to the en values otherwise? How does one do this?

Upvotes: 1

Views: 896

Answers (1)

Herman Schaaf
Herman Schaaf

Reputation: 48425

From the Django docs:

Django does not support localizing your application into a locale for which Django itself has not been translated. In this case, it will ignore your translation files. If you were to try this and Django supported it, you would inevitably see a mixture of translated strings (from your application) and English strings (from Django itself). If you want to support a locale for your application that is not already part of Django, you’ll need to make at least a minimal translation of the Django core.

That's quite irritating though, I wouldn't mind having a mixture of English and translated strings. But, at least it can be done, even though it is with quite some trouble.

Upvotes: 1

Related Questions