Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set language according to HTTP_REFERER for links from OCDS documentation #178

Open
ghost opened this issue Sep 24, 2020 · 3 comments
Open

Comments

@ghost
Copy link

ghost commented Sep 24, 2020

(Found when doing open-contracting/deploy#53)

@ghost
Copy link
Author

ghost commented Sep 25, 2020

Suggestions:

There is a global "language" variable in Sphinx. https://www.sphinx-doc.org/en/master/templating.html#global-variables Oddly, it comes out as None for English, but the others are fine - "es", "fr" and "it"

We can use this to edit the template in the standard and attach a language code to the link to the review tool. We can use a if statement to look for English and put in en. https://github.com/open-contracting/standard/blob/1.1-dev/docs/_templates/layout.html#L25 and https://github.com/open-contracting/infrastructure/blob/0.9-dev/docs/_templates/layout.html#L15

Then it's just a case of making something in Cove/Django that responds to that:

Note: The main standard site has more languages then Cove has (ie; fr, it) - have to test that Django will use a suitable fallback in this case.

However, this involves changing the standard site which is of course versioned.

So another route may be to ignore all this:

Links should have a HTTP_REFERER set. In Django index view, look for a referrer, take it apart to get the languge, set the Django language in Python. No changes to Standard required now, no changes to standard required if we add or remove a language to a Cove later.

@jpmckinney
Copy link
Member

The link can also be changed with JavaScript to send a POST request to the language redirect view, setting language to 'en' or 'es' and next to the /review/ URL.

Alternately, we can directly set the cookie, but that seems more tightly coupled, since it's not expected to change another app's cookies (whereas it's expected to request another app's URLs).

@jpmckinney jpmckinney changed the title Linking from Spanish docs to CoVE takes you to English Cove docs: Spanish site should link to Spanish Data Review Tool Apr 9, 2021
@jpmckinney
Copy link
Member

jpmckinney commented Mar 1, 2023

Noting that since the URL is in the translated string (and not passed to e.g. blocktranslate as a variable), it's easy to hand-code different links for different languages via gettext/Transifex. This avoids needing to have consistent language codes across Sphinx and CoVE, and to have logic about which languages are available in CoVE.

The review tools are now on sub-domains of standard.open-contracting.org. It's still possible to set shared cookies - with the same caveats as above.

I prefer the HTTP_REFERER solution (essentially treating the OCDS documentation as a special case), in which case this issue can be transferred to cove-ocds.

@jpmckinney jpmckinney transferred this issue from open-contracting/deploy Mar 1, 2023
@jpmckinney jpmckinney changed the title docs: Spanish site should link to Spanish Data Review Tool Set language according to HTTP_REFERER for links from OCDS documentation Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant