-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
FES + i18n: Load translations from a CDN #4701
FES + i18n: Load translations from a CDN #4701
Conversation
It is possible to publish the files to cdnjs as well, probably just need to make a PR to edit this file. A fix for |
Yes. I will look into it. |
This looks great. Could we add some link in the |
Hi. Yes. I will add that too. |
ec0fcb5
to
d3813a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Two small simple questions inline. I am working with the assumption that we will have some time to look at this in more depth later to make sure that it is easy enough for others to maintain and build upon.
One part that might be a bit difficult to maintain is this. There are already several i18next plugins available that do something similar like i18next-http-backend, i18next-fetch-backend. But there were two things which I didn't find a way to implement using these: quickly skip a language if it doesn't exist in the list of supported languages ( don't send a request ), and timeout a request if it takes too much time. Since we are stalling the initialization waiting for the translations to finish downloading, it may be important that this step doesn't take too much time as well ensure that it doesn't spend time trying to find files for languages which we know aren't supported yet. This may be important when there is a chain of unsupported languages. For example, if someone's browser language is |
7234cdf
to
362adf8
Compare
Thanks for explaining this in detail. I think that quickly skipping unsupported languages should be a priority for future work. |
Resolves #4694
Changes:
translations/**
get published to NPM. From there, jsDelivr can cache it to their CDN.I published a namespaced version to test this out and it seems to work
https://cdn.jsdelivr.net/npm/@akshay-99/[email protected]/translations/es/translation.json
https://cdn.jsdelivr.net/npm/@akshay-99/[email protected]/translations/en/translation.json
These changes would take effect from the next release. Before then, the configured path ( https://cdn.jsdelivr.net/npm/p5/translations/ ) would give us a 404. This wouldn't be a problem for contributors because of the next point below.
dev
mode. Whenever someone is adding/updating something, they should be able to test it out. Fetching from the CDN will not be helpful as these changes wouldn't have been published yet. I configured grunt and browserify to pack all the translation files in the library when runningbrowserify:dev
( i.e withnpm run dev
but not withnpm run build
)Also, since we have updated our default branch name to
main
, we may have to change something withnp
to let it know this. Otherwise it complains that we aren't on the correct branch and would stop the release. For testing out this PR, I just manually passed in--any-branch
. But there must be some other way to letnp
know the name of the default branch.PR Checklist
npm run lint
passes