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

Ian Ward ian at excess.org
Mon Nov 4 13:24:53 UTC 2013


On Mon, Nov 4, 2013 at 4:10 AM, John Glover <john.glover at okfn.org> wrote:
>> In my setup I just copy the compiles files in the CKAN directory
>> (pyenv/lib/python2.7/site-packages/ckan/i18n). Afaik there is no way to
>> include them from your extension directly (unlike e.g. templates).
>
>
> Actually this should be possible. You cannot currently have translations in
> multiple locations (so you cannot just override a few core translations like
> you can do with the templates). You can however create an i18n directory in
> your extension, then give the path to it using the ckan.i18n_directory
> config option, and CKAN will load all translations from this directory.
>
> We do this in the EU Open Data Portal extension which is based on CKAN
> 1.8.x, but as far as I know this should still work in 2.x.

We should be doing that instead of replacing the one in the CKAN directory.

Handling this cleanly in CKAN would certainly be nicer. How about a
new plugin type to register translations and then let CKAN merge them
with msgcat+msgfmt on startup?

On Mon, Nov 4, 2013 at 5:10 AM, Stefan Oderbolz <stefan.oderbolz at liip.ch> wrote:
>
>> Last question / problem:
>>
>> How do I replace the default "en" files? There are only "en_GB" and
>> "en_AU" directories under "pyenv/src/ckan/ckan/i18n/". I could not find any
>> other mo files that would fit to plain "en". Is the "en" translation
>> hardcoded into the CKAN source? Or how to tweak it?
>
>
> 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?




More information about the ckan-dev mailing list