Module refers to the part of the CMS "Management", intersects with all modules of the site and is required for installation.
Languages have the following characteristics:
When you add or remove language of the site is changing the database structure, structure of the site. You can not remove the primary site language.
Any language of the site can be defined as the basis for the administrative part and the main part of the user. When this language is previously labeled for the respective primary portion becomes basic. Main language can not be deleted.
The module allows you to define your own version of texts in the interface. interface editing form has the following fields:
Translation of source code can be set manually. If you open different from the english version of the site, all available on the current page of text with no translation will be added to the base for further transfer. Search added text easily by using the search form.
Translation interface, you can import and export, and edit from the user of the module with the help of "Quick Edit Panel".
Подключаемая часть – файл modules/languages/languages.inc.php. В нем описан класс
Languages_inc. В модуле к объекту класса можно обратиться через переменную $this->diafan->_languages
. Экземпляр класса создается при первом вызове
переменной.
var is_ru = false – это русская версия сайта.
string get (string $name, [string $module_name = ''], [boolean $useradmin = false], [array $args = array()]) – Отдает значение перевода строки.
For quick access to functions in the main system object defined function _()
.
Example:
// full version
$text = $this->diafan->_laguages->get('Hello, %s! You have %d new messages.', 'registration', false, array('Fred', 3));
string base_admin () – Определяет язык версии административной панели для текущего пользователя.
void import (string $file_path, integer $lang_id) – Импортирует файл перевода.
Example:
// import the file transfer langs/eng interface language ID=2
$this->diafan->_languages->import(ABSOLUTE_PATH.'langs/eng', 2);
string _ (string $name, [boolean $useradmin = false]) – returns translate of string for the current module.
access: public
string $name: the text for translation
boolean $useradmin: issue a form for editing, only parameter the user part
Additionally, you can pass arguments to the function, in order to substitute them in the function vsprintf()
.
Example:
// abridged version
$text = $this->diafan->_('Hello %s! You have %d new messages.', false, 'Fred', 3);
array all – an array of data about all the languages used on the site.
Example:
print_r($this->diafan->_languages->all);
Result:
Array
(
[0] => Array
(
[id] => 1 // language ID
[name] => english// language name
[shortname] => eng // abbreviation, used in the URL
[base_admin] => 1 // is the main language for the administrative part
[base_site] => 1 // is the main language for the site
[page_act] => 1 // current page exists for the language mirrors
)
[1] => Array
(
[id] => 2
[name] => russian
[shortname] => ru
[base_admin] => 0
[base_site] => 0
[page_act] => 1
)
)
integer site – the language number is used as the main site.
Example:
if(_LANG == $this->diafan->_languages->site)
{
echo 'The current language is the primary online.';
}
integer admin – language number, which is used as the basic admin part.
Example:
if(_LANG == $this->diafan->_languages->admin)
{
echo 'Current language is the basis for the administrative part.';
}
Для работы с модулем «Languages» служат следующие шаблонные теги:
show_block – выводит ссылки на альтернативные языковые версии сайта.
Атрибуты:
— defer – deferred load tag template tag: event – load content only at the request of the user when you click "Upload", emergence – load content only when the client window appears in the browser window, async – asynchronous (simultaneous) content loading together with the content of template tags with the same marker, sync – synchronous (sequential) load of content in conjunction with the content of template tags with the same marker, by default, downloading content only at the request of the user;
— defer_title – text string displayed at the point where the loadable content appears with the help of delayed loading of the template tag;
— template – tag template (file modules/languages/views/languages.view.show_block_template.php; default - file modules/languages/views/languages.view.show_block.php).
Example:
<insert name="show_block" module="languages">
выведет список ссылок на языковые версии сайта, «ru/eng»
В шаблоне тега можно получить значение любого атрибута через переменную $result["attributes"]["название атрибута"]
.
{languages} – Languages
{languages_translate} – Translation of interface
modules/languages/admin/js/languages.admin.translate.js – Редактирование списка языковых версий сайта, JS-сценарий;
modules/languages/admin/languages.admin.php – Редактирование списка языковых версий сайта;
modules/languages/admin/languages.admin.translate.php – Редактирование перевода интерфейса;
modules/languages/languages.php – Controller;
modules/languages/languages.export.php – Экспорт языкового файла;
modules/languages/languages.inc.php – Подключение модуля;
modules/languages/languages.install.php – Install of module;
modules/languages/languages.model.php – Model;
modules/languages/views/languages.view.show_block.php – Шаблон ссылок на языковые версии сайта.