Elxis CMS - Open Source

elxis 2008
Feel the power of Open Source!


download elxis 2008.0 Olympus
size: 7.35mb | revision: 1891 | stable

Multilingual XML parameters

Elxis 2008 supports custom language files for providing multi-linguism in XML parameters. This feature concerns any sub-application that uses XML files such as modules, components and bots. As you most probably know, elxis 2006.x generation had multilingual support for XML files using the standard XML files from the administration language package. But there was no way to add multilingual strings to a custom module or component. Now you can do that!

Elxis 2006.x

All standard XML language files, located at Elxis administration language folder, contain a PHP class named xmlLanguage which starts with the function get(). get() usage is pretty simply. As input gets a string from the XML file and returns the translated string if the strings starts with "AX_" or the untranslated string if nothing found.

example 1
$xmlLanguage->get('test');
will return: test

example 2
$xmlLanguage->get('AX_MENUIMGL');

will return: the translated string of the variable $AX_MENUIMGL, which for the english language is: "Menu Image".


Elxis 2008.x

Function get() updated to support inputs from custom language files. Here is the new get() function:

function get($a) {
if ( is_numeric($a) ) { return $a; }
$pref = strtoupper(substr($a,0,3));
if ($pref == 'AX_') {
return $this->$a;
} elseif (($pref == 'CX_') && defined($a)) {
return constant($a);
} else {
return $a;
}
}

As you see you can now insert as input a constant which name starts from CX_ (Custom Xml language).

How you declare your language files?
Inside the xml file add a tag named cxlangdir and write inside it the relative path to the folder that are located your custom language files.

example 3
<?xml version="1.0"?>
<mosinstall type="module" version="2008">
<name>module name</name>
<authorUrl>www.elxis.org</authorUrl>
<cxlangdir>/modules/mod_mymodule/language</cxlangdir>
<version>1.0</version>
<description>module description</description>
<files>

Your language files are located inside the folder /modules/mod_mymodule/language.
Of course you can set this to any folder. The path is the relative path from the Elxis root folder to that folder that contains your language files. Your language files names should follow the Elxis standards (english.php, italian.php, greek.php, german.php etc).

Language strings inside that files must be declared as PHP constants starting with "CX_".

example 4
define('CX_START', 'Start');
define('CX_HOWRY', 'How are you?');
Last Updated Thursday, 14 February 2008
< Previous
Powered by Elxis - Open Source CMS.
Copyright (C) 2006-2008 Elxis.org. All rights reserved.
Elxis.org web site and template was created by Is Open Source (IOS)
Language:

Valid XHTML