Thứ Năm, 27 tháng 6, 2013

Create .po language files using PoEdit in Zend 2

Create .po language files using PoEdit

In this post i will instruct you guys on how to create your very own translation files for your ZF2-Modules using PoEdit. I wasn’t able to find any information at all on how to create language files from scratch. All i was able to find were information on how to edit existing ones. If your google skills are as bad as mine, i hope you somehow found this post for me to help you out. Let’s take a look on how to create language files from scratch.

Set up PoEdit for ZF2 View Fiels

By default PoEdit doesn’t know how to parse ZF2′s view files. We first need to tell the program to actually look for and parse them. This is done by following these simple steps:
  • Download PoEdit
  • Install and Open PoEdit
  • GoTo Menu File > Settings > Parser
  • Select PHP > Edit
  • Add ;*.phtml to file extensions to parse
  • Hit OK twice

Create the language files

Now let’s take a look at why PoEdit is so much referenced throughout the internet when it comes to generating translation files. We will automate the process for our very own translation files.
  • Goto Menu File > New Catalog
  • Feel free to edit the Information in the window, but leave Language blank
  • GoTo Tab Paths
  • Add the path to your Module as default path, e.g.:
        C:\xampp\htdocs\AwesomeApp\modules\MyModule
  • Add . as an alternate path
  • GoTo Tab Keywords
  • Add the ZF2 translator keyword “translate” (obviously no brackets)
  • Hit OK
  • Select your save-path, e.g.:
        C:\xampp\htdocs\AwesomeApp\modules\MyModule\language
  • Define the file name, e.g.: ‘de_DE’.po
  • Hit OK
That’s it. Now PoEdit will look through all .phtml-files and search for the translate function. All values passed to the view helper will be referenced in the .po file and you’ll be able to edit translations for your file.
One thing to note: When you wish to add or remove single translation string when making newer versions of your Module, simply open the language file, e.g.: de_DE.po and select Catalog > Refresh from sources
PS: I only have PoEdit on a german version. I assume that my guessed translation for menu items will be very similar but probably won’t match 1:1. Please help me out and leave a comment for me to be able to update this post for greater accuracy. Thanks in advance.

resources :  http://samminds.com/2012/09/create-po-language-files-using-poedit/

Không có nhận xét nào:

Đăng nhận xét

Học lập trình web căn bản với PHP

Bài 1: Các kiến thức căn bản Part 1:  https://jimmyvan88.blogspot.com/2012/05/can-ban-lap-trinh-web-voi-php-bai-1-cac.html Part 2:  https://...