【发布时间】:2019-01-28 16:22:48
【问题描述】:
对于 POedit 中带有“%”符号的字符串,我遇到了一些不同的错误。
第一:
a format specification for argument 1 doesn't exist in 'msgstr'
第二:
msgstr is not a valid PHP string, unlike 'msgid'. Reason: In the directive number 1, the character 'a' is not a valid conversion specifier.
在这种情况下,'a' 是 '%' 符号后面的字母。 (例如,“100% 不锈钢”变为“100% 更耐氧化”)
为了尝试解决这个问题,我已经尝试过:
1) 将以下行添加到 .po 文件头:
"Content-Type: text/plain; charset=UTF-8\n"
"X-Poedit-SourceCharset: UTF-8\n"
2) 根据How can I escape '%' character in a gettext string?,在翻译字符串中使用 %% 代替 '%'
3) 使用 & #37 ;而不是翻译字符串中的“%”。
4) 在翻译字符串中使用 'percent' 而不是 '%'。
是我遗漏了什么还是应该替换源文本中的所有“%”实例?
编辑
所以我试着弄乱我的源文本。
我在源代码中将 '%' 替换为 '%%' 并且能够放入 '& #37;'进入翻译和验证的 .po 文件。
但是....它不起作用,我的英文版现在只有 '%%' 在前端,它不会翻译成任何语言。
注意
'%'它实际上没有空格,如果我不把它们放在那里它只会显示为 % 所以我不能显示一个例子。
【问题讨论】:
标签: php html gettext html-entities poedit