[development] po import in install time
gabor at hojtsy.hu
Mon Aug 28 11:48:18 UTC 2006
I started to code this supposedly simple patch today and hit too many road
blocks, so I figured I would ask here, if someone knows a bulletproof way
to do this.
I have this installer translation patch , which is not yet ready for
core comitting (and might not be until the code freeze unfortunately). I
thought I'd better focus on the more important issue first then: importing
of PO files automatically on module enable (and possibly install time).
The fundamental problem is that if I would try to import PO files, I would
need the list of languages set up on the site. For this API I need the
locale module already set up and enabled (loaded in), and for this we need
the locale tables to set up.
PO import on module enable would work this way:
- drupal_install_module() calls the module's install hook if available
- it would then call a locale_install_po($modulename) function,
which would look for PO files in the modulefolder/po/it.po places,
in the form of it.po, de.po, hu.po and such. we only need to look
for po files for the enabled languages, and need to import them
Getting the enabled languages is trivial, if locale module is already set
up and working, and then this PO import becomes trivial as a result. The
problem is that the locale module is enabled at an uncertain time by the
install profile, so modules enabled after that in the install sequence
will have their translations loaded, others will surely have not. This
includes the system.module, which is forced to get installed first.
We can also do PO import in drupal_install_modules(), and try to import PO
files after all modules are installed. This is slightly better, but is not
called by system.module in case you enable a module on the admin
More information about the development