Localization

From PCGen Wiki
Jump to: navigation, search

Localization (l8n) is the process of adapting software for its use in a particular location. It can only be done if the software has been internationnalized (i10n). It is mainly translation.

In the case of PCGen, as with other free software, localization can only be done with the help of the community.

PCGen both need translation for its user interface (UI) and its data. The data can not be translated for now (as of August 25th 2012), because the internationnalization for the data is not yet done.

The translation of the UI is simpler. There is a file for each language, and basically you need to translate all the messages. Beware that, as of August 25th 2012, there are still many unused strings in the files.

My Process

By Masaru20100 03:44, 25 August 2012 (MIST)

PCGen uses Java's ResourceBundle, and use cryptic text as the key of strings (unlike PO that indicate to use ASCII text as keys). It means you need to see two text files at the same time to view original files. Do not edit a copy of another language file, because you'd have a file with a mix of the target language and the copied language, which make it difficult to see what is not yet translated (and also harder to merge). I don't like the ResourceBundle format because it does not allow me to keep the information that my translations on some strings might not be good. That's why I keep my main translation in po files and not in bundles.

Another reason to keep separated files, is that only ASCII characters can be included in a ResourceBundle, other characters need to be unicode escaped (things like \u0145).

Each time I update my svn copy, I create a new POT file from the default resource bundle. Then I update my latest po file of the language I'm working on, update it with the POT file and save it with a new name (using the svn version number). I then proceed to edit the po file. I save the file, update the resource bundle in the code directory then (I think its needed to see changes) build pcgen.

To update, I just do

# svn up

To create the new POT, I use prop2po which is part of the package translate-toolkit on Debian. I have a little script that I usually call with the svn number.

# newpot 17045

newpot

#!/bin/zsh

# argument is name of version
if [[ -z $1 ]];
then
        echo Argument needed
        exit 1
else
        name=.$1
fi

# Create the new POT from the Language bundle
prop2po ../pcgen-svn/code/src/java/pcgen/resources/lang/LanguageBundle.properties LanguageBundle$name.pot
#po2xliff -P LanguageBundle$name.pot LanguageBundle$name.xlf

I use virtaal to open the latest po file, update it with the POT then save it with the new version number (poedit would work fine but doesn’t show the comments in the po file). I then edit the file.

Once my change are done, or I want to view them, I use a script to update the resource bundle file. You’ll have to change the name of the language you’d work with there (fr ja en_GB in my case). It uses po2prop also part of the translate-toolkit package.

# updatebundle 17045

updatebundle

#!/bin/zsh

# argument is name of version
if [[ -z $1 ]];
then
        echo Argument needed
        exit 1
fi

# Create the new POT from the Language bundle
for lang in fr ja en_GB
do
        if [[ -f LanguageBundle.$1.$lang.po ]];
        then
                po2prop --fuzzy --errorlevel=traceback -t ../pcgen-svn/code/src/java/pcgen/resources/lang/LanguageBundle.properties LanguageBundle.$1.$lang.po ../pcgen-svn/code/src/java/pcgen/resources/lang/LanguageBundle_$lang.properties
        fi
done

I hope those scripts help some one, you’ll probably need to change them (to fix the path for example).