开发者

Django i18n: Specifying context. (msgctxt)

开发者 https://www.devze.com 2023-04-11 02:01 出处:网络
This page, about gettext generally, mentions the ability t开发者_如何学Goo specify a context for a string marked for translation. (http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files)This

This page, about gettext generally, mentions the ability t开发者_如何学Goo specify a context for a string marked for translation. (http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files) This helps when you have two instances of the same string in an application that have different meanings (e.g. "back" in one instance may mean "go back" while in another it may mean "not the front" -- it's possible that these are two different words in a foreign language)

Does Django's i18n allow you to specify a context?


Yes since version 1.3 Django supports "Contextual Markers". See eg. this example from the documentation:

 from django.utils.translation import pgettext

 month = pgettext("month name", "May")
0

精彩评论

暂无评论...
验证码 换一张
取 消