mozmeao / infra

Mozilla Marketing Engineering and Operations Infrastructure
https://mozilla.github.io/meao/
Mozilla Public License 2.0
59 stars 12 forks source link

Research Pocket pages Localization #1366

Closed glogiotatidis closed 3 years ago

glogiotatidis commented 3 years ago

Also:

glogiotatidis commented 3 years ago

Netlify supports redirects based on Country or Locale. https://docs.netlify.com/routing/redirects/redirect-options/#redirect-by-country-or-language

hoosteeno commented 3 years ago

We are blocked on this waiting for Pocket to get back to us on how l10n happens.

glogiotatidis commented 3 years ago

Quoting Mark's very detailed reply:

Locale identification works by using Express' req.acceptsLanguages() Method to read the request's Accept-Language header and compare this list against a list of supported languages. The default language is English (en) if there are no matches between supported and accepted languages. Here is where you can find the files that are controlling this:

Detecting languages middleware Handling the language matching and redirect middleware Setting the language after redirect middleware List of routes that are localized Supported languages list

One thing to note here is that the Pocket Hits Signup page was built before the web-discover repo had proper localization setup. So, it uses a custom Middleware that appends a custom header to assist the page in determining the correct language to display. There are only two languages supported for this page (en and de-DE). You can find relevant files to this here:

Appending "x-pocket-lang" custom header middleware Single route using this method Where the this header is read Supported languages list

hoosteeno commented 3 years ago

@glogiotatidis what's next here?

glogiotatidis commented 3 years ago