Printing \" with gettext

2019-05-07 12:04发布

问题:

I want to output the translation of this string

By clicking on "Post"

Using gettext, how do I escape the quotation mark? Should I try \ "?

msgid "By clicking on"
msgstr ""

回答1:

Yes, you need to escape double quotes with a backslash (\").

The gettext manual says the following:

The two strings, untranslated and translated, are quoted in various ways in the PO file, using " delimiters and \ escapes

...

Each of untranslated-string and translated-string respects the C syntax for a character string, including the surrounding quotes and embedded backslashed escape sequences.