2017-04-09 |  admin
GB flag PL flag

Language

The language module is very powerful tool with many features.

This module has a lots of hidden hooks in CMS's core. The most important thing You need to know is: how does it works.

Crud_model

This model is extending a third_party Crud_model and has a ability to read the database in this pattern. When a language is changed - the all selected models content will change.

In this class are two important variables to control a language behaviour.

  1. is_language - inform class to seperate entries by language (DB table must contains entity language)
  2. language - it is expected language (leave it as null if class has to guess a user language from session, userdata or cookie)
If You want to use a language sensitive model then just remmember to set first variable to true in extented class. The rest will be made by the core. Also remmember to add entity language in selected table.

 Also when You update rows using CRUD pre-defined methods (like update, insert etc), the class will append a language value to posted data.

Changing language

To switch language - user need to pass an get argument lang with language slum, like: http://altego.pl/developers-cms-guide/62/language?lang=english.

The System_language controller in core path will find and activate a expected lang.

If an entry exists with this slum (developers-cms-guide/62/language) - the output will be rendered. For example if You also have a translation in others languages like polish and You type a url with lang=polish then a content will be changed. It is recomended to create a multilanguages pages with the equivalent slums.

Tip: To easy change a translation of page in front - use CodeIgniter url helper with parameter like: <?= anchor (current_url().'?lang=english', 'EN')?>.

Wizzard

It is a helper controller allowed only in DEVELOPMENT mode (on localhost). Has a lots of features to make easier translations to new languages.

By default all used language must be installed first (see a user's guide) and the unpacked files are storred in application/language path.

CMS is written oryginaly in Polish and English so both of these langs is in application path and when You use a wizzard's tools - the controller look into that directory first.

Creator

The most important tool. Just go to language module and find this position in sidebar menu.

Then find a oryginal language (to translate from) and type to language field to start translation progress in easy way.

After that the system will give You first found not translated line (prepare for this - on this moment it is about 1000 lines to translate).

The creator has a lots of ulitiles to helps You. Use a Google translation plugin t otranslate a whole page (and a translation line) and if it is ok then just click to   copy button and submit changes.

Some of words are really simple and if You notice it - just press enter to go forward.

Don't worry about undercores, slashes and font capacity - because the validator will set it to correct value.

Adding new word

To do it please use a add button in language module. It is easy in use and after creating word in one language - redirects to simillar value in other lang.

You need to fill up a fews fields only:

  1. Language - where You add new line,
  2. File - modules has separated lang files, You can add line to one of these files or add to global CMS_lang file,
  3. Key - a slum line name (must be valid like variable name). Use ":" character to make sub-element like $lang ['item']['subitem'],
  4. Translation - a language line You want to use.
Good habits

It is good to add preffix before entering a new line slum. For example if You type a success message then use: success_Your_slum or title_description_to_field_x.

"Compiling"

When You finish all Your tasks, You need to compile new files to .ZIP. To use it just click generate button and select Your language. Then You can share it or easy update in pages managed by You.

Gallery