<TEI:TOK>

Main Menu


Powered by TEITOK
Maarten Janssen, 2014-

TEITOK Help Pages

Setting up Internationalization

In many cases, you might want to have the interface of your site in more than one language, or only in a language that is not English. For that, the internationalization allows you to set up your site for display in other languages.

Defining the interface languages

Which languages can be used in the interface is defined in the settings.xml. An example of how to do that is given below.

In this example, Dutch and English are selected, identified by their ISO 639 code. In the first line, English is defined as the default interface language. The settings prefixed indicates that a prefix is used in the URL to keep track of the selected language. In case this is not possible due to the server settings, this attribute should be set to 0

When more than one language is selected, a language select option will appear in the menu bar, where each language is displayed by the value of the menu attribute. The locale attribute is an optional attribute to have country-specific things like dates show correctly.

Translating individual HTML files

Pages with explanations in HTML are translated by different files for different languages. The language is indicated at the end of filename, so the file home.html, which is the landing page of the site, can be translated into a different language by for instance creating a file called home-pt.html for Portuguese. These files ar never called by their full name, but rather get resolved by the system. So the the URL index.php?action=home will open the file home-en.html when English is selected, or home-pt.html for Portuguese. The shorter name home.html will always be interpreted as the homepage in the default language.

The creation of internationalized HTML files is helped along by the Edit HTML Files section in the Admin section. For each HTML file on your site, the system will check whether that file is present in all languages selected in the settings.xml, and suggests creating a translation when the translated HTML file is missing. When creating a new translation, the system will always open the existing file, which can then be translated bit by bit by replacing the text in English (or whatever language is already available) to the target language.

As long as a translation is missing, the system will always open the page in the best language availabe. So after selecting Portuguese as interface language, the system will open home-en.html or home.html if there is no file home-pt.html. This can be used purposefully for HTML pages with embedded i18n codes (see next section).

Translating parts of pages

Many of the standard interface pages in TEITOK, such as the pages for the individual manuscripts, contain a lot of code that does not need to be translated, as well as the original manuscript text that should not be modified either. On such pages, a code is used to specify which words on the page should be translated: the code {%This text} indicate that This text should be translated into the selected interface language, so that when choosing Dutch as interface language, it will show Deze tekst. These codes can be used in user-generated texts as well, for instance in the teiHeader, but also in individual HTML pages, such as a bibliography list where only a small number of words will change between one language and the next.

The way the system figures out how to translate This text is by looking up the word in a so-called i18n file (short for internationalization). If it cannot find the translation in the i18n files, it will display the untranslated text. In TEITOK, there are two types of i18n files: common files and project-specific files. The common files provide the translation of all the words in the interface into a small number of languages. The project-specific files can be used for either additional languages, or for additional translations needed in a specific project.

To add the internationalization for a new language, you should copy the file i18n_auto.php to the Sources folder in your project folder, giving it a name corresponding to the language you are defining - for instance Sources/i18n_sw.php for Swahili. After copying, open the new file in a simple text editor. That file contains all the internationalized texts in the common Sources, and translating those should provide a largely localized interface, minus all the project specific translations.

In the Edit Internationalization section you can provide the missing translations. Notice that hence the i18n section does not list any words you did not encounter yourself, which is why it is important to browse through your own site in all interface language from time to time to check for missing translations. Translations should always be whatever you want the site to site in the interface language, which will not always be a literal translation. To see how the word was used, the system lists where the missing translation was first encountered. The project-specific i18n files are stored as plain text files in the Resources folder, which can be edited in the Edit settings files section.


Back to index