3
votes

I have files named en_US.po, ru_RU.po etc. Editing *.po files in PoEdit is very useful, but not while adding new strings manually.

How can I easily add new translation strings which are not automatically detected by PoEdit?

3

3 Answers

4
votes

You can edit *.po files in any text editor and then in POEdit generate *.mo file

1
votes

You misunderstand how gettext translations work. Source strings for translation are extracted from source code. It doesn't make sense to add them manually — they would never be used if they didn't have corresponding source code that uses them.

So the way to add strings is to use xgettext or Poedit's update from sources functionality.

P.S. The name's Poedit, not PoEditor.

1
votes

You can configure your project (*.po file) opened in PoEdit. If you will done that correct PoEdit automatically update what to translate in this opened *.po file.

  1. First of all, open *.po file which you want update with strings to translate.
  2. Go to Catalog -> Properties then to Source Paths tab
  3. Add paths where PoEdit should look for source files in Your applilcation. More universal is to use relative to opened *.po file main path. If you have typical zf2 skeleton application folder structure you can add ../../.. for main path and add one module path.
  4. Then go to Source of keywords tab and add translate and if you're using zf2 forms it is useful to add addLabel keyword (PoEdit will scan sources for this functions and add string parameters from them to your *.po file, as string to translate)
  5. Next open Edit -> Preferences and in Processing programs tab, edit PHP section and add *.phtml extension (this will be scanned by poedit also)

After that you have to click in Update button and PoEdit will start scan your sources for strings to translate. Then you only have to do is translate found strings.