Skip to content

Commit

Permalink
locale fix
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Jul 10, 2018
1 parent f2cfd68 commit 60f3da8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lighthouse-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Config = require('./config/config');
async function lighthouse(url, flags, configJSON) {
// TODO(bckenny): figure out Flags types.
flags = flags || /** @type {LH.Flags} */ ({});
i18n.setLocale(flags.locale || 'en-US');
i18n.setLocale(flags.locale);

// set logging preferences, assume quiet
flags.logLevel = flags.logLevel || 'error';
Expand Down
7 changes: 6 additions & 1 deletion lighthouse-core/lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const formats = {
},
};

/**
* @param {string} msg
* @param {Record<string, *>} values
*/
function preprocessMessageValues(msg, values) {
const parsed = MessageParser.parse(msg);
// Replace all the bytes with KB
Expand Down Expand Up @@ -71,7 +75,7 @@ module.exports = {
// fallback to the original english message if we couldn't find a message in the specified locale
// better to have an english message than no message at all, in some number cases it won't even matter
const messageForMessageFormat = localeStrings[lookupKey] || msg
// when using accented english, force the use of a different locale for numbers
// when using accented english, force the use of a different locale for number formatting
const localeForMessageFormat = locale === 'en-XA' ? 'de-DE' : locale;

const formatter = new MessageFormat(
Expand All @@ -86,6 +90,7 @@ module.exports = {
},
/** @param {string} newLocale */
setLocale(newLocale) {
if (typeof newLocale === 'undefined') return;
locale = newLocale;
},
};

0 comments on commit 60f3da8

Please sign in to comment.