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

i18n(report): runtime settings and tools #9166

Merged
merged 32 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
52030ca
i18n runtime settings & dropdown. Modify ui-feat for i18n.
exterkamp Jun 10, 2019
ab5b189
Wrongly added this localeString mod
exterkamp Jun 10, 2019
df92054
Messed up some HTML while editing the strings.
exterkamp Jun 10, 2019
e6a7d32
Ignore report-ui-feat from collect-strings. Update proto, update sam…
exterkamp Jun 10, 2019
5a5f2c0
stringback
exterkamp Jun 10, 2019
e469d64
this -> Util
exterkamp Jun 10, 2019
670ef5e
Add proto comments.
exterkamp Jun 13, 2019
341b858
convert \t to _ because regex is hard
exterkamp Jun 13, 2019
4664a5f
Merge branch 'master' into i18n-report
exterkamp Jun 26, 2019
5f1ec69
collected en-XL
exterkamp Jun 26, 2019
03afb96
Merge branch 'master' into i18n-report
exterkamp Jul 10, 2019
78444a7
Merge branch 'master' into i18n-report
exterkamp Jul 26, 2019
62b3ba1
let -> const
exterkamp Jul 26, 2019
e683ebd
updated id's
exterkamp Aug 1, 2019
d5135a0
Merge branch 'master' into i18n-report
exterkamp Aug 14, 2019
1676f8a
Added caching/hydration to Util
exterkamp Aug 14, 2019
a785482
hm, not sure how that worked, but okay
exterkamp Aug 16, 2019
a0c7c91
Merge branch 'master' into i18n-report
exterkamp Aug 16, 2019
d8916e7
Merge branch 'master' into i18n-report
exterkamp Jan 8, 2020
eff2c46
net -> network
exterkamp Jan 8, 2020
37732a6
data-i18n attr
exterkamp Jan 8, 2020
c7b5083
update sample json
exterkamp Jan 8, 2020
ef3549d
keyof!
exterkamp Jan 8, 2020
52abf75
forEach -> for of
exterkamp Jan 9, 2020
0bac2c4
add test
exterkamp Jan 9, 2020
d4d35a3
Connor's nits
exterkamp Jan 10, 2020
ccdba60
Remove backup English from html, remove useless ignorePaths
exterkamp Jan 13, 2020
3301b18
Merge branch 'i18n-report' of github.com:GoogleChrome/lighthouse into…
exterkamp Jan 13, 2020
4c89c0f
fix tests
exterkamp Jan 14, 2020
ee5bab0
Merge remote-tracking branch 'origin/master' into i18n-report
exterkamp Jan 14, 2020
d5aa83c
Revert "fix tests"
exterkamp Jan 14, 2020
551886b
ignore axe link-name
exterkamp Jan 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions lighthouse-core/lib/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,38 @@
"message": "Maximum critical path latency:",
"description": "Label of value shown in the summary of critical request chains. Refers to the total amount of time (milliseconds) of the longest critical path chain/sequence of network requests. Example value: 2310 ms"
},
"lighthouse-core/report/html/renderer/util.js | dropdownCopyJSON": {
"message": "Copy JSON",
"description": "Option in a dropdown menu that copies the Lighthouse JSON object to the system clipboard."
},
"lighthouse-core/report/html/renderer/util.js | dropdownDarkTheme": {
"message": "Toggle Dark Theme",
"description": "Option in a dropdown menu that toggles the themeing of the report between Light(default) and Dark themes."
},
"lighthouse-core/report/html/renderer/util.js | dropdownPrintExpanded": {
"message": "Print Expanded",
"description": "Option in a dropdown menu that opens a full Lighthouse report in a print dialog."
},
"lighthouse-core/report/html/renderer/util.js | dropdownPrintSummary": {
"message": "Print Summary",
"description": "Option in a dropdown menu that opens a small, summary report in a print dialog."
},
"lighthouse-core/report/html/renderer/util.js | dropdownSaveGist": {
"message": "Save as Gist",
"description": "Option in a dropdown menu that saves the current report as a new Github Gist."
},
"lighthouse-core/report/html/renderer/util.js | dropdownSaveHTML": {
"message": "Save as HTML",
"description": "Option in a dropdown menu that saves the Lighthouse report HTML locally to the system as a '.html' file."
},
"lighthouse-core/report/html/renderer/util.js | dropdownSaveJSON": {
"message": "Save as JSON",
"description": "Option in a dropdown menu that save the Lighthouse JSON object to the local system as a '.json' file."
},
"lighthouse-core/report/html/renderer/util.js | dropdownViewer": {
"message": "Open in Viewer",
"description": "Option in a dropdown menu that opens the current report in the Lighthouse Viewer Application."
},
"lighthouse-core/report/html/renderer/util.js | errorLabel": {
"message": "Error!",
"description": "A label, shown next to an audit title or metric title, indicating that there was an error computing it. The user can hover on the label to reveal a tooltip with the extended error message. Translation should be short (< 20 characters)."
Expand All @@ -1407,6 +1439,10 @@
"message": "Report error: no audit information",
"description": "An error string displayed next to a particular audit when it has errored, but not provided any specific error message."
},
"lighthouse-core/report/html/renderer/util.js | footerIssue": {
"message": "File an issue",
"description": "Label for button to create an issue against the Lighthouse Github project."
},
"lighthouse-core/report/html/renderer/util.js | labDataTitle": {
"message": "Lab Data",
"description": "Title of the lab data section of the Performance category. Within this section are various speed metrics which quantify the pageload performance into values presented in seconds and milliseconds. \"Lab\" is an abbreviated form of \"laboratory\", and refers to the fact that the data is from a controlled test of a website, not measurements from real users visiting that site."
Expand Down Expand Up @@ -1435,6 +1471,58 @@
"message": "Passed audits",
"description": "Section heading shown above a list of audits that are passing. 'Passed' here refers to a passing grade. This section is collapsed by default, as the user should be focusing on the failed audits instead. Users can click this heading to reveal the list."
},
"lighthouse-core/report/html/renderer/util.js | runtimeDesktopEmulation": {
"message": "Emulated Desktop",
"description": "Descriptive explanation for emulation setting when emulating a generic desktop form factor, as opposed to a mobile-device like form factor."
},
"lighthouse-core/report/html/renderer/util.js | runtimeMobileEmulation": {
"message": "Emulated Nexus 5X",
"description": "Descriptive explanation for emulation setting when emulating a Nexus 5X mobile device."
},
"lighthouse-core/report/html/renderer/util.js | runtimeNoEmulation": {
"message": "No emulation",
"description": "Descriptive explanation for emulation setting when no device emulation is set."
},
"lighthouse-core/report/html/renderer/util.js | runtimeSettingsBenchmark": {
"message": "CPU/Memory Power",
"description": "Label for a row in a table that shows the estimated CPU power of the machine running Lighthouse. Example row values: 532, 1492, 783."
},
"lighthouse-core/report/html/renderer/util.js | runtimeSettingsCPUThrottling": {
"message": "CPU throttling",
"description": "Label for a row in a table that describes the CPU throttling conditions that were used during a Lighthouse run, if any."
},
"lighthouse-core/report/html/renderer/util.js | runtimeSettingsDevice": {
"message": "Device",
"description": "Label for a row in a table that describes the kind of physical device that was emulated for the Lighthouse run. Example values for row elements: 'No Emulation', 'Emulated Desktop', etc."
},
"lighthouse-core/report/html/renderer/util.js | runtimeSettingsFetchTime": {
"message": "Fetch Time",
"description": "Label for a row in a table that shows the time that a Lighthouse run was conducted."
},
"lighthouse-core/report/html/renderer/util.js | runtimeSettingsNetworkThrottling": {
"message": "Network throttling",
"description": "Label for a row in a table that describes the network throttling conditions that were used during a Lighthouse run, if any."
},
"lighthouse-core/report/html/renderer/util.js | runtimeSettingsTitle": {
"message": "Runtime Settings",
"description": "Title of the Runtime settings table in a Lighthouse report. Runtime settings are the environment configurations that a specific report used at auditing time."
},
"lighthouse-core/report/html/renderer/util.js | runtimeSettingsUA": {
"message": "User agent (host)",
"description": "Label for a row in a table that shows the User Agent that was detected on the Host machine of the Lighthouse run."
},
"lighthouse-core/report/html/renderer/util.js | runtimeSettingsUANet": {
"message": "User agent (network)",
"description": "Label for a row in a table that shows the User Agent that was used to send out all network requests during the Lighthouse run."
},
"lighthouse-core/report/html/renderer/util.js | runtimeSettingsUrl": {
"message": "URL",
"description": "Label for a row in a table that shows the URL that was audited during a Lighthouse run."
},
"lighthouse-core/report/html/renderer/util.js | runtimeUnknown": {
"message": "Unknown",
"description": "Descriptive explanation for a runtime setting that is set to an unknown value."
},
"lighthouse-core/report/html/renderer/util.js | snippetCollapseButtonLabel": {
"message": "Collapse snippet",
"description": "Label for button that only shows a few lines of the snippet when clicked"
Expand All @@ -1447,6 +1535,10 @@
"message": "Show 3rd-party resources",
"description": "This label is for a checkbox above a table of items loaded by a web page. The checkbox is used to show or hide third-party (or \"3rd-party\") resources in the table, where \"third-party resources\" refers to items loaded by a web page from URLs that aren't controlled by the owner of the web page."
},
"lighthouse-core/report/html/renderer/util.js | throttlingProvided": {
"message": "Provided by environment",
"description": "Descriptive explanation for environment throttling that was provided by the runtime environment instead of provided by Lighthouse throttling."
},
"lighthouse-core/report/html/renderer/util.js | toplevelWarningsMessage": {
"message": "There were issues affecting this run of Lighthouse:",
"description": "Label shown preceding any important warnings that may have invalidated the entire report. For example, if the user has Chrome extensions installed, they may add enough performance overhead that Lighthouse's performance metrics are unreliable. If shown, this will be displayed at the top of the report UI."
Expand Down
14 changes: 9 additions & 5 deletions lighthouse-core/report/html/renderer/report-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,18 @@ class ReportRenderer {

const env = this._dom.find('.lh-env__items', footer);
env.id = 'runtime-settings';
this._dom.find('.lh-env__title', footer).textContent = Util.UIStrings.runtimeSettingsTitle;

const envValues = Util.getEnvironmentDisplayValues(report.configSettings || {});
[
{name: 'URL', description: report.finalUrl},
{name: 'Fetch time', description: Util.formatDateTime(report.fetchTime)},
{name: Util.UIStrings.runtimeSettingsUrl, description: report.finalUrl},
{name: Util.UIStrings.runtimeSettingsFetchTime,
description: Util.formatDateTime(report.fetchTime)},
...envValues,
{name: 'User agent (host)', description: report.userAgent},
{name: 'User agent (network)', description: report.environment &&
{name: Util.UIStrings.runtimeSettingsUA, description: report.userAgent},
{name: Util.UIStrings.runtimeSettingsUANet, description: report.environment &&
report.environment.networkUserAgent},
{name: 'CPU/Memory Power', description: report.environment &&
{name: Util.UIStrings.runtimeSettingsBenchmark, description: report.environment &&
report.environment.benchmarkIndex.toFixed(0)},
].forEach(runtime => {
if (!runtime.description) return;
Expand All @@ -119,6 +122,7 @@ class ReportRenderer {
env.appendChild(item);
});

this._dom.find('.lh-footer__version_issue', footer).textContent = Util.UIStrings.footerIssue;
this._dom.find('.lh-footer__version', footer).textContent = report.lighthouseVersion;
return footer;
}
Expand Down
29 changes: 29 additions & 0 deletions lighthouse-core/report/html/renderer/report-ui-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ class ReportUIFeatures {
initFeatures(report) {
this.json = report;

// TODO(i18n): Modifying Util singleton is not the best way to i18n this.
// Related TODO: https://github.com/GoogleChrome/lighthouse/pull/5713/files#r204948699
// Update util UIStrings, just like in report-renderer, we need to do it again b/c they have been reset.
const originalUIStrings = JSON.parse(JSON.stringify(Util.UIStrings));
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
if (report.i18n && report.i18n.rendererFormattedStrings) {
connorjclark marked this conversation as resolved.
Show resolved Hide resolved
Util.updateAllUIStrings(report.i18n.rendererFormattedStrings);
}

this._setupMediaQueryListeners();
this._setupToolsButton();
this._setupThirdPartyFilter();
Expand Down Expand Up @@ -139,6 +147,9 @@ class ReportUIFeatures {
this._dom.find('.lh-metrics-toggle__input', this._document));
toggleInputEl.checked = true;
}

// Reset Util UIStrings.
Util.updateAllUIStrings(originalUIStrings);
}

/**
Expand Down Expand Up @@ -211,6 +222,24 @@ class ReportUIFeatures {

const dropdown = this._dom.find('.lh-tools__dropdown', this._document);
dropdown.addEventListener('click', this.onToolAction);

// i18n the dropdown text
this._dom.find('#lh-dropdown_print_summary', dropdown).textContent =
Util.UIStrings.dropdownPrintSummary;
this._dom.find('#lh-dropdown_print_expanded', dropdown).textContent =
Util.UIStrings.dropdownPrintExpanded;
this._dom.find('#lh-dropdown_json', dropdown).textContent =
Util.UIStrings.dropdownCopyJSON;
this._dom.find('#lh-dropdown_save_html', dropdown).textContent =
Util.UIStrings.dropdownSaveHTML;
this._dom.find('#lh-dropdown_save_json', dropdown).textContent =
Util.UIStrings.dropdownSaveJSON;
this._dom.find('#lh-dropdown_open_viewer', dropdown).textContent =
Util.UIStrings.dropdownViewer;
this._dom.find('#lh-dropdown_save_gist', dropdown).textContent =
Util.UIStrings.dropdownSaveGist;
this._dom.find('#lh-dropdown_dark_theme', dropdown).textContent =
Util.UIStrings.dropdownDarkTheme;
}

_setupThirdPartyFilter() {
Expand Down
83 changes: 66 additions & 17 deletions lighthouse-core/report/html/renderer/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,69 +418,67 @@ class Util {

return [
{
name: 'Device',
name: this.UIStrings.runtimeSettingsDevice,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason we need to use this instead of Util here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No not really, I was following the prior art for that file, but using this. for only this file seems bad.

description: emulationDesc.deviceEmulation,
},
{
name: 'Network throttling',
name: this.UIStrings.runtimeSettingsNetworkThrottling,
description: emulationDesc.networkThrottling,
},
{
name: 'CPU throttling',
name: this.UIStrings.runtimeSettingsCPUThrottling,
description: emulationDesc.cpuThrottling,
},
];
}

/**
* @param {LH.Config.Settings} settings
* @return {{deviceEmulation: string, networkThrottling: string, cpuThrottling: string, summary: string}}
* @return {{deviceEmulation: string, networkThrottling: string, cpuThrottling: string}}
*/
static getEmulationDescriptions(settings) {
let cpuThrottling;
let networkThrottling;
let summary;

const throttling = settings.throttling;

switch (settings.throttlingMethod) {
case 'provided':
cpuThrottling = 'Provided by environment';
networkThrottling = 'Provided by environment';
summary = 'No throttling applied';
cpuThrottling = this.UIStrings.throttlingProvided;
networkThrottling = this.UIStrings.throttlingProvided;
break;
case 'devtools': {
const {cpuSlowdownMultiplier, requestLatencyMs} = throttling;
// TODO(i18n): ICU replacement syntax/formal i18n.js usage
cpuThrottling = `${Util.formatNumber(cpuSlowdownMultiplier)}x slowdown (DevTools)`;
networkThrottling = `${Util.formatNumber(requestLatencyMs)}${NBSP}ms HTTP RTT, ` +
`${Util.formatNumber(throttling.downloadThroughputKbps)}${NBSP}Kbps down, ` +
`${Util.formatNumber(throttling.uploadThroughputKbps)}${NBSP}Kbps up (DevTools)`;
summary = 'Throttled Slow 4G network';
break;
}
case 'simulate': {
const {cpuSlowdownMultiplier, rttMs, throughputKbps} = throttling;
cpuThrottling = `${Util.formatNumber(cpuSlowdownMultiplier)}x slowdown (Simulated)`;
networkThrottling = `${Util.formatNumber(rttMs)}${NBSP}ms TCP RTT, ` +
`${Util.formatNumber(throughputKbps)}${NBSP}Kbps throughput (Simulated)`;
summary = 'Simulated Slow 4G network';
break;
}
default:
cpuThrottling = 'Unknown';
networkThrottling = 'Unknown';
summary = 'Unknown';
cpuThrottling = this.UIStrings.runtimeUnknown;
networkThrottling = this.UIStrings.runtimeUnknown;
}

let deviceEmulation = 'No emulation';
if (settings.emulatedFormFactor === 'mobile') deviceEmulation = 'Emulated Nexus 5X';
if (settings.emulatedFormFactor === 'desktop') deviceEmulation = 'Emulated Desktop';
let deviceEmulation = this.UIStrings.runtimeNoEmulation;
if (settings.emulatedFormFactor === 'mobile') {
deviceEmulation = this.UIStrings.runtimeMobileEmulation;
} else if (settings.emulatedFormFactor === 'desktop') {
deviceEmulation = this.UIStrings.runtimeDesktopEmulation;
}

return {
deviceEmulation,
cpuThrottling,
networkThrottling,
summary: `${deviceEmulation}, ${summary}`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we just not use this? 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah forgot to mention, we removed this in the new report redesign. It was on the top header, but no more!

};
}

Expand Down Expand Up @@ -600,6 +598,57 @@ Util.UIStrings = {

/** This label is for a checkbox above a table of items loaded by a web page. The checkbox is used to show or hide third-party (or "3rd-party") resources in the table, where "third-party resources" refers to items loaded by a web page from URLs that aren't controlled by the owner of the web page. */
thirdPartyResourcesLabel: 'Show 3rd-party resources',

/** Option in a dropdown menu that opens a small, summary report in a print dialog. */
dropdownPrintSummary: 'Print Summary',
/** Option in a dropdown menu that opens a full Lighthouse report in a print dialog. */
dropdownPrintExpanded: 'Print Expanded',
/** Option in a dropdown menu that copies the Lighthouse JSON object to the system clipboard. */
dropdownCopyJSON: 'Copy JSON',
/** Option in a dropdown menu that saves the Lighthouse report HTML locally to the system as a '.html' file. */
dropdownSaveHTML: 'Save as HTML',
/** Option in a dropdown menu that save the Lighthouse JSON object to the local system as a '.json' file. */
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
dropdownSaveJSON: 'Save as JSON',
/** Option in a dropdown menu that opens the current report in the Lighthouse Viewer Application. */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LVA, I like it 😎

dropdownViewer: 'Open in Viewer',
/** Option in a dropdown menu that saves the current report as a new Github Gist. */
dropdownSaveGist: 'Save as Gist',
/** Option in a dropdown menu that toggles the themeing of the report between Light(default) and Dark themes. */
dropdownDarkTheme: 'Toggle Dark Theme',

/** Title of the Runtime settings table in a Lighthouse report. Runtime settings are the environment configurations that a specific report used at auditing time. */
runtimeSettingsTitle: 'Runtime Settings',
/** Label for a row in a table that shows the URL that was audited during a Lighthouse run. */
runtimeSettingsUrl: 'URL',
/** Label for a row in a table that shows the time that a Lighthouse run was conducted. */
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
runtimeSettingsFetchTime: 'Fetch Time',
/** Label for a row in a table that describes the kind of physical device that was emulated for the Lighthouse run. Example values for row elements: 'No Emulation', 'Emulated Desktop', etc. */
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
runtimeSettingsDevice: 'Device',
/** Label for a row in a table that describes the network throttling conditions that were used during a Lighthouse run, if any. */
runtimeSettingsNetworkThrottling: 'Network throttling',
/** Label for a row in a table that describes the CPU throttling conditions that were used during a Lighthouse run, if any.*/
runtimeSettingsCPUThrottling: 'CPU throttling',
/** Label for a row in a table that shows the User Agent that was detected on the Host machine of the Lighthouse run. */
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
runtimeSettingsUA: 'User agent (host)',
/** Label for a row in a table that shows the User Agent that was used to send out all network requests during the Lighthouse run. */
runtimeSettingsUANet: 'User agent (network)',
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
/** Label for a row in a table that shows the estimated CPU power of the machine running Lighthouse. Example row values: 532, 1492, 783. */
runtimeSettingsBenchmark: 'CPU/Memory Power',

/** Label for button to create an issue against the Lighthouse Github project. */
footerIssue: 'File an issue',

/** Descriptive explanation for emulation setting when no device emulation is set. */
runtimeNoEmulation: 'No emulation',
/** Descriptive explanation for emulation setting when emulating a Nexus 5X mobile device. */
runtimeMobileEmulation: 'Emulated Nexus 5X',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heads up Moto G4 conflict ahead :) #10191

/** Descriptive explanation for emulation setting when emulating a generic desktop form factor, as opposed to a mobile-device like form factor. */
runtimeDesktopEmulation: 'Emulated Desktop',
/** Descriptive explanation for a runtime setting that is set to an unknown value. */
runtimeUnknown: 'Unknown',

/** Descriptive explanation for environment throttling that was provided by the runtime environment instead of provided by Lighthouse throttling. */
throttlingProvided: 'Provided by environment',
};

if (typeof module !== 'undefined' && module.exports) {
Expand Down
Loading