Item9697: Enhance i18n infrastructure to support translation of extensions.
Priority: Enhancement
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Engine
Component: Configure,
I18N
Branches: trunk
For the moment, we have some good infrastructure to translate the core, but nothing easy to use to translate extensions.
User interface internationalisation gives some guidelines on how to extend that.
Also, pootle seems to expect files to be in one directory per language, and not flat like we have.
Hence, my proposal (and I'd love feedbacks), is the following:
- For foswiki core we would split them in a directory per language:
- Before:
core/locale/de.po
-- core/locale/Foswiki.pot
- After:
core/locale/de/core.po
-- core/locale/core.pot
- After:
core/locale/de/Foswiki.po
-- core/locale/Foswiki.pot
other suggestion
- For extensions, we would just add the locales in their directory:
- In SVN:
JQueryPlugin/locale/de/JQueryPlugin.po
and JQueryPlugin/locale/JQueryPlugin.pot
- Installed:
.../locale/de/JQueryPlugin.po
and .../locale/JQueryPlugin.pot
The changes to the core would be minimal, as Foswiki::I18N only needs to loop over all .po files inside
locale/$lang
, instead of simply adding the
locale/$lang.po
for language
$lang
.
MichaelDaum states that we could consider having configure merge the .po files together for performance.
I am not sure it's worth it, and I'd rather keep it split so it's easier to see and remove.
--
OlivierRaginel - 16 Sep 2010
I've added the checker to trunk to compile the .po file into a .mo file. Maybe they should be merged at compile time, creating a single .mo file for the collection of .po files for each language?
Does this one need a feature proposal?
--
GeorgeClark - 16 Mar 2011
Following up the
today's IRC discussion I learned that pootle does not necessarily need all po files of one language in one directory; it can be configured both ways.
So actually the minimal change that possibly works is:
- leave all core po files where they are:
locale/<language>.po
- let plugins have their translations in
locale/<plugin>/<language>.po
Patch is
here.
Also, I've attached a changed
xgettext
tool that can deal with plugins extracting strings.
There are a few things to bootstrap translation:
- generate the translation template file: in locale/<plugin-name>/Foswiki.pot:
mkdir <foswiki-root>/trunk/<plugin-name>/locale/<plugin-name>
<foswiki-root>/tools/xgettext-plugin <plugin-name>
- for each language that you want to translate:
msgmerge -o <foswiki-root>/trunk/<plugin-name>/locale/<plugin-name>/<language>.po \
<foswiki-root>/trunk/core/locale/<language>.po \
<foswiki-root>/trunk/<plugin-name>/locale/<plugin-name>/Foswiki.pot
Note that these steps will copy-paste the headers from the original core translations into the Foswiki.pot template.
You might want to change these to adjust them to the proper copyright and authorship for the plugin.
To upgrade a plugin's strings use:
msgmerge -U <foswiki-root>/trunk/<plugin-name>/locale/<plugin-name>/<language>.po \
<foswiki-root>/trunk/<plugin-name>/locale/Foswiki.pot
--
MichaelDaum - 09 Jan 2012