Articles

Language Packages - Project

Language Packages - Project's Articles

Rastin Mehr

Rastin Mehr

July 22 2012

An introduction to Anahita translation files

Anahita 2.0 is currently using the same translation management system inherited from the Joomla! 1.5 with some improvements that we have done, such as ability to do translation overwrites for an existing file.

In an Anahita installation the translation files reside in the following directories:

  • SITE: languages/en-GB
  • ADMIN: administrator/langugages/en-GB
the en-GB folder is named after the language tag we construct to identify different language packages. Inside those folders also you see list of files that are prefixed with the language tag and postfixed with .ini for example:
  • en-GB.com_people.ini (translation file for the com_people component)
  • en-GB.com_actors.ini (translation file for the com_actors component)
  • en-GB.mod_actors.ini (translation file for the mod_actors module)
The translation files in the SITE are used in the front-end your Anahita installation. The ones in the  ADMIN side are used to localize the user interfaces in the administration backend of a certain component or module.

When you download an Anahita app or extension, the translation files are in the site/language or admin/language directories in the package. For example for the Anahita Photos we have:

site/language/en-GB.com_photos.ini 

Constructing The Language Tag

the en-GB is the language tag is constructed from 2 parts separated by a dash:

The 1st part is a 2 letter ISO 639-1 language name code The 2nd part is a 2 letter ISO 3166-1 alpha 2 country name code

Now don't let those ISO standards scare you. You probably know many of them already. For example:

en-GB is English Great Britain en-CA is English Canadian en-US is English USA

fr-FR is frech France  fr-CA is french Canadian

and so on.

The XML files

Every translation folder in the SITE or ADMIN also contains an xml file with the following tags:

For the SITE

<!--?xml version="1.0" encoding="utf-8"?--> <!-- $Id --> <metafile version="2.0" client="site"> <name>English(United Kingdom)</name> <tag>en-GB</tag> <version>2.0</version> <creationdate>2012-07-22</creationdate> <author>Anahita Project</author> <authoremail>info@anahitapolis.com</authoremail> <authorurl>www.anahitapolis.com</authorurl> <copyright>Copyright (C) 2012 Anahitapolis.com</copyright> <license>GPL3</license> <description></description> <metadata> <name>English (United Kingdom)</name> <tag>en-GB</tag> <rtl>0</rtl> <locale>en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain, uk, united kingdom, united-kingdom</locale> <wincodepage>iso-8859-1</wincodepage> <backwardlang>english</backwardlang> </metadata> <params> </params></metafile>

For the ADMIN

<!--?xml version="1.0" encoding="utf-8"?--> <metafile version="2.0" client="administrator"> <name>English(United Kingdom)</name> <version>2.0</version> <creationdate>2012-07-22</creationdate> <author>Anahita Project</author> <authoremail>info@anahitapolis.com</authoremail> <authorurl>www.anahitapolis.com</authorurl> <copyright>Copyright (C) 2012 Anahitapolis.com</copyright> <license>GPL3</license> <description></description> <metadata> <name>English (United Kingdom)</name> <tag>en-GB</tag> <rtl>0</rtl> <locale>en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain, uk, united kingdom, united-kingdom</locale> <wincodepage>iso-8859-1</wincodepage> <backwardlang>english</backwardlang> </metadata> <params> </params></metafile>

The fields in the xml files are pretty self explanatory.

Translation Labels

When you open an .ini file you notice that there are a lot of key value pairs in the file. For example in the en-GB.lib_anahita.ini you can find: LIB-AN-YES=Yes LIB-AN-NO=No 

In these examples LIB-AN-YES AND LIB-AN-NO are the translation labels. If we had a french translation package then we would have had a fr-FR.lib_anahita.ini file which contained:

LIB-AN-YES=Oui LIB-AN-NO=Non 

When we develop Anahita code, instead of typing sentences and words directly into the code, we use the translation labels. For example in the component layouts you might have seen @text('LIB-AN-YES') or in the code you might have seen JText::_('LIB-AN-YES'). By using @text or JText::_() we are basically asking the code to output the value assigned to the LIB-AN-YES tag which in this case is "Yes" on the English mode and "Oui" on the french mode.

Additional Information

Powered by Anahita