-
Notifications
You must be signed in to change notification settings - Fork 19
Accept language #109
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
Accept language #109
Conversation
This adds support for using the Accept-Language header to Fastly config for the currently known locales. Unfortunately needs to be edited every time locales change.
... to make intentions clearer.
The one outstanding issue I see is that we currently have is that Babel uses CLDR language tags and Accept-Language uses IANA language tags... which use different casing and locale differentiators ( So I think our |
@di here is a Fastly Fiddle that shows how things work: https://fiddle.fastly.dev/fiddle/3506e1d7#req-8aa50147 |
@webknjaz this is now live on https://test.pypi.org for validation. I'm going to be poking at it to make sure all is well for a bit before making live on pypi.org |
With support for Accept-Language header from pypi/infra#109 we need to add a step so our VCL knows about the new locale.
With support for Accept-Language header from pypi/infra#109 we need to add a step so our VCL knows about the new locale.
Active now for https://pypi.org |
Sorry, I forgot to report back. This seems to work correctly on the HTTP level, per my testing: $ curl -ssvH 'Accept-Language: uk,en' https://pypi.org 2>&1 | head -c 5500 | grep -i lang
* h2h3 [accept-language: uk,en]
> accept-language: uk,en
<html lang="uk" dir="ltr">
<meta name="defaultLanguage" content="en">
<meta name="availableLanguages" content="en, es, fr, ja, pt_BR, uk, el, de, zh_Hans, zh_Hant, ru, he, eo">
$ curl -ssvH 'Accept-Language: en,uk,en' https://pypi.org 2>&1 | head -c 5500 | grep -i lang
* h2h3 [accept-language: en,uk,en]
> accept-language: en,uk,en
<html lang="en" dir="ltr">
<meta name="defaultLanguage" content="en">
<meta name="availableLanguages" content="en, es, fr, ja, pt_BR, uk, el, de, zh_Hans, zh_Hant, ru, he, eo">
<meta name="description" content="The Python Package Index (PyPI) is a repository of software for the Python programming language.">
$ curl -ssvH 'Accept-Language: weird,en,uk,en' https://pypi.org 2>&1 | head -c 5500 | grep -i lang
* h2h3 [accept-language: weird,en,uk,en]
> accept-language: weird,en,uk,en
<html lang="en" dir="ltr">
<meta name="defaultLanguage" content="en">
<meta name="availableLanguages" content="en, es, fr, ja, pt_BR, uk, el, de, zh_Hans, zh_Hant, ru, he, eo">
<meta name="description" content="The Python Package Index (PyPI) is a repository of software for the Python programming language.">
$ curl -ssvH 'Accept-Language: weird,uk,en' https://pypi.org 2>&1 | head -c 5500 | grep -i lang
* h2h3 [accept-language: weird,uk,en]
> accept-language: weird,uk,en
<html lang="uk" dir="ltr">
<meta name="defaultLanguage" content="en">
<meta name="availableLanguages" content="en, es, fr, ja, pt_BR, uk, el, de, zh_Hans, zh_Hant, ru, he, eo">
$ curl -ssvH 'Accept-Language: weird,BR,uk-UA,en' https://pypi.org 2>&1 | head -c 5500 | grep -i lang
* h2h3 [accept-language: weird,BR,uk-UA,en]
> accept-language: weird,BR,uk-UA,en
<html lang="uk" dir="ltr">
<meta name="defaultLanguage" content="en">
<meta name="availableLanguages" content="en, es, fr, ja, pt_BR, uk, el, de, zh_Hans, zh_Hant, ru, he, eo">
$ curl -ssvH 'Accept-Language: weird,pt-BR,uk-UA,en' https://pypi.org 2>&1 | head -c 5500 | grep -i lang
* h2h3 [accept-language: weird,pt-BR,uk-UA,en]
> accept-language: weird,pt-BR,uk-UA,en
<html lang="pt_BR" dir="ltr">
<meta name="defaultLanguage" content="en">
<meta name="availableLanguages" content="en, es, fr, ja, pt_BR, uk, el, de, zh_Hans, zh_Hant, ru, he, eo">
$ curl -ssvH 'Accept-Language: weird,pt,pt-BR,uk-UA,en' https://pypi.org 2>&1 | head -c 5500 | grep -i lang
* h2h3 [accept-language: weird,pt,pt-BR,uk-UA,en]
> accept-language: weird,pt,pt-BR,uk-UA,en
<html lang="pt_BR" dir="ltr">
<meta name="defaultLanguage" content="en">
<meta name="availableLanguages" content="en, es, fr, ja, pt_BR, uk, el, de, zh_Hans, zh_Hant, ru, he, eo">
# rtl test:
$ curl -ssvH 'Accept-Language: weird,he,pt,pt-BR,uk-UA,en' https://pypi.org 2>&1 | head -c 5500 | grep -i lang
* h2h3 [accept-language: weird,he,pt,pt-BR,uk-UA,en]
> accept-language: weird,he,pt,pt-BR,uk-UA,en
<html lang="he" dir="rtl">
<meta name="defaultLanguage" content="en">
<meta name="availableLanguages" content="en, es, fr, ja, pt_BR, uk, el, de, zh_Hans, zh_Hant, ru, he, eo"> |
superseedes #53