[ckan-dev] How to activate and compile CKAN internationalization files within an extension

Stefan Oderbolz stefan.oderbolz at liip.ch
Mon Nov 4 15:04:13 UTC 2013


Hi Ian,


 > There is no such things as "en" default files. CKAN uses "en" as the
> default
> > source language, i.e. if you don't translate anything, it's English. I
> think
> > this was a very bad choice, as it makes customizing the English
> translation
> > really painful. For this purpose we removed the code that prevents the
> > loading of translations for "en" provide an English .mo file.
>
> Stefan: Interesting. do some projects declare some non-real-language
> as the source language and just not override anything in the "en"
> translation?


I'm not sure if I understood you correctly: CKAN uses English as it's
source language, there is no way to change that (see all translations
files, the msgid is in English, msgstr is the translation, e.g. here:
https://github.com/okfn/ckan/blob/master/ckan/i18n/de/LC_MESSAGES/ckan.po#L594
).

If you look at the en_GB translation, the pattern you described is used a
lot: do not override -> the original is used.
E.g.
https://github.com/okfn/ckan/blob/master/ckan/i18n/en_GB/LC_MESSAGES/ckan.po#L1084
"The
resource url is not specified." is not translated, therefore this string is
used as-is.

Now because CKAN uses this model, it's not necessary to have an "en"
translation, because this is what you get anyway if you don't specify the
language. This is why there is code, that checks whether you use "en", if
this is the case, it doesn't load any translations (
https://github.com/okfn/ckan/blob/master/ckan/lib/i18n.py#L132).

Now you have two possibilities:
1. Create a new (non-real) language and translate what you want to change.
Use this new language instead of "en". I consider this a hack.
2. Change the code to always load translations (i.e. remove the condition
here: https://github.com/okfn/ckan/blob/master/ckan/lib/i18n.py#L132) and
provide a "en" translation. This is a clean(er) solution with the
disadvantage, that you have to change one line of CKAN core code. Maybe in
the future this can be addressed directly in CKAN to provide a standard
solution for every language (incl. "en").


-- 
Liip AG  //  Feldstrasse 133 //  CH-8004 Zurich
Tel +41 43 500 39 80 // GnuPG 0x7B588C67 // www.liip.ch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20131104/09143dfa/attachment-0001.html>


More information about the ckan-dev mailing list