Gettext自动生成注释 [英] Gettext automatic comments generation
问题描述
我使用gettext为一个php项目做i18n。我想使用自动评论功能向翻译者提供提示翻译由短语替换的长短语。我想获得的是以下po文件
#:full-path-to-file / index.phtml:3
#。一个很长的文本应该替换为_('foobar')
msgidfoobar
msgstr
这样,当他在程序员注释框中使用POEdit或一些模拟工具看到键 foobar
时,翻译人员可以看到他应该翻译什么。
我尝试过此代码,但无效
<?php
/// TRANSLATORS:一个很长的文本,应该替换为_('foobar')
_('foobar');
?>
我缺少某些内容或自动注释不适用于php?
即使维基百科提及此功能,我已尝试复制其示例一个C文件,但我不能得到它工作即使与C.我使用的命令行是
xgettext -C - o - main.c
但生成的输出是
#:main.c:16
#,c-format
msgid我的名字是%s.\\\
msgstr
所以我绝对缺少一些东西,应该使用任何 ' 在输出文件中放置以 将 I'm doing i18n for a php project using gettext. I'd like to use the automatic comment feature to give hints to translators when translating long phrases replaced by id. What I want to obtain is the following po file In this way the translator can see what he should translate when he see the key I've tried with this code but it doesn't work Am I missing something or automatic comments just don't work for php? Even Wikipedia mentions this feature, I've tried to copy their example in a C file, but I cannot get it working even with C. The command line I've used is But the generated output is So I'm definitely missing something, should I use any To make From the documentation: ‘ Place comment blocks starting with
tag and preceding keyword lines in the output file. Without a tag, the
option means to put all comment blocks preceding keyword lines in the
output file. Passing 这篇关于Gettext自动生成注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! xgettext $
xgettext
< blockquote>
-c [tag]
'
' - add-comments [=标签]
'
标记和前面的关键字行开头的注释块。没有标记,
选项意味着将所有注释块放在
输出文件中的关键字行之前。
-c /
或 - add-comments = /
作为参数传递将使其识别 格式。#: full-path-to-file/index.phtml:3
#. a very long text which should replaced by _('foobar')
msgid "foobar"
msgstr ""
foobar
using POEdit or some analogue tool in the programmer comment box.<?php
/// TRANSLATORS: a very long text which should replaced by _('foobar')
_('foobar');
?>
xgettext -C -o - main.c
#: main.c:16
#, c-format
msgid "My name is %s.\n"
msgstr ""
xgettext
flag or particular version to enable this feature.xgettext
extract comments from your source, you need to pass an argument to tell it what comments to look for.
-c[tag]
’
‘--add-comments[=tag]
’-c/
or --add-comments=/
as an argument will make it recognize the "triple slash" format.