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.
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.
Defining languages for your page
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.
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 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.
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]'
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:
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.
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).
Phi can encode or decode files from and to the following encodings:
- Apple Roman
- 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
- Windows-1250 to 1258