-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
core(i18n): export rendererFormattedStrings #5713
Conversation
@@ -89,9 +89,10 @@ class CategoryRenderer { | |||
// Add list of warnings or singular warning | |||
const warningsEl = this.dom.createChildOf(titleEl, 'div', 'lh-warnings'); | |||
if (warnings.length === 1) { | |||
warningsEl.textContent = `Warning: ${warnings.join('')}`; | |||
// TODO(i18n): Maybe need to construct this differently |
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.
TODO(i18n): Maybe need to construct this differently
if warnings are full sentences this should be fine
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.
alright, removed
@@ -35,6 +35,11 @@ class ReportRenderer { | |||
renderReport(report, container) { | |||
// If any mutations happen to the report within the renderers, we want the original object untouched | |||
const clone = /** @type {LH.ReportResult} */ (JSON.parse(JSON.stringify(report))); | |||
// Mutate the UIStrings if necessary (while saving originals) |
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.
should the technical debt comment below be moved up here? :)
It does kind of suck to rely on utils as a mutable singleton. We pass at least a DOM
into all of our report rendering classes. Should we pass in strings? Or pass the lhr to everything, use lhr.i18n.rendererFormattedStrings.string
everywhere, and here (since we're mutating the lhr anyways) could set lhr.i18n.rendererFormattedStrings
to the default strings if not set.
Fine to punt to a future PR, but it would be nice to have a plan before we get too deep.
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.
Or pass the lhr to everything, use lhr.i18n.rendererFormattedStrings.string everywhere, and here (since we're mutating the lhr anyways) could set lhr.i18n.rendererFormattedStrings to the default strings if not set.
This sounds good to me, we have other LHR reaching needs like locale in config settings and such that would be nice. I accept your offer for a followup :)
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.
add a TODO?
@@ -35,6 +35,11 @@ class ReportRenderer { | |||
renderReport(report, container) { | |||
// If any mutations happen to the report within the renderers, we want the original object untouched | |||
const clone = /** @type {LH.ReportResult} */ (JSON.parse(JSON.stringify(report))); | |||
// Mutate the UIStrings if necessary (while saving originals) | |||
ReportRenderer.stashUIStrings(); |
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.
if it's stashing just for this function, can it stored in a local variable instead of stashed in a static property?
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.
done
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.
otherwise LGTM!
brings i18n strings to the renderer! this tackles most of what we need for performance category. strategy is what was outlined in #5655, strings are located at
lhr.i18n.rendererFormattedStrings
which the renderer uses to replace its own UIStrings inutil.js
the
${n} audits
is definitely going to be a problem we're going to have to figure out, but for performance it only shows up for the "passed audits" section and none of the others which isn't the worst thing to live without at first if we need to