Cotonti / Open Source PHP Content Management FrameworkContent Management Framework

Documentation / Extending Cotonti / Localizations / Localization-files for Cotonti

explaination and creating a new localization

In a default installation of Cotonti, all text is displayed in English. This is common known, but not always suitable for your site.

Those texts can be change via the language files.

There are already localization available for Cotonti. See http://www.cotonti.com/locales/.
Each version of cotonti uses its own version of the language files.

 

1. Language code

Each language has his own 2-character ISO language code. eg. English: en ; Russian: ru ; German: de ; Dutch: nl ; …
This language code is used in each language-file. eg. Xxxx.en.lang.php, Xxxx.ru.lang.php, ...

 

2. Locations of the language files

There are different kind of language files which are located in different locations. In the list below you can substitute lang_code with a 2-character ISO code of an actual language.

/lang    This folder contains common and core language files. Each language has its own directory named as its language code eg. /lang/en/
/lang/lang_code/admin.lang_code.lang.php   administration backend localization
/lang/lang_code/countries.lang_code.lang.php   localized country names
/lang/lang_code/main.lang_code.lang.php   common lexis
/lang/lang_code/message.lang_code.lang.php   localized service messages
/lang/lang_code/translit.lang_code.lang.php   for languages other than English, it may represent tables for forward and backward transliteration
/lang/lang_code/users.lang_code.lang.php   user account related language strings
/modules/ext_name/lang/ext_name.lang_code.lang.php   contains extension localization (language) files
/plugins/plugin_name/lang/plugin_name.lang_code.lang.php   contains plugin localization (language) files
/themes/theme_name/theme_name.lang_code.lang.php   contains theme localization (language) files
/images/smilies/lang/lang_code.lang.js   contains names for the smilies

 

3. Content of the language files

Eg. Main.en.lang.php

<?php
/**
 * English Language File (main.lang.php)
 *
 * @package Cotonti
 * @version 0.9.0
 * @author Cotonti Translators Team
 * @copyright Copyright (c) Cotonti Team 2008-2011
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL.');
/**
 * Main strings
 */
$L['Access'] = 'Access';
$L['Action'] = 'Action';
$L['Active'] = 'Active';
$L['Activity'] = 'Activity';
$Ls['Guests'] = array('guests','guest');

 

First part is general info about the file.
Below “defined('COT_CODE') or die('Wrong URL.');” you can find the language strings.
Before “=” you can find the strings that is used in the .tpl e.g. {PHP.L.Access}. This string in the tpl will be replaced by the text between brackets after the “=”.
Sometimes you see array after ‘=’, this means that the engine will decide upon some parameters to choose between the items in the array. Like above it will use plural or not.

 

4. Changing the language of your site

There are 2 ways to change the language used at the site.
- Change the language in the users own profile. This will effect only the user that changed his language
- Change the language in /datas/config.php 

$cfg['defaultlang'] = 'en';                      // Default language code

This will change the language for all guests and all new registered users.
There is also a setting in admin-menu to force the default language for all users. 
http://yoursite.com/admin.php?m=config&n=edit&o=core&p=locale

 

5. Creating your own localization

- Copy all language files and change the 2-character ISO code to the language you will use (For the location of the files, see above)
- Translate all texts after “=” between the brackets. Don’t change the word array or the text before “=”, or the strings will become unusable.


No comments yet
Adding comments has been disabled for this item