-
Notifications
You must be signed in to change notification settings - Fork 9.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
Custom locales #9043
Comments
This seems like a reasonable approach. One note, we'll still want to package en-US.json with the bundle, so that it's picked up by default. The DevTools will not make a request for locale strings when the language is set to English, so they need to be baked in. |
Another approach would be to make bundle(s?) of locales with whatever script comes out of #8755 for swapping LHR locales. Lighthouse would run as it does today (with the A benefit of this would be that we wouldn't have to get clever with bundle splitting or triggering downloads in core...all of the locale stuff could be handled by Audits2Panel in DevTools. |
+1 to shipping #8755 bundles and still generating as usual. Though I called it a "locale rewriter" bundle, great minds think alike :) |
To confirm, you're suggesting we do something like modify AuditsPanel2.js!_startAudit to call swapLocale(lhr, requestedLocale) before calling through to _buildReportUI(lhrReport). swapLocale would be included as part of lighthouse-dt-bundle.js, correct? Assuming the DevTools package the Lighthouse <locale>.json translations with the browser's resource system, which are fetched when an Audit is generated. Thoughts on how the requestedLocale's LocaleMessages would be set by the DevTools? |
That is roughly my suggestion. I was thinking this happens on the worker side before returning the result object so all the remote module code execution stays in the worker, but it's very similar points in the lifecycle. Based on @brendankenny's comments it sounds like he might have been thinking it happens in the Audits2Panel context though?
My proposal at least was that It's certainly possible to have the |
yes, I believe so
we'd have to adapt to what's feasible, but I was suggesting it be in a separate bundle. Basically (as a handwavy example) devtools could fetch a |
whoops, ninjaed :)
it was just an idea, I don't actually know all that much about how fetching remote modules works :) I was thinking running them in two workers would allow DevTools to fetch the two bundles ( |
I'm tracking with you now. Thanks for the clarification. We were thinking from the point of view of including the <locale>.json message translations with the appropriate .pak in the browser, which would be loaded by the browsers resource system. In this case, it would be wasteful to disk footprint to include lighthouse-swap-<locale>.js. If we were to segment the lighthouse/<locale>.json to the matching browser locale .pak files, then we'd need a way to pass that to Lighthouse to perform the appropriate translations. Initially, we were thinking something of like runLighthouseWorker(..., locale, localeMessageJsonObject) or a helper that would accept localeMessageJsonObject. We'll have a look at using remote bundles for lighthouse-swap-fr-bundle.js. We'll have to consider the disk hit for bundling everything on builds (i.e. ChromeOS, others?) that can't pull from a remote server. |
@JoelEinbinder, I'd like to get your take on using remote modules of |
Technically possible with #9638 |
Was thinking about how to support lazy-locales in DevTools. What about adding "custom locales" via the plugin system? Would have to complete our plugins in DevTools story.
Would just add to LOCALES in ./lighthouse-core/lib/i18n/locales.js ASAP. So, in DevTools, the lazy module loading would pass in the extra locale for w/e the AuditPanel was configured to use.
Link to devtools-entry.
Also would enable my dream of making a pirate translation.
The text was updated successfully, but these errors were encountered: