[ckan-dev] 2375-demo-theme code review

Sean Hammond sean.hammond at okfn.org
Mon Sep 10 15:26:21 UTC 2012


On Sat, Sep 08, 2012 at 07:42:59PM +0200, Sean Hammond wrote:
> > > lib/cli.py TranslationsCommand
> > 
> > New `trans` paster command, the js command seems to make files for each
> > language in ckan/public/base/i18n/ like this:
> > 
> >     {
> >         "": {
> >             "domain": "ckan",
> >             "lang": "de",
> >             "plural-forms": "nplurals=2; plural=(n != 1)"
> >         }
> >     }
> > 
> > What are these files for? Maybe a better docstring than "generate the
> > javascript translations", the files that it generates don't contain any
> > translations. I guess this is part of the new system for handling
> > translations in javascript but I don't know anything about this system.
> > Maybe this is something I missed from the workshop in London. Maybe you
> > could give me a couple of pointers to get started understanding how this
> > works?
> 
> Ah, working on a Saturday. I looked at this a little closer and it seems
> once I created a pot file and everything that these
> ckan/public/base/i18n/*.js files do actually contain translations to
> different languages, but only for a few strings, I guess only the ones
> that appear in javascript.
> 
> So my guess is that Babel extracts strings from the javascript source
> into the po files, and this trans js command finds the translated
> strings in the po files and puts them in these i18n/*.js files for the
> js code to find them when it needs them at run time?
> 
> I'll look at this some more later

I've looked at this TranslationsCommand some more and it looks fine to
me, just a couple of minor points which I'll do if you agree:

- I'd like to add a slightly longer docstring to say what `trans js`
  does

- I guess we need to run trans js before each CKAN release and commit
  the results? This should be added to the Release Process wiki page
  (which is now on Github Wiki)

- Is `trans mangle` really necessary? If you upload a pot file to
  Transifex, it can generate a po file for you with 100% strings
  translated into a fictional pseudo language where everything is really
  long strings of unicode characters. I found this worked well for
  coverage testing, and also tests handling of unicode and long strings
  all over the place.

I haven't looked at the javascript code itself and how it accesses these
translations, I'm probably not the best person to do that but let me
know if you want me to review it.




More information about the ckan-dev mailing list