[ckan-dev] Problems with localization

Sean Hammond sean.hammond at okfn.org
Thu Jul 26 16:31:34 UTC 2012


> for my CKAN project (http://dati.toscana.it ) I need to fix some
> translations that are missing from the original .pot file.  (eg.
> ckan/templates/package/search.html:25 "Resource formats". There are a
> few places that need a fix in this sense).

Cool! Nice looking site :)

That particular string 'Resource formats' (and also 'Tags' and 'Groups')
were not translated in CKAN 1.7.1, but they are marked in translation in
the current CKAN 1.8 beta (the actual source file
ckan/templates/package.search.html needed to be fixed to mark the
strings for translation). So the easiest thing for you to do would be
either to wait until CKAN 1.8 is released, or switch to the CKAN 1.8
beta right now.

> 1. if I add the following lines directly on the .../i18n/it/LC_MESSAGES/ckan.po and do a rebuild, things do not work
> #: ckan/templates/package/search.html:25
> msgid "Resource Formats"
> msgstr "Formato dei file"

No, without the strings being marked for translation in the source code,
this will not work. Also, we don't normally edit po files directly,
rather we edit the translations on the CKAN project on Transifex.com and
those get downloaded into CKAN before each release:

https://www.transifex.com/projects/p/ckan/

Since the CKAN 1.8 release is coming up in a few weeks, we'll soon
upload a ckan 1.8 resource to Transifex and we'll send emails to
ckan-dev and ckan-discuss asking people to submit translations on
transifex. After a couple of weeks of translation work, we'll download
the new translations into the ckan git repo just before making the ckan
1.8 release.

So if you want to contribute new translations to CKAN, the best thing to
do is wait for the CKAN 1.8 request for translations to go out, and then
submit your translations on Transifex.

> 2. I also tried to edit the ckan.pot file, adding the aforementioned
> message, and updating afterwords the ckan.po file.  I get several
> errors since **it seems that ckan.pot and it/.../ckan.po files are not
> in sync**.  This is the kind of errors that I get:

You shouldn't edit the ckan.pot file directly, it is generated from the
CKAN source code by the extract_messages command.

If you've found a string in CKAN that's not marked for translation in
the CKAN source code (and therefore it doesn't appear in the ckan.pot
file) what you do is mark strings in the source code for translation
using the _() function, here's an example of a commit that does this to
some strings:

https://github.com/okfn/ckan/commit/af1f41fb48fc1e8634455b2fa3b464d28de6213d

or you just report it as a bug and let the ckan devs do it for you :)

Then before we put out the request for translations before each ckan release,
we run this command to update the ckan.pot file with the latest strings
marked for translation in ckan source code:

    python setup.py extract_messages

we then upload the new pot file to the ckan transifex project as a new
'resource' and ask people to translate it. We only do this once before
each major ckan release.

> > (pyenv)ckan at ckan:~/pyenv/src/ckan-i18n$ python setup.py compile_catalog --locale it
> > running compile_catalog
> > 312 of 419 messages (74%) translated in 'ckan/i18n/it/LC_MESSAGES/ckan.po'
> > error: ckan/i18n/it/LC_MESSAGES/ckan.po:68: placeholders are incompatible
> > error: ckan/i18n/it/LC_MESSAGES/ckan.po:86: placeholders are incompatible
> >...
> I checked the updated ckan.po file and in fact some messages do not match.
> 
> **IMPORTANT**: I repeated this process downloading from scratch both "ckan.pot" and the "it" version of the ckan.po (that by the way I contributed to translate) from Transifex. I took the files for the 1.7 version, that is the one I'm using.
> 
> Any guess?

If you have edited the pot file then you need to run this command to
update the po files:

    python setup.py update_catalog --no-fuzzy-matching

then you can run the compile_catalog command to update the mo files. But
as I said, we don't recommend editing the pot and po files directly,
rather submit your new translations to the ckan project on
transifex.com.




More information about the ckan-dev mailing list