You are here: Foswiki>Tasks Web>Item9697 (05 Jul 2015, GeorgeClark)Edit Attach

Item9697: Enhance i18n infrastructure to support translation of extensions.

pencil
Priority: Enhancement
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Engine
Component: Configure, I18N
Branches: trunk
Reported By: OlivierRaginel
Waiting For:
Last Change By: GeorgeClark
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.

ALERT! 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:

  1. 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>
         
  2. 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
 

ItemTemplate edit

Summary Enhance i18n infrastructure to support translation of extensions.
ReportedBy OlivierRaginel
Codebase
SVN Range
AppliesTo Engine
Component Configure, I18N
Priority Enhancement
CurrentState Closed
WaitingFor
Checkins distro:c0b3ecb2793f
TargetRelease major
ReleasedIn 2.0.0
CheckinsOnBranches trunk
trunkCheckins distro:c0b3ecb2793f
masterCheckins
ItemBranchCheckins
Release01x01Checkins
I Attachment Action Size Date Who Comment
xgettext-pluginEXT xgettext-plugin manage 3 K 09 Jan 2012 - 14:44 MichaelDaum  
Topic revision: r8 - 05 Jul 2015, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy