Login +

i18n / Advanced i18n

At application level

You can define as many languages ​​as desired in the application.

Once the languages ​​defined, SillySmart analyzes the different translations in the URL to load the application in the right language.

For example :

http://vhost.domain.iso/Home/Welcome.sls

=> Load the application in English.

http://vhost.domain.iso/Accueil/Bienvenue.sls

=> Load the application in French.

If the URL does not identify the language (for example : http://vhost.domain.iso/), SillySmart will search language in the following order:

  • The current session of user
  • The current cookie of user
  • Language of the web browser

If any of these techniques can identify one of the languages ​​of the application, SillySmart load the default language.

At interface level

Multilingualismin point of view of interface is managed by translations into the language files loaded according to their location in the tree.

  • Langs
    • Action
      • Controller
        • __Controller.xx.lang.php
        • Action.xx.lang.php
    • Generics
      • Site.xx.lang.php

To display one of these languages ​​in XSL, simply call one of predefined XSL templates.

<xsl:call-template name="displayLang">
    <xsl:with-param name="str" select="'variable_key'" />
    <!— Optional : -->
    <xsl:with-param name="escaping" select="'yes'" />
</xsl:call-template>

The second parameter is optional (default: 'false'). It can interpret the HTML content in the value of language variable (not recommended).

To simplify the process of translation, the following pattern works (HTML parsing) :

||| sls:lang:'variable_key'|||

At database level

If you want to manage multilingual data in the database, just change the table structure in which you want to insert datas into N languages.

By adding a second primary key named "pk_lang" in your table, SillySmart will automatically identify the multilingual nature of the latter.

At Models level

When you want to recover data from a Model through the getModel($id) function, you have nothing particular to do. SillySmart based on the common language of the application to retrieve data from the table whose id is passed as a parameter and automatically adds the clause on language.

When you want to save a record in a Model, you must first call the setModelLanguage($lang) function from the FrontModel by inheritance.

When you want to delete a record from a Model, a simple call to delete() function will delete the entry in N application languages.

When you want to find N records you should add the clause in the where parameter of searchModels() function, typically:

array("column" => "pk_lang",
      "value" => $this->_lang->getLang(), // Current lang
      "mode" => "equal")

At Back-Office level

Automatically add and modify forms request you informations about your entity in the N languages ​​through the left menu :

If all table informations does not need to be translated (dates, foreign keys) you can uncheck the columns you want in the form of Model:

This will affect the customer back office information by cloning automatically from the default language:

SillySmart requires its tables have multilingual data stored in the N languages​​. If you want to have tables for multilingual only in few entries, you should implement it yourself multilingualism in another way.

Related :