如何合并 2 个 .POT 文件(翻译文件) [英] How can I merge 2 .POT files (translation files)

查看:13
本文介绍了如何合并 2 个 .POT 文件(翻译文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下情况:

我要翻译的一个产品有两个独立的网站,一个用于管理员,一个用于客户.
代码库是 CakePHP.
这两个站点是完全独立的,它们是完整的 CakePHP 站点.
他们都有很多共同的字符串.

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.

所以,我使用 CakePHP 为每个站点生成 .pot 文件,但我想给翻译者一个文件,两个 .pot 文件中都有唯一的字符串.

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.

他们会给我一个 .po 文件,其中包含两个站点的字符串,我只需将同一个文件复制到两个站点,因此我将获得包含额外字符串的 .po 文件,代码不会使用这些字符串,但这应该不是问题.

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.

所以问题本质上是......如何合并两个 .pot 文件?

So the question essentially is... How can I merge two .pot files?

  • 我需要获取一个没有重复字符串的新文件.
  • 理想情况下,它会保留(对于重复的字符串,追加)CakePHP 添加的每个字符串之前的注释,指定找到字符串的位置,但如果不这样做,那也没关系,我可以不用它.(请参阅下面的 .pot 文件的摘录以对此进行说明)

你知道有什么工具可以让我这样做吗?我真的很想避免自己写.

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:

#: controllersaccounts_controller.php:118
#: controllerscustomer_documents_controller.php:75
msgid "Parent Customer not specified"
msgstr ""

推荐答案

好的,所以执行此操作的工具是 msgcat

Ok, so the tool to do this is msgcat

msgcat *.pot > all.pot

如果您使用的是 Windows,请安装 cygwin,并确保您拥有 gettext-devel 包,因为 msgcat 不在常规 gettext包.

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.

这篇关于如何合并 2 个 .POT 文件(翻译文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆