开发者

How do you escape a dollar sign in gettext .po file?

开发者 https://www.devze.com 2023-01-29 23:34 出处:网络
This is the first question I\'ve asked here, so please be kind... In my PO file, I have a localized string that contains a dollar sign. I have not been able to escape the dollar sign (to avoid gettex

This is the first question I've asked here, so please be kind...

In my PO file, I have a localized string that contains a dollar sign. I have not been able to escape the dollar sign (to avoid gettext's attempt at dollar-substitution) with the desired results. An example PO entry to clarify what I'm trying to do:

msgid "myStringId"

msgstr "My string that contains a $ sign"

gettext throws up on the $ in the msgtr. I've tried escaping using the following approaches:

msgstr "My string that contains a \$ sign"

msgstr "My string that contains a $$ sign"

msgstr "My string that contains a '$' sign"

...without success. The third approach (single quotes) gets the closest, but returns the dollar sign and the single quotes.

returned => My string that contains a '$' sign

desired => My开发者_StackOverflow中文版 string that contains a $ sign

My question again: How do you escape dollar signs in gettext PO entries?

Thanks in advance.


I haven't tried, but how about using C's octal escaping \044 or the unicode one \u0024?


I found out that I could just replace my $ with its HTML entity code. https://stackoverflow.com/a/10225521/470749 For $5, I now write $5

0

精彩评论

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