microCOVID / microCOVID

Estimating the COVID risk of ordinary activities
https://www.microCOVID.org
MIT License
269 stars 55 forks source link

Move language code to subdomain #486

Open blanchardjeremy opened 4 years ago

blanchardjeremy commented 4 years ago

I'm pretty sure we don't have automatic language detection. @gyp can you confirm?

See options here: https://www.i18next.com/overview/plugins-and-utils#language-detector

UPDATE: This issue has evolved into "we should put the language code in the subdomain so it doesn't get lost when people are sharing URLs."

gyp commented 4 years ago

We do, we use https://github.com/i18next/i18next-browser-languageDetector with the default settings, which are pretty sane. (see https://github.com/microcovid/microcovid/blob/60a7f63d2a44dc0486bd6a46bc9ebfe88b5d00d4/src/i18n.tsx#L2 and https://github.com/microcovid/microcovid/blob/60a7f63d2a44dc0486bd6a46bc9ebfe88b5d00d4/src/i18n.tsx#L9)

The language selector dropdown actually makes use of this by redirecting the user to /?lng=LANGUAGE, and subsequent page loads will make use of the information stored in the URL. If nothing's set, it will fall back to the browser preference order set in navigator.language.

I think the only improvement that might be useful here would be to set up a wildcard DNS record for *.microcovid.org so that one can link to hu.microcovid.org, es.microcovid.org, de.microcovid.org etc. or maybe set up routing in React so that microcovid.org/hu works, too.

blanchardjeremy commented 4 years ago

Got it. Thanks. What's the benefit of having language in subdomain vs a URL param? Less likely to get dropped, I suppose?

We also have an issue where the URL params overwrite the language code. So you can't share a link that includes the language.

gyp commented 4 years ago

It's less likely to get dropped indeed, and it's much easier to remember and to type in manually so it increases accessibility and helps sharing in the offline space, either verbally or by including the link on posters and similar interfaces.

blanchardjeremy commented 4 years ago

@dominic did you set up our servers? Or @beshaya or @oremanj ? I wonder what it would take to add wildcard subdomains?

beshaya commented 4 years ago

Dom did. I have access to the console but can't add you.

We use netlify, so you can poke around their documentation to see what they offer.

https://docs.netlify.com/routing/redirects/#syntax-for-the-redirects-file looks promising.

On Mon, Nov 9, 2020 at 9:13 AM Jeremy Blanchard notifications@github.com wrote:

@dominic https://github.com/dominic did you set up our servers? Or @beshaya https://github.com/beshaya or @oremanj https://github.com/oremanj ? I wonder what it would take to add wildcard subdomains?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/microcovid/microcovid/issues/486#issuecomment-724150208, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABM25LP5PUW322J6FYI5MGDSPAPMJANCNFSM4TOPAYJA .