wiki:Documentation/DevelopingForXinha/Translating

Version 6 (modified by gogo, 5 weeks ago) (diff)

--

Translating Xinha

Hello you multi-lingual person you, so you would like to help translate Xinha or create your own special translation to use?

It's really easy!

First, Download Xinha

In the full Xinha distribution (Download Xinha Here) you will find some files under the following directory

/lang/merged/*.js

you can see that there is a file for every currently existing translation there and also one called "new.js". You will also see there are other lang files around the place, they are used only when not using a merged file, you don't need to touch them, just work on /lang/merged/*.js !

Edit or Create the Language File

If your language is there already, simply open that .js file in your favourite UTF-8 compliant text editor.

If your language is not there, copy the new.js file and create a new one called [yourlanguagecode].js, for example if you are translating into Klingon, perhaps "kl.js" and then open it in your favourite UTF-8 compliant text editor.

Please note that all translation is in UTF-8 Encoding, do not try to use other character encodings (character sets), it's not going to end well.

Test The Language File

To actually test or use your translation, in your code right before you load Xinha specify the language and file like this...

<!-- Set Language To Klingon --> <script type="text/javascript>

_editor_lang = 'kl'; _editor_lang_merged_file = '/xinha/lang/merged/kl.js';

</script>

<!-- And Load Xinha As Usual --> <script type="text/javascript" src="../XinhaCore?.js"></script>

that's it, try out Xinha and your language file should provide the translations.

When you have made your translation file and would like to submit it to Xinha for inclusion in a future distibution of Xinha, please just open a ticket at http://trac.xinha.org/ and attach your new or improved language file, be sure to let us know your details to add the the contributors list below!

Tools

In the contrib directory there are a few scripts written in PHP to handle the translation setup tasks.

lc_parse_strings.php

This script goes through all the Xinha files, javascript, php, html, and pulls out the strings which should get translated. These are written into lc_base.js translation files spread through the system, eg /lang/lc_base.js, /modules/.../lang/lc_base.js, /plugins/.../lang/lc_base.js and so forth.

lc_base.js files do not get committed to the Subversion repository they are just temporary working files.

lc_create_merged_file.php

This script takes all the lc_base.js files and the existing lang files for a given language and creates a merged language file, for example

php contrib/lc_create_merged_file.php fr /tmp/fr.js

creates the French translation merged file /tmp/fr.js

Note that existing merged files are not consulted during this process.

Translators can then work on the merged file to do their translation work.

To make things easy the lang/merged/ directory contains pre-generated merged language files of each language of the release, again these are not committed to the subversion repository.

If you run this script without arguments it will give you some help showing how you can generate all the merged language files at once, this is done as part of the release process.

lc_split_merged_file.php

This script takes a merged file and splits it into the constituent lang files these files are written into a temporary directory structure so that you can use a diff/merge tool if you wish to compare them rather than actually copying them into place. For example,

php contrib/lc_split_merged_file.php /tmp/fr.js fr

will create a directory structure (it will be printed at completion) in /tmp,

/tmp/something-unique-here/lang/fr.js /tmp/something-unique-here/modules/.../lang/fr.js /tmp/something-unique-here/plugins/.../lang/fr.js /tmp/something-unique-here/unsupported_plugins/.../lang/fr.js

the directory and some instructions for easily "installing" the generated files is printed.

Contributors

The following people are thanked for providing and updating translations!