Developers Documentation

×

Warning

0 error for file:https://clearos.com/dokuwiki2/lib/exe/css.php?t=dokuwiki&tseed=82873f9c9a1f5784b951644363f20ef8

User Tools

Site Tools


Language

ClearOS includes support for multiple languages. The framework uses the standard CodeIgniter system which is described here.

A team of ClearFoundation translation volunteers are ready to help with your application! We have also made it easier for you to import and maintain translations with the online translation tool.

File System Layout

Inside every ClearOS App directory, you will the language directory. Inside this directory is a subdirectory for each supported language. The language files are stored in these subdirectories.

Creating Language Files

All language files must end with _lang.php. For example, the ClearOS User Manager App (app-user) includes the translation file user_lang.php. Inside this file are $lang array entries similar to what is shown below.

$lang['user_first_name'] = 'first name';
$lang['user_last_name'] = 'last name';
$lang['user_email_address' = 'e-mail address';
...

It is good practice to prefix all language tags with the App name. This prevents collisions with other translation files.

As you are developing your ClearOS App, edit the translation file in your language as you go. When you are ready to publish your app, you can import your translation file into the online translator. You can find out more about this process here.

Loading Language Files

In order to keep ClearOS lightweight, translation files are not automatically loaded. Instead, translations must be explicitly loaded in your library, view or controller. In a library, loading a translation is done through clearos_load_language():

clearos_load_language('base/base');
clearos_load_language('user/user');

In a view or controller, loading translations is done with the standard CodeIgniter call - $this→lang→load():

$this->lang->load('base/base');
$this->lang->load('user/user');

Using Language Files

Use the lang() function anywhere in your code to access the translations. That's all there is to it.

echo lang('user_last_name') . ': ' . $lastname;
echo lang('base_help');
content/en_us/dev_framework_reference_guide_language.txt · Last modified: 2015/03/01 16:40 (external edit)

https://clearos.com/dokuwiki2/lib/exe/indexer.php?id=content%3Aen_us%3Adev_framework_reference_guide_language&1569165354