Sphinx, gettext and html : how can I create multiline translations?

The documentation of my project (using Python 3.2) is created with Sphinx (1.1.3) and is made of HTML files. I have to write this documentation in English and in French; that's the reason why I build my documentation with Sphinx and gettext, using the usual bunch of .po(t) and .mo files.

By example, my .po files are made of lines like this one :

msgid "original text"
msgstr "translation"

My problem lies in the fact that if some translations are made of several lines, the corresponding HTML file loses the "new line" characters : my different lines are packed into one big paragraph. I tried different things, like :

msgid "original text"
msgstr "translation : first line \n second line"

But of course the HTML doesn't care about the \n character; same problem with the \r character.

Then I tried this :

msgid "original text"
msgstr "translation : first line <br> second line"

But all I get is something like &lt;br&gt; instead of the expected "line break". Same thing with <br/>.

What can I do ? I would be nice to help me !


Well, thank's to ms4py, I'm able to answer my own question :

  • add the following line in each .rst file if you use "new line" characters in this file :

    .. |br| raw:: html

Then add an empty line, then add on a new line the following characters : "less than" and br />. Then a new empty line.

  • use the following characters in each translations in order to have a break line : |br| with spaces before and after |br|.

Thank you !

Need Your Help

Using Rails 3 Sprockets at runtime

ruby-on-rails runtime sprockets

I have a Rails 3 application that needs to display images from another application. Those images change over time, so I have a task that runs hourly to check for changes. For performance reasons, I...