Зміст

Domain Translation

The header, the menu, the footer, and the pages of a domain can be shown in the viewer's language. It works the same way as game translations: a dictionary of “source → translation” pairs lies beside the text, and the text is substituted when shown. Where there is no translation, the viewer sees the original.

The screen is “Translation” in the domain's admin panel (“Translations” in the new admin). It can be opened by a domain admin.

This is only about the text you wrote. The engine's own buttons, emails, and interface are translated on their own and have nothing to do with this dictionary.

Settings

The "Settings" tab: the domain's language, the translation languages, and what untranslated text falls back to

A fallback may only point at a language the domain has declared. Untick a language and everything falling back to it is reset right there on the screen.

Localization can be switched off (“Localization off”) at any time: the substitution stops at once for everybody, and the dictionary stays intact.

Pages

The “Pages” tab lists the domain's pages and asks about each one: is it translated by the dictionary or not.

A page may have a copy of its own in another language. Such a copy always beats the dictionary: if it exists, the viewer sees it, and the dictionary is not applied to that page. There is no way to turn a copy into dictionary pairs — it is either the copy or the dictionary.

Translations

The third tab is the table of pairs itself. It is exactly the same table as the “Translation” tab of the game editor: the same “untranslated / translated / not translatable” groups, the same filter, the same “do not translate” marks. How it works is described in detail on the Multilingual Game page.

There is one difference — the “What are we translating” selector in the filter bar:

“Everything at once” writes a translation into several dictionaries. A string that occurs both in the header and on a page is one row of the table, and editing it writes into the dictionary of every place the string occurs in. If a page needs its own wording for the same phrase, narrow “What are we translating” down to that page first.

What Gets Translated

Not translated: css, addresses (the domain name, a page's address), mail and payment settings, the engine's own text, and the content of games — games have translations of their own.

The domain's emails go out with the base name, not the translated one.

{% match lang %} templates do not work in the domain design — that is a device for tasks.

Text Inside Scripts: gt()

The domain menu is a script, and the button captions in it are plain strings. To let the engine see them, wrap each one in gt():

add_navbar({
  items: [
    {name: gt('ИГРЫ'), url: 'index.php'},
    {name: gt('АРХИВ'), url: 'archive.php'},
  ],
  ...
});

The caption then shows up in the translation table as an ordinary string, and the translation is substituted on the server, before the page reaches the viewer.

This works in any html block of the design, not only in the menu.

JSON: Export and Import

The “JSON” button at the top of the screen:

Loading does not save: it edits the screen, and it is the “Save” button that writes. The browser will not let you leave the page with unsaved changes in silence — it asks.

Loading merges rather than replaces: pairs are applied one by one. An empty translation in the file means “remove this pair”.

Both kinds of file are accepted — the full snapshot and the translator's file.

A New Domain

A new domain inherits the base domain's dictionary — as a copy, once, at the moment of creation. Later edits to the base domain's dictionary never reach it.

A new domain has a name of its own, so the inherited translation of the old name arrives in “Outdated translations”, and the new name stays untranslated.

Worth Knowing

The Old Way: addTranslation()

Menu captions used to be translated in the browser, by a call in the menu block itself:

addTranslation('en', 'АВТОРАМ', 'ABOUT');

It still works, and running domains are not deprived of it. But it covers only the menu button captions — not the header, not the footer, not the pages — and it says nothing about what is still untranslated.

There will be no double translation: if the server has already translated a string, what reaches the browser is the English one, and addTranslation simply does not find it.

For a new domain use gt() and this page.

See Also