How to add a new string to a *.po file w/ a PO editor

这一生的挚爱 提交于 2019-12-20 11:37:01

问题


I MANUALLY created a file: test.po with the contents:

msgid "greeting"
msgstr "Hello World"

Now I can edit the translation (hello world) in editors like "poedit" and "GTranslated" (I'm using Ubuntu). I can even add comments to that translation. However neither "poedit" and "GTranslated" will let me ADD a new translation string - I've looked online to no avail and looked at screenshots of other editors and none seem to have a "new" button.

What am I missing??? It seems stupid to have to edit new keys w/ a "plain" text editor and then edit them in these PO editors (whichever they may be). (If you can't tell I'm new to this 'gettext' world - I'm building a website in Zend/PHP.)


回答1:


You should never be adding strings directly to a .po file; they will be added by msgmerge from the .pot file generated by xgettext.




回答2:


Here's what I did:

Edit the .po file and add your new string, for example:

msgid "All Catalogues"
msgstr "Todos los catalogos"

Save the .po file.

Now open it in poedit and in the menu select: Catalog > Update from POT file

Once you've updated you should see the new string and will be able to change it.

Save changes and you're good to go.




回答3:


MacOS:

  1. Edit the .po file in any text editor.
  2. Open the .po file in Poedit (free)
  3. In Poedit, select file -> Compile to .MO

This is what worked for me in a Wordpress Genesis .po file.




回答4:


open the .po file with any text editor, add these line or what ever the text need to added.

msgid "All Catalogues"
msgstr "Todos los catalogos"

save and launch :-D



来源:https://stackoverflow.com/questions/7680021/how-to-add-a-new-string-to-a-po-file-w-a-po-editor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!