多个"msgid"对于"msgstr"在gettext中 [英] Multiple "msgid" for an "msgstr" in gettext

查看:208
本文介绍了多个"msgid"对于"msgstr"在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 entry
  • msgctxt is optional and is used to differentiate between two msgid records with same content that may have different translations.
  • (msgid, msgctxt) is the unique key for the dictionary, if msgctxt is missing you can consider it null.

在实施之前,您应该阅读 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屋!

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