<br />

What's this?

XML Translator - an xml based module for internationalization of the strings.

Prepare the installation

Unpack/copy the package at a convenient location. Make sure you have the lang/ folder
and at least one xml file in it. Check the provided files for a quick example. <br />

The xml structure should look like: <br />

<?xml version="1.0" encoding="UTF-8"?>
        <language name="en">
            <string key="one">translated value</string>

How to use it?

Getting some initial information

Getting default/current languages folder

The current and default one is the same if you didn't change them already.


Available languages

They match the xml files from the languages folder.

$availlang = $xmlconfig::get_available_languages();
echo .implode(", ", $availlang);

Getting translations

The methods are static so they can be called directly, without object instantiation.<br />
For convenience only, I'll be using variables to keep the Singleton instances:

$xmltrans = XT\XMLTrans::init();
$xmlconfig = XT\XMLConfig::init();

Setting up the current language


Getting translations for different keys


Note that all the operations are against the current selected language. If you need translation from
another language, you have to switch the language (see setting up the current language above).


Creating a new language file

This will create a new bg.xml file. Then, add more keys to it or check the syncronization chapter.


Adding a new key

The first step is option but ensures that you have selected the proper language to work on.

$xmltrans::add_key('newkey', 'This is a new key');

Updating a key

Again, make sure you have selected the correct language.

$xmltrans::update_key('newkey', 'This is the new value for key');

Deleting a key


Syncronize the language files

One of the coolest feature is this syncronization against a base file. Just make sure you have selected
your base language (in this case English):


And then, update the rest of the files: add to them the missing keys (from base file) and delete the
extra ones (not found in the en.xml). After this operation, all language files should contain the same
amount of keys (of course, you need to update the translation for the newly generated keys).