Interface languages

Energine 2.13 ships two languages, Russian and Ukrainian; Russian is the default, and Ukrainian pages are under /ua/. There is no English. A language is added in the admin: it starts as a copy of the default one, and you translate its pages and interface strings.

1. Before the first language

A fresh 2.13 database has two interface-string translations whose constant does not exist, and the language editor stops with a foreign-key error when it copies them. Delete them once, in the site's database:

DELETE t FROM share_lang_tags_translation t
LEFT JOIN share_lang_tags g ON g.ltag_id = t.ltag_id
WHERE g.ltag_id IS NULL;

2. Add the language

In «Редактор языков» (Language editor), /admin/translations/languages/ or «Языки» (Languages) on the page toolbar:

  1. Press «Добавить» (Add) and fill in «Аббревиатура языка» (Language abbreviation) — two Latin letters, en — and «Название языка» (Language name) — English, at most 20 characters. Save.
  2. Select the language, press «Редактировать» (Edit) and set «Локаль» (Locale), such as en_US.UTF8: the add form has no locale.
  3. «Поднять» (Move up) and «Опустить» (Move down) order the languages of the switcher.

The language opens at once with a copy of everything of the default language: pages, text blocks, news, mail templates and interface strings. /en/ shows the site with the Russian texts, and the admin under /en/admin/ has Russian captions, until you translate them. To keep a page out of a language for now, tick «Отключен» (Disabled) on that language's tab of the page form: the page answers 404 in it.

3. Translate the pages

Switch the site to the language and edit the texts in edit mode — in Firefox; see Structure and content. Names, titles and descriptions are on the language's tab of the page form.

4. Translate the interface

«Редактор переводов» (Translations editor), /admin/translations/ or «Переводы» (Translations) on the page toolbar, lists every constant with «Перевод» (Translation) on a tab for each language. Month and weekday names are constants too: TXT_MONTH_…, TXT_WEEKDAY_…. A few captions are written into the scripts themselves and are not in the list.

The console tools run from htdocs/ as the site's user:

Command What it does
php index.php setup untranslated lists the constants used in the code and templates that have no row in the dictionary
php index.php setup exportTrans writes the constants used in each module's code to install/translations.csv of the module — ;-separated, with the header CONST and the languages' abbreviations; it stops at the first module without an install/ folder, so create one in every module of the core — core/modules/<module>/install/, which is inside the core's checkout — and in site/modules/main/
php index.php setup loadTransFile <file.csv> loads such a file: it adds the constants that are not in the dictionary and skips the ones that are

loadTransFile cannot change the strings that a new language got as copies: translate them in the translations editor, or in the table share_lang_tags_translation of the database.

Deleting a language

The current and the default language can't be deleted. Deleting another deletes everything kept in it; see Known risks.