使用 gettext 翻译 php 应用程序
从我之前关于 gettext 的问题来看,使用 PHP 的 gettext 扩展而不是其他语言翻译方法的最大好处之一是,让其他人使用名为 Poedit 的程序制作翻译文件非常容易。
现在我已经在我的应用程序中使用了 gettext,但我还没有制作任何翻译文件,我在网上找到了一个演示文件并对其进行了测试,以确保我的应用程序可以与 gettext 兼容。
现在我稍微玩了一下poedit,我可能是错的,希望有人能澄清一些问题。
据我所知,poedit 会读取您的 php 代码并找到所有可用的位置进行翻译,这是正确的吗?
据如果上述内容正确,那么如何让人工翻译人员在无法访问您的应用程序的情况下使用 poedit 进行翻译?
如果上述内容正确,
或者简单来说,是否可以使用 poedit 制作翻译文件,而无需访问您的 php 代码?
From my previous questions about gettext, one of the biggest benefits of using PHP's gettext extension instead of other methods of language translation was that it is super easy to have other people make translation files with a program called Poedit.
Now I have gettext working in my app but I have not made any translation files yet, I found a demo file on the net and tested with it to conform my app works with gettext though.
Now I played around with poedit a little bit and I might be wrong, hopefully someone can clarify some issues.
As far as I can tell poedit reads through your php code and finds all availabale spots to do a translation, is this correct?
If the above is correct, then how do you have a human translator translate with poedit without having access to your app?
Or in simple terms is it possible to make a translation file with poedit without it having access to your php code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请注意,我自己从未使用过 poedit,因此这可能不完全准确...
您可能会首先阅读一篇有趣的文章,以获取一些信息:使用 poEdit 本地化 WordPress 插件。它是 WordPress,意思是 PHP——所以基本思想应该适合您的应用程序。
基本上:
另一篇关于 WordPress 的文章似乎表明我猜对了: User:Skippy/创建 POT 文件——尤其是这句话:
(显然,您将在应用程序中使用的函数名称将与 WordPress 中的函数名称不同 - 不过,这个想法是存在的)。
Note that I have never used poedit myself, so this might not be totally accurate...
An interesting article that you might first read, for some information : Localizing a WordPress Plugin Using poEdit. It's WordPress, which means PHP -- so the basic ideas should be OK for your application.
Basically:
This other article, about WordPress too, seems to indicate that I'm guessing right : User:Skippy/Creating POT Files -- especially, this sentence :
(Obviously, the function name you'll be using in your application will not be the same as the one in WordPress -- still, the idea is there).
不,poEdit 不会读取您的所有来源。您可以使用 gettext 实用程序“xgettext”来执行此操作。
基本上,xgettext 将生成一个 .po 文件。
您的翻译人员将使用 POEdit 来处理该 .po 文件。
翻译器完成后,您会将 .po 编译为 .mo,您的应用程序将使用它来查找翻译。
如果你在某些unixy系统上安装了gettext,请尝试在bash中使用“info gettext”。
No, poEdit doesn't read all your sources. You use the gettext utility "xgettext" to do that.
Basically, xgettext will produce a .po file.
Your translators will use POEdit to work on that .po file.
When the translater is done, you'll compile the .po into an .mo, which you app will use to look up translations.
If you have gettext installed on some unixy system, try "info gettext" in bash.
PoEdit 实际上使用
xgettext
,您可以在 Settings/Parsers 选项卡上正确设置。顺便说一句,您应该分发一个 .pot 文件,它是一个 .po 模板。所以译者可以翻译它,设置语言,翻译团队等。
不幸的是,我看不到从源代码创建 .pot 文件的选项,但
poedit
可以读取(当然,这是一样的)作为.po)。创建自己的.po后,就可以拥有.mo了!
PoEdit actually uses
xgettext
, which you can set up on the Settings/Parsers tab correctly.You should distribute a .pot file by the way, which is a .po template. So translators can translate it, set the language, the translator team, etc.
Unfortunately, I cannot see an option to create .pot file from source, but
poedit
can read then (of course, it's the same as .po).After creating their own .po, you can have the .mo!