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

misc(proto): add i18n.icuMessagePaths #13068

Merged
merged 1 commit into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 5 additions & 10 deletions lighthouse-core/lib/proto-preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const fs = require('fs');
*/

/**
* Transform an LHR into a proto-friendly, mostly-compatible LHR.
* @param {LH.Result} lhr
* @return {LH.Result}
*/
* Transform an LHR into a proto-friendly, mostly-compatible LHR.
* @param {LH.Result} lhr
* @return {LH.Result}
*/
function processForProto(lhr) {
/** @type {LH.Result} */
const reportJson = JSON.parse(JSON.stringify(lhr));
Expand Down Expand Up @@ -68,13 +68,8 @@ function processForProto(lhr) {
});
}

// Drop the i18n icuMessagePaths. Painful in proto, and low priority to expose currently.
if (reportJson.i18n && reportJson.i18n.icuMessagePaths) {
delete reportJson.i18n.icuMessagePaths;
}

// Remove any found empty strings, as they are dropped after round-tripping anyway
/**
* Remove any found empty strings, as they are dropped after round-tripping anyway
* @param {any} obj
*/
function removeStrings(obj) {
Expand Down
7 changes: 6 additions & 1 deletion proto/lighthouse-result.proto
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,13 @@ message I18n {
string show_relevant_audits = 48;
}

// The message holding all formatted strings
// The message holding all formatted strings used in the renderer.
RendererFormattedStrings renderer_formatted_strings = 1;

// Holds all message paths used. The locale of the report has already be used to translated
// the strings in this LighthouseResult, but this field can be used to translate into another
// language.
map<string, google.protobuf.ListValue> icu_message_paths = 2;
}

// Message containing Stack Pack information.
Expand Down
6 changes: 5 additions & 1 deletion types/lhr/lhr.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ interface Result {
/** Execution timings for the Lighthouse run */
timing: Result.Timing;
/** Strings for the report and the record of all formatted string locations in the LHR and their corresponding source values. */
i18n: {rendererFormattedStrings: Record<string, string>, icuMessagePaths?: Result.IcuMessagePaths};
i18n: {
rendererFormattedStrings: Record<string, string>;
/** Optional because LR has many old LHRs that return nothing for this property. */
icuMessagePaths?: Result.IcuMessagePaths;
};
/** An array containing the result of all stack packs. */
stackPacks?: Result.StackPack[];
}
Expand Down