wCMF Wiki : translate

HomePage :: Categories :: PageIndex :: RecentChanges :: Login/Register

Localizing the views

In order to program the views language independent, the Smarty function translate can be used. When the view is displayed, the framework determines the language and shows the corresponding translation. If there is no translation, the text of the function call will be displayed.

{translate text="Logged in as %1%" r0=$authUser->getLogin()} 


The parameters of the method Message::get are defined by the values of r0, r1, ...

Providing the translations

For localization of the application the method Message::get is provided. For a given (English) string this method searches for the required language's version. The language version can either be passed directly with the method call or can be set application wide (see documentation of Message::get).

How the translation is retrieved depends on the parameter usegettext (in the configuration section cms). If it is set to 1, the method uses the PHP function gettext. This in turn makes use of *.mo files in the directory

/localeDir/language/LC_MESSAGES - e.g. /locale/de_DE/LC_MESSAGES/main.mo (see documentation of gettext)

If gettext doesn't exist, the language version can also be taken from an associative array named messages_language (e.g. messages_de_DE). This must be defined in a file

/localeDir/language/LC_MESSAGES/messages_language.php - e.g. /locale/de_DE/LC_MESSAGES/messages_de_DE.php

The keys of the array are the strings, which are passed to the method Message::get, the values are the corresponding translations.

Note:
If a translation for a text doesn't exist, the string, which was passed to the method Message::get, will be used.

tools

For making the localization more comfortable some tools are provided in the directory /wcmf/tools/i18n:


Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.0781 seconds