Opened 12 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 Aymeric Augustin, 12 years ago

Component: TranslationsInternationalization

comment:2 by nahuel, 12 years ago

Cc: nahuel added

comment:3 by Aymeric Augustin, 12 years ago

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)

comment:4 by Jacob, 12 years ago

Triage Stage: UnreviewedAccepted

I've heard this request a few times, seems pretty reasonable. --> accepted.

comment:5 by Baptiste Mispelon, 12 years ago

Cc: bmispelon@… 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?

in reply to:  5 comment:6 by Ramiro Morales, 12 years ago

Resolution: duplicate
Status: newclosed

Replying to bmispelon:

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?

Yes it's the same idea. Thanks bmispelon for catching this.

Note: See TracTickets for help on using tickets.
Back to Top