0

I would like to be able to translate only part of a page to another language using sphinx and sphinx-intl. For example, when some content relevant in the native language but not useful in another language.

The current default with sphinx is to then simply display the untranslated content: I would like these messages to be not displayed at all if I tag them as such (e.g.: "ignore" or similar). An example PO file would look like:

#: ../../myfile.rst:26
msgid "Important content"
msgstr "Contenu important"


#: ../../myfile.rst:28
#, ignore
msgid "Content which is only relevant in english"
msgstr "<doNotDisplayThisinFrench>"
Fabzi
  • 626
  • 5
  • 15
  • Would the use of [`ifconfig`](https://www.sphinx-doc.org/en/master/usage/extensions/ifconfig.html) do what you want? – Steve Piercy Jun 09 '20 at 20:51
  • Thanks @StevePiercy! ifconfig *might* help to get what I want, but it's a pretty convoluted solution. On top of the boilerplate it would add, this would have to be in the native document which creates problems: e.g. the English doc writer would have to decide that this part of the doc is only relevant in English and not in all other languages. I'd much rather have the translator decide: "nah I won't translate that it doesn't make sense in my context". – Fabzi Jun 10 '20 at 09:14
  • I am pretty sure that translation files themselves do not support any kind of logic. They merely define what gets substituted, not _how_ to do substitutions. With that, you could do a substitution with an empty string or remove its item from the translation file. – Steve Piercy Jun 10 '20 at 22:01
  • Thanks @StevePiercy - I have gone for the ifconfig option for now. An empty string or remove the item from the translation file would have been the most logical and evident for me, but unfortunately in these cases sphinx simply uses the native language text instead, which is why I asked the question in the first place: can we prevent this automatic behavior or using the native language when no translation is provided? – Fabzi Jun 11 '20 at 08:20

0 Answers0