Search code examples
pythongettextpo-file

How to have no-break spaces in translatable strings


We have a Pyramid application which we must have in English, Spanish and French. We have completed our first pass of i18n, however we are troubled about how to introduce no-break spaces in our translate strings.

For instance we have the following:

USER_UPDATED = _('User "${user}" updated!')

When translating to French, this must be changed to:

Utilisateur « ${user} » mise à jour !

But the space after the « and the ones before the » and the ! must be non-breaking.

When editing the PO file, how do I put the no-break space where it should be? I use Emacs PO mode, and I haven't found a way to do this.


Solution

  • Use the HTML entity   or the Unicode character 160 (0xA0), same as in any other situation where you need a non-breaking space on a Web page. You may be able to enter the Unicode character directly using your editor, but frankly I'd advise using the HTML entity because it's clearer. You could also escape the character using the Python syntax \u00a0 if the HTML entity is not appropriate.