多个"msgid"对于"msgstr"在gettext中 [英] Multiple "msgid" for an "msgstr" in gettext
问题描述
是否可以使两个或多个匹配一个 msgstr 的 msgids ?
Is it possible to make two or more msgids matching one msgstr?
例如, ('list.empty')和 ('list.null')均返回"There is no any objects yet."
For example, both ('list.empty') and ('list.null') return "There is no any objects yet."
如果我在po文件中这样写:
msgid "list.empty"
msgid "list.null"
msgstr "There is no any objects yet."
缺少'msgstr'"只是错误:
但是
msgid "list.empty"
msgstr "There is no any objects yet."
msgid "list.null"
msgstr "There is no any objects yet."
看起来工作正常,但很愚蠢,因为一旦我更改了一个msgstr而没有另一个,它们将返回不同的结果.
Looks and works fine but stupid, because once I change one msgstr without another, they return different result.
任何人都有更好的技巧吗?
Does anyone have any better hacks?
推荐答案
您以错误的方式接近gettext
,这是它的工作方式:
You are approaching gettext
in the wrong way, here is how it works:
-
每个条目都需要
-
msgid
-
msgctxt
是可选的,用于区分内容相同但翻译可能不同的两个msgid
记录. -
(msgid, msgctxt)
是字典的唯一键,如果缺少msgctxt
,则可以将其视为null
.
msgid
is required for each entrymsgctxt
is optional and is used to differentiate between twomsgid
records with same content that may have different translations.(msgid, msgctxt)
is the unique key for the dictionary, ifmsgctxt
is missing you can consider itnull
.
在实施之前,您应该阅读 gettext文档因为并不总是那么简单.
You should read the gettext documentation before implementing as it's not always straightforward.
在您的情况下,这是您应该如何实施的方法:
In your case, this is how you are supposed to implement it:
msgctxt "list.empty"
msgid "There is no any objects yet."
msgctxt "list.null"
msgid "There is no any objects yet."
这篇关于多个"msgid"对于"msgstr"在gettext中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!