-
Notifications
You must be signed in to change notification settings - Fork 2
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
Comments
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. |
The link can also be changed with JavaScript to send a POST request to the language redirect view, setting 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). |
Noting that since the URL is in the translated string (and not passed to e.g. The review tools are now on sub-domains of 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. |
(Found when doing open-contracting/deploy#53)
The text was updated successfully, but these errors were encountered: