I notice that some people have tried to view my Sphinx-generated docs
through Google Translate. Looking at the translation from Engligh to
my own native language (Swedish), the text is actually quite readable
(except for the usual quirks like "generators" being translated to
"spisar" (stoves :)), so I think this could be useful for some people,
even to the point that I'd consider linking to machine-translated
versions on the website.
The catch is that Google Translate tries to translate all content in
Python code examples, and this breaks the code completely. So the
question is whether there is some kind of HTML or CSS directive that
can be used to tell Google Translate to skip the code examples? If so,
I think this would be a useful enhancement to Sphinx. Otherwise, I
might try to contact the Google Translate team to suggest such a
feature.
Fredrik
That's a nice idea!
> The catch is that Google Translate tries to translate all content in
> Python code examples, and this breaks the code completely. So the
> question is whether there is some kind of HTML or CSS directive that
> can be used to tell Google Translate to skip the code examples? If so,
> I think this would be a useful enhancement to Sphinx. Otherwise, I
> might try to contact the Google Translate team to suggest such a
> feature.
I don't know if Google Translate has such a feature. (IMO it should
certainly exclude e.g. <pre> tags by default.)
If you can find out whether there's some custom attribute or CSS
property that can be set to disable translation, I'll certainly
add a Sphinx setting to output these.
cheers,
Georg
Why? The fact that programmers use it to render code is
circumstantial; there's nothing about an implied language change in
the HTML specification.
> If you can find out whether there's some custom attribute or CSS
> property that can be set to disable translation, I'll certainly
> add a Sphinx setting to output these.
I tried to see if there's a language code that means "not a
known/translatable language", but couldn't find anything. I suspect
using something like "x-code" (or a more specific "x-python" if a more
specific language is known) might do the trick if Google Translate
handles unknown language codes reasonably.
Ideally, there'd be a way to say "not translatable", I don't know if
lang="" would suffice or not.
-Fred
--
Fred L. Drake, Jr. <fdrake at gmail.com>
"Chaos is the score upon which reality is written." --Henry Miller
If you prefer not have your page translated by Google Translate, just insert the following meta tag into your HTML file:
<meta name="google" value="notranslate">
Cheers,The problem, though, is that we want to be able to affect translation
for *part* of a page (the examples); the rest of the text should still
be translated. (Inline function, method, and class names shouldn't be
translated either.)
Okay, I will experiment with different "lang" settings and see if it makes
a difference.
Georg
I have now tried several "lang" attributes for pre tags, and it does not
seem like Google Translate takes these as a hint whether to translate
or not.
I guess it will be best if you contact the Translate team about that.
cheers,
Georg