Translation

From PhiWiki
Jump to: navigation, search

Phi comes with great support for translation issues for your web- or intranet page even for the page title you can choose translated text sources.

Basics

Via the web all strings will be transfered as UTF8 strings. Internally all strings are stored as 16bit Unicode characters what also enables you to a direct entering your text in the Aphilo editor in your native language even for example cyrillic characters. You also can read text from files with different encodings.

See also: Text sources, document.languages, phi.lang and Internationalization How-To.

Defining languages for your page

Pagelangs.png

First you have to choose which language you want to provide to your users. You can simply add the required language codes (for example de for german or de-ch for swiss german) in the page config dialog (right click in an empty space opens a context dialog and choose Settings to display the page dialog then switch to the Languages tab). Clicking on the plus sign adds the language to the list of available languages.

If you loaded a Site config before, the list will be already adapted with the settings from the site configuration.

Note: the default C language can not be deleted and should usually contain the english text.

Text translation

Browserphilang.png

After defining your available languages for your page you can translate each text element by opening the text data source dialog. The first match of the client (HTTP header Accept-language) and one of your provided languages will be choosen as language or the default C language if no language does match. You can explicitely overwrite a language by adding philang=<lang code> to the query in the address line of your browser.

Inline translations

Statictranslation.png

Inline translations are directly stored along with the *.phis page. You can open a small translation editor to show a language on the left side and its translation on the right by clicking on the Editor button.

Database translations

If you want to provide translations through a database you can use the variable $PHISERVER[lang] to optain the requested language (remember if none is found the C language will be set so ensure that at least a text for 'C' exists).

SELECT translatedtext FROM translations WHERE id='mypage:myitem' AND lang='$PHISERVER[lang]'

See also: $PHISQL, Database support.

File translations

Different files can be used for a requested language. If you want translations based on files you have to add a /C/ to the file path:

/translations/C/myfile.txt

All parts of the file path containing /C/ will replaces by the requested language for example for a german translation the file path above becomes /translations/de/myfile.txt. Ensure that at least always the default language path with /C/ exists.

Warning: Always use the / as separator in the dialog a \C\ will not be recognized. On Windows systems the path separators are automatically translated.

Automatic translations

Some elements are translated automatically for example the month and day names in a calendar item. A system call to the currently installed locales will be performed to get the translation names. If the locale is not installed for the requested language the C locale will be used (which mostly leads to an english translation).

See also: $PHISERVER[month][x], $PHISERVER[monthlist].

Supported encodings

Phi can encode or decode files from and to the following encodings:

  • Apple Roman
  • Big5
  • Big5-HKSCS
  • CP949
  • EUC-JP
  • EUC-KR
  • GB18030-0
  • IBM 850
  • IBM 866
  • IBM 874
  • ISO 2022-JP
  • ISO 8859-1 to 10
  • ISO 8859-13 to 16
  • Iscii-Bng, Dev, Gjr, Knd, Mlm, Ori, Pnj, Tlg, and Tml
  • JIS X 0201
  • JIS X 0208
  • KOI8-R
  • KOI8-U
  • MuleLao-1
  • ROMAN8
  • Shift-JIS
  • TIS-620
  • TSCII
  • UTF-8
  • UTF-16
  • UTF-16BE
  • UTF-16LE
  • UTF-32
  • UTF-32BE
  • UTF-32LE
  • Windows-1250 to 1258
  • WINSAMI2

See also: file.read(), file.write().