3

我必须将我的所有回显/打印字符串从我的php 源代码文件转换为PO 文件(用于语言翻译),是否有任何可用的批处理对流器。

4

4 回答 4

4

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
于 2009-09-24T07:27:53.590 回答
1

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

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

于 2009-09-24T07:15:58.527 回答
0

可悲的是,我认为不存在这样的工具。如果你找到一个,它的功能可能会受到限制

这是由于 php 能够与 html 混合。很难知道特定的 gettext 文件中究竟应该包含什么。

如果您只使用“echo”语句将内容发送到浏览器并且您从不混合 html 和 php,那么编写一个脚本来解析它是非常简单的。

HTH, -FT

于 2009-09-23T17:05:53.370 回答
0

是的,我得到了答案。

有一种方法可以从文件夹的给定源文件中提取所有字符串。这是您可以检查的链接:

  • 从源代码中提取字符串以进行翻译(用于 po 文件) [链接现已失效]

  • Poedit:一个跨平台的 PO 到 MO 转换器和 PO 文件编辑器[链接现已失效]

于 2009-09-29T19:08:57.300 回答