Localization Issues

The DVelum platform supports several interface localization languages. The interface language is set during the system installation (by setting a tag in system/config/main.php). Herewith, the system is being configured to work with dictionaries, localization of ORM object properties and names, lists of connected modules using specific localization.

Main localization files may be found in the system/lang directory. Additional files are located in child directories, like system/lang/[en]/objects.php, which contains localization of ORM object properties.

There is localization in php-files and it is automatically transmitted in js-format to be used in visual interfaces. To update js-transmission after making changes to files of the main localization, you’ll need to enter the Code Compiler interface and click “Compile Lang”/”Rebuild dictionaries”, thus rewriting the file /js/lang/[locale].js (writing permissions required).

To access the localization dictionary from visual interfaces using JavaScript, appLang object should be used as it contains the necessary locale. For instance, appLang.EDIT_ITEM will contain the ‘Edit item’ string and depending on the current sing a dictionary from PHP, use the following scheme:

<?php
// getting a link to the object of default localization,
// the dictionary is already initialized in some parts of the system,e.g.:
// $this->_lang in the controllers of the admin panels
$lang = Lang::lang();
echo $lang->EDIT_ITEM;
// a more preferable option as it works quicker, the magic methods being bypassed
echo $lang->get('EDIT_ITEM'); 

Registration of your own dictionaries, lazy load:

<?php
// Add dictionary uploader
// a dictionary name, a path to the file, the type of the adapter for the Config object
// in this case, our dictionary is located in the php file as an array, just like the main localization files:
Lang::addDictionaryLoader('myLang', 'path/to/file.php', 'File_Array');
// get the link to your own dictionary
$myLang = Lang::lang('myLang');
// get the value from the dictionary; note that the dictionary will be uploaded on the first invoke
echo $myLang->get('lang_key');

Thus, using the output of local strings only in cacheable templates,we considerably increase the performance, saving time and RAM for uploading big localization dictionaries.

ORM Localization Specifics

ORM performance doesn’t in any way depend on switching languages. When field and object titles are specified, the data is saved in the current localization file. Once the locale is switched in main.php, ORM locale file is switched as well. If the current locale lacks the items (the interface is not translated), the name values will be taken as titles.

For instance, if we create Object name = news, title = News List, the other locale will display it as the object name = news, title - news. The same goes for object properties. So, for a translation, it is necessary and required to switch to another language and change titles of the objects and their properties.

Dictionary Localization Specifics

Dictionaries depend on localizations, each being saved in a separate directory. Please note that when the system language is switched after the system has been set up and the work with it has been started, there might be lacking some of the dictionaries and their values; they need to be manually synchronized in the case.

Dictionaries are located in system/config/dictionary/[lang]. Let’s say, the system has been installed and several dictionaries have been created. After that, for some reasons the localization has been changed, for instance from [en] to [ru]. To ensure the correct work of the dictionaries, it is necessary to copy all the files from system/config/dictionary/en to system/config/dictionary/ru and set the localization value for each of dictionary from the admin interface.

Attention! Changing one localization dictionary does not lead to changes in another one. The issue will be probably resolved in further releases.

Connected Modules List Localization Specifics

The situation with connected modules is practically the same as it is with dictionaries, their configuration may be found in the system/config/modules directory.

The characteristic feature is that a different set of modules and their interfaces may be connected in different localizations.

Interface Projects Localization Specifics

The Layout Designer projects have no multi-language localization support, however, the issue is resolved by copying the interface file and renaming the necessary titles. Then, specify different Layout Designer projects for different locales in the list of connected modules.

Localization related files:

  • js/lang (are generated automatically)
  • system/lang/ (main localization files)
  • system/config/dictionary/ (language dependent files)
  • system/config/modules/ (language dependent files)