Save as Word Document | Find | English | Portugues(Brasil)

Reasons for the XMLNuke
The LanguageCollection Class

Using a word dictionary to assist with the internationalization of the modules

Table of contents
1. Introductory Concepts
2. The Context class
3. The FilenameProcessor Class
4. The LanguageCollection Class
5. AnyDataSet and Data Access
6. The "Util" NameSpace
7. Structure of Directories

On this page
The LanguageCollection Class


The LanguageCollection Class

To support the internationalization of user modules, it was necessary to create a class that could manipulate a small data dictionary efficiently. The LanguageCollection class only loads in its memory words from the language dictionary that is selected.

For example, to manually create a word dictionary:

CSharp
// using com.xmlnuke.international;

LanguageCollection myWords = new LanguageCollection(this._context);
// English Words
myWords.addText("en-us", "TITLE", "Download Module");
myWords.addText("en-us", "ABSTRACT", "Abstract for this module {0}");

// Portuguese Words
myWords.addText("pt-br", "TITLE", "Módulo de Download");
myWords.addText("pt-br", "ABSTRACT", "Resumo para este módulo {0}");
PHP
$myWords = new LanguageCollection($this->_context);
// English Words
$myWords->addText("en-us", "TITLE", "Download Module");
$myWords->addText("en-us", "ABSTRACT", "Abstract for this module {0}");

// Portuguese Words
$myWords->addText("pt-br", "TITLE", "Módulo de Download");
$myWords->addText("pt-br", "ABSTRACT", "Resumo para este módulo {0}");

To use a word defined in the dictionary:

CSharp
this._myWords.Value("TITLE")
// ou
this._myWords.Value("ABSTRACT", new string[]{"VALOR"})
PHP
$this->_myWords.Value("TITLE")
// ou
this._myWords.Value("ABSTRACT", array("VALOR"))

In the moldules, words in the LanguageCollection are read as a configuration file. This configuration file resides in the LANG file within the Shared folder or on the site itself. The priority is to open files from the very same site.

The file name is defined as the name of the module, including its namespace. For example: To run the ?namespace.module? module, the language file name should be: ?namespace-module.lang.anydata.xml?. Once read, the file can be used again normally, as seen previously.

Example of a Language File
<anydataset>
  <row>
    <field name="LANGUAGE">en-us</field>
    <field name="TITLE">XmlNuke - Download Area</field>
    <field name="ABSTRACT">Download Area</field>
    <field name="BLOCKTITLE">Download Area</field>
    <field name="FORMTITLE">Download Information</field>
  </row>
  <row>
    <field name="LANGUAGE">pt-br</field>
    <field name="TITLE">XmlNuke - Área de Download</field>
    <field name="ABSTRACT">Área de Download</field>
    <field name="BLOCKTITLE">Área de Download</field>
    <field name="FORMTITLE">Informações para Download</field>
  </row>
</anydataset>

Previous
The FilenameProcessor Class
Next
AnyDataSet and Data Access