Opened 13 years ago
Closed 12 years ago
#20070 closed New feature (duplicate)
LOCALE_PATHS doesn't support "external" translations
| Reported by: | nahuel | Owned by: | nobody |
|---|---|---|---|
| Component: | Internationalization | Version: | 1.5 |
| Severity: | Normal | Keywords: | |
| Cc: | nahuel, bmispelon@… | Triage Stage: | Accepted |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I'm trying to use LOCALE_PATHS to integrate translations from pycountry, but as I read in the django documentation, django is looking for a django.mo in the LOCALE_PATHS directories.
This is too much restrictive and force developer to make a copy of a sub-project translations or to deal with the django internal API to add the translations manually.
It should be great that django allows to read in any .mo/.po files explicitly specified or not.
Change History (6)
comment:1 by , 13 years ago
| Component: | Translations → Internationalization |
|---|
comment:2 by , 13 years ago
| Cc: | added |
|---|
comment:3 by , 13 years ago
comment:4 by , 13 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
I've heard this request a few times, seems pretty reasonable. --> accepted.
follow-up: 6 comment:5 by , 13 years ago
| Cc: | added |
|---|
How does this ticket relate to #6376?
I'm not too familiar with gettext but it seems these two tickets are basically asking for the same feature, no?
comment:6 by , 12 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
The feature requested here is a convenient way to load in Django's i18n implementation .mo files from other software and not called django.mo.
Here's the workaround found by the OP:
import pycountry, gettext from django.utils.translation import get_language, to_locale, trans_real language = get_language() locale = to_locale(get_language()) res = trans_real._translations.get(language, None) t = gettext.translation("iso639", pycountry.LOCALES_DIR, [locale], class_=trans_real.DjangoTranslation) t.set_language(language) res.merge(t)