Skip to content

Commit

Permalink
misc(proto): add i18n.icuMessagePaths (#13068)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored Sep 15, 2021
1 parent 06bdf13 commit fa69d24
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
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

0 comments on commit fa69d24

Please sign in to comment.