php source code to PO file generator

喜你入骨 提交于 2019-12-23 21:19:39

问题


I have to convert all my echo/print string from my php source code file to PO file(for the language translation), is there any batch convector available for the same.


回答1:


How I do this:

  • make gettext run on your server
  • setup a translation adapter (for example Zend_Translate with gettext adapter)
  • use a good search tool to find all strings in your code and wrap them with something like $translationObject->translate(). Often the method is wrapped to be called __(). This will be at least partly handwork in most cases since you will have various forms of strings which you will maybe also want to split up into shorter units
  • install poEdit and configure it to parse for 'translate(' or '__('
  • send your resulting po-Files to the human translators and instruct them how to use poEdit
  • load the translations and generate mo-files which are used by the adapter



回答2:


You need http://www.poedit.net/

You can use Poedit to scan source code for translatable strings.




回答3:


Sadly, I do not think such a tool exists. If you find one it will likely be limited in functionality

This is due to ability of php to intermingle with html. It is hard to be able to know what exactly should be included in a particular gettext file.

If you only use "echo" statements to send content to the browser and you are never mixing html and php, then it is pretty simple to write up a script to parse that out.

HTH, -FT




回答4:


Yes I got the answer.

There is a method to extract all the string from a give source file for a folder. Here is the link you can check:

  • Extract the strings from source code for Translation (for po file) [link now dead]

  • Poedit: A cross-platform PO to MO converter and PO file editor [link now dead]



来源:https://stackoverflow.com/questions/1465752/php-source-code-to-po-file-generator

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