phTagr supports multi-languages with automatic language selection. Translations are done similar to the gettext mechanism, which uses specific translation tables. These translation tables could be created, edited, and updated with e.g. the handy poEdit editor.
Create translation file in your language
Your language is missing? You can create with an PO editor (like poEdit) and submit the complete translation to [firstname.lastname@example.org].
Following example is given with poEdit (available for Windows, Linux, or Mac):
- Download current root translation table file from current master: Locale/default.pot
- In poEdit goto File -> New Catalog from POT file...
- Select the default.pot file
- Enter your name, email address, your language and country to the setting form (source code charset is utf-8)
- Start translating
- Send your default.po and default.mo to translation [AT] phtagr.org to submit your contribution to the source code
- Feel happy! You did a great contribution
If you're updating or correct a translation, open the translation file default.po of your language and download the current root translation file from current master Locale/default.pot. Select Catalog -> Updated from POT file... in poEdit and translate the updated strings. Send again your translation to the translation team of phtagr, to submit your contribution to the source code.
Test your translation
Copy your translation files to the correct location of your phtagr installation. The folder structure is given below. See cakePHP language codes or official ISO 639-3 language codes for your language. Eg. ita for Italian, tha for Thai.
To test your translation within your browser, your browser must send the correct Accept-Language HTTP request header for the automatic language selection. With [www.mozilla.org Firefox] you might be able to change this HTTP request header via the about:config page. Change the intl.accept_languages value to your language and watch your translation.
Update Your Language
You do not need to translate all texts if some translation is already done. Here are the steps to update or complete a translation file
- Open your translation file from Locale/[your country code]/LC_MESSAGES/default.po
- Goto poEdit's menu "Catalog" -> "Update from POT file"
- Open the phtagr's base translation file from Locale/default.pot
These steps merge phtagr's translation to your translation texts. You should have some text "25 new, 3 obsolete" in this merge dialog. Now you can translate these 25 new text entries and save the file and send it to [email@example.com] or commit it.
The translation files are stored in Locale/language code/LC_MESSAGES/default.[pm]o.
/phtagr /cakephp <-- CakePHP framework /Locale <-- Folder of tranlation tables /eng <-- Language folders (format of ISO 639-3 or language codes in ll-cc format, e.g. en-US) /LC_MESSAGES /deu /LC_MESSAGES default.po <-- Portable Object file, human readable translation table default.mo <-- Machine Object file, final translation table file ... default.pot <-- Root translation table
Automatic Language Selection
cakePHP selects the language according to the Accept-Language HTTP request header. If the translation is not present, it uses the default string, which is mainly (some sort of) English.
Fixed Language Selection
It is also possible to disable the automatic language select and set a fix language. Please edit your Config/core.php configuration and add following lines to it:
With this configuration the web galler phtagr would only speak German. See Localization in CakePHP for more details.