Localizing Your Application
Any Controller that uses localized content should include the use of the L10n CakePHP utility class.
Простой текст//Include the L10n class:App::import('Core', 'l10n');class RecipesController extends AppController { //... }
Next, you’ll need to create language files that manage the localized strings. Each language contains a set of strings and their IDs. Creating these files sets up a way for content to be organized and translated. Each language should contain a default.po file in a folder named after the language of the strings it contains.
Простой текст/app/locale/eng/LC_MESSAGES/default.po (English)/app/locale/fre/LC_MESSAGES/default.po (French)/app/locale/por/LC_MESSAGES/default.po (Portuguese)
The locale folder is located inside the app folder of your CakePHP installation. The three-character locale codes confirm to the ISO 639-2 standard (examples can be found at the Library of Congress Website, http://www.loc.gov/standards/iso639-2/php/code_list.php).
Once you’ve created the files, populate them with the string key and value data used for the localization process. Each string key must be unique and contain a corresponding value. Here’s a basic example of what might be inside of an English language .po file:
Простой текстmsgid "purchase"msgstr "Please purchase a pastry by selecting its name and pressing BUY NOW."msgid "search"msgstr "Click here to search our recipe database."
.po files should be encoded using UTF-8, and there is a 1014-character limit for each msgstr value. If you are using a Macintosh, be careful to ensure you use Unix linebreaks (LF), otherwise the file may not be parsed correctly. You can avoid worrying about the details by using Poedit, a free tool for editing po files.
Once you’ve created the .po files correctly, your application has been localized.


Коментарии:
Добавить коментарий