sphinxext-opengraph icon indicating copy to clipboard operation
sphinxext-opengraph copied to clipboard

Locales

Open ItayZiv opened this issue 5 years ago • 6 comments

Not sure if this is possible, but if it is, then adding support for and changing the og:locale based on the translated version of the documentation would be nice if possible. Additional adding support for og:locale and og:locale:alternate would be useful anyways for non-English documentation and documentation who has non-English translations.

ItayZiv avatar Jul 07 '20 11:07 ItayZiv

app.config.language returns the language when it is explicitly defined (in conf.py or cli). It defaults to "".

I don't know if og:locale:alternate is that useful. From a quick google search, it seems that only Facebook uses it. Even then, Facebook makes extra requests to the server with the parameter fb_locale and expects a response that RTD does not support afaik.

It may be more useful to provide links to alternate languages in the form:

<link rel="alternate" hreflang="en" href="https://docs.wpilib.org/en/latest/" />
<link rel="alternate" hreflang="fr" href="https://docs.wpilib.org/fr/latest/" />

^ This is what Google Search uses to differentiate between languages: https://support.google.com/webmasters/answer/189077

TheTripleV avatar Jul 12 '20 01:07 TheTripleV

That's something that we might be able to insert in extra tags on the per lang build, but not something that should be done in the extension. The language as configured by sphinx isn't the same format as defined by opengraph, it's be something you need to specify in conf.py per each lang build

ItayZiv avatar Jul 25 '20 23:07 ItayZiv

We should be able to take advantage of READTHEDOCS_LANGUAGE for this

Daltz333 avatar Jul 25 '20 23:07 Daltz333

It’s not the correct format that ogp expects, it wants language_TERRITORY. Unless your talking about the link for google that was mentioned. Idk if that’s in scope for this being not very ogp? idk

ItayZiv avatar Jul 26 '20 10:07 ItayZiv

It does indeed what language territory. However are locale codes can be used to lookup language territory.

Daltz333 avatar Jul 26 '20 10:07 Daltz333

I added support for this (the non-og meta version) directly into frc-docs a while ago. https://github.com/wpilibsuite/frc-docs/blob/main/source/_extensions/localization.py It can be upstreamed to this repo.

TheTripleV avatar Sep 13 '22 08:09 TheTripleV