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

Localisation #491

Open
jakearchibald opened this issue Aug 2, 2019 · 3 comments
Open

Localisation #491

jakearchibald opened this issue Aug 2, 2019 · 3 comments
Assignees

Comments

@jakearchibald
Copy link
Contributor

The plan is to use Accept-Language + Netlify's rewrite rules. https://www.netlify.com/docs/redirects/#geoip-and-language-based-redirects. It says 'redirect' here, but if you use 200 as the status code, it'll rewrite rather than redirect.

You can also set an nf_lang cookie, so we have a path to a language picker.

The idea is just to do multiple builds of the site.

import { strTryAgain, strMedium, strEasy } from ':lang:';

Where Rollup will make :lang: an import like:

export const strTryAgain = 'Try again';
export const strMedium = 'Medium';
export const strEasy = 'Easy';

And it'll just do a build per language pack.

We need to make sure we set Vary headers on all content.

We need to avoid the subsetted font trick for non-English (unless we do similar subsetting).

We probably need to rethink the font all together for non-latin script.

@jakearchibald jakearchibald self-assigned this Aug 2, 2019
@jakearchibald
Copy link
Contributor Author

Test: https://localisation-test--gravitongame.netlify.com/

curl -v -H "Accept-Language: en-in"  https://localisation-test--gravitongame.netlify.com
curl -v -H "Accept-Language: en-gb"  https://localisation-test--gravitongame.netlify.com
curl -v -H "Accept-Language: en-us"  https://localisation-test--gravitongame.netlify.com
curl -v -H "Accept-Language: hi-in"  https://localisation-test--gravitongame.netlify.com

@surma
Copy link
Contributor

surma commented Aug 5, 2019

Nice!

The only worry I have around multiple, separate builds is ServiceWorker and the caches. For example, each language will have their own sprite textures that will get redownloaded when I switch languages, no? Or can we dedupe those across builds?

@jakearchibald
Copy link
Contributor Author

They're duped in the build, but (assuming their content is the same) they'll have the same URL at the end. It could be a build optimisation though.

I guess the point is, hashed assets do not need Vary, since their variance is covered by the hash. I should limit to resources that aren't hashed and change by language (the root, the service worker, maybe more?)

But yeah, we'll have to trigger sprite regeneration on language change (assuming numbers are different).

I'll have a think about the service worker behaviour here. Maybe forcing a reload in this case is a better option.

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

2 participants