如何合并 2 个 .POT 文件(翻译文件)
我遇到以下情况:
我想要翻译一种产品,该产品有两个独立的网站,一个用于管理员,一个用于客户。
代码库是 CakePHP。
两个站点彼此完全独立,它们是完整的 CakePHP 站点。
它们都有很多共同点。
因此,我使用 CakePHP 为每个站点生成 .pot 文件,但我很乐意为翻译人员提供一个文件,其中两个 .pot 文件中都有唯一的字符串。
他们会给我一个包含两个站点的字符串的 .po 文件,我只需将相同的文件复制到两个站点,因此我将拥有包含代码不会使用的额外字符串的 .po 文件,但是应该不是问题。
所以问题本质上是...如何合并两个 .pot 文件?
- 我需要获取一个没有重复字符串的新文件。
- 理想情况下,它会在 CakePHP 添加的每个字符串之前保留(对于重复的字符串,附加)注释,指定找到该字符串的位置,但如果没有这样做,那也没关系,没有它我也可以生活。 (请参阅下面的 .pot 文件摘录以了解对此的说明)
您知道有什么工具可以让我执行此操作吗?我真的很想避免自己编写。
这些是我上面谈论的评论:
#: \controllers\accounts_controller.php:118
#: \controllers\customer_documents_controller.php:75
msgid "Parent Customer not specified"
msgstr ""
I have the following situation:
One product which I want to translate, that has two separate websites, one for admins, one for customers.
The codebase is CakePHP.
Both sites are completely separate from each other, they are complete CakePHP sites.
And they both have A LOT of strings in common.
So, with CakePHP I generate the .pot files for each site, but I'd love to give translators ONE file, with the unique strings in both .pot files.
They'd give me back one .po file with the strings for both sites, and I'll just copy the same file to both sites, so I'll have .po files with extra strings that the code will not use, but that shouldn't be a problem.
So the question essentially is... How can I merge two .pot files?
- I need to get a new file that has no duplicate strings.
- Ideally, it'll keep (and for duplicate strings, append) the comments before each string that CakePHP adds, specifying where the string was found, but if this is not done, that's fine, I can live without it. (see below for an excerpt of the .pot file for a clarification on this)
Do you know of any tools that'd let me do this? I'd really like to avoid having to write my own.
These are the comments I'm talking about above:
#: \controllers\accounts_controller.php:118
#: \controllers\customer_documents_controller.php:75
msgid "Parent Customer not specified"
msgstr ""
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好的,执行此操作的工具是 msgcat
如果您使用的是 Windows,请安装 cygwin,并确保您拥有 gettext-devel 包,因为 msgcat 不在常规 gettext 包。
Ok, so the tool to do this is msgcat
If you're on Windows, install cygwin, and make sure you have the gettext-devel package, because msgcat is not in the regular gettext package.
msgcat 不应该是正确的答案,msgcat 适用于 .po 文件,但它不适用于 .pot 文件,因为文档如下:
正确的是:
xgettext input/*.pot -o out.pot
msgcat should not be the right answer, msgcat is good for .po file but it won't work well on .pot file due to document that:
The right one is:
xgettext input/*.pot -o out.pot
将两个 .pot 文件合并为一个:
Merge two .pot files into one:
命令是:
the command is: