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

core(i18n): incorporate 52 languages into messages pipeline #5781

Merged
merged 8 commits into from
Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from 6 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
9 changes: 1 addition & 8 deletions lighthouse-cli/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function getFlags(manualArgv) {
],
'Configuration:')
.describe({
// We don't allowlist specific locales. Why? So we can support the user who requests 'es-MX' (unsupported) and we'll fall back to 'es' (supported)
Copy link
Member

Choose a reason for hiding this comment

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

we might want a command for listing available locales, but something for another day :)

'locale': 'The locale/language the report should be formatted in',
'enable-error-reporting':
'Enables error reporting, overriding any saved preference. --no-enable-error-reporting will do the opposite. More: https://git.io/vFFTO',
Expand Down Expand Up @@ -119,14 +120,6 @@ function getFlags(manualArgv) {
'disable-storage-reset', 'disable-device-emulation', 'save-assets', 'list-all-audits',
'list-trace-categories', 'view', 'verbose', 'quiet', 'help',
])
.choices('locale', [
// Later, this could be Object.keys(require('../lighthouse-core/lib/locales/index.js'))
// But we'll curate the list for now..

'en-US', // English
'en-XA', // Accented English, good for testing
'ar-XB', // RTL English, good for testing
])
.choices('output', printer.getValidOutputOptions())
.choices('throttling-method', ['devtools', 'provided', 'simulate'])
.choices('preset', ['full', 'perf', 'mixed-content'])
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const formats = {
* Look up the best available locale for the requested language through these fall backs:
* - exact match
* - progressively shorter prefixes (`de-CH-1996` -> `de-CH` -> `de`)
* - the default locale ('en-US') if no match is found
* - the default locale ('en') if no match is found
*
* If `locale` isn't provided, the default is used.
* @param {string=} locale
Expand All @@ -82,7 +82,7 @@ function lookupLocale(locale) {
const canonicalLocale = Intl.getCanonicalLocales(locale)[0];

const closestLocale = lookupClosestLocale(canonicalLocale, LOCALES);
return closestLocale || 'en-US';
return closestLocale || 'en';
}

/**
Expand Down
332 changes: 0 additions & 332 deletions lighthouse-core/lib/locales/de-AT.json

This file was deleted.

332 changes: 0 additions & 332 deletions lighthouse-core/lib/locales/de-CH.json

This file was deleted.

332 changes: 0 additions & 332 deletions lighthouse-core/lib/locales/en-IN.json

This file was deleted.

332 changes: 0 additions & 332 deletions lighthouse-core/lib/locales/en-SG.json

This file was deleted.

332 changes: 0 additions & 332 deletions lighthouse-core/lib/locales/en-ZA.json

This file was deleted.

332 changes: 0 additions & 332 deletions lighthouse-core/lib/locales/fr-CH.json

This file was deleted.

332 changes: 0 additions & 332 deletions lighthouse-core/lib/locales/gsw.json

This file was deleted.

62 changes: 57 additions & 5 deletions lighthouse-core/lib/locales/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,63 @@

/** @type {Record<LH.Locale, LocaleMessages>} */
const locales = {
'ar': require('./ar-XB.json'), // TODO: fallback not needed when ar translation available
'ar-XB': require('./ar-XB.json'),
'en': require('./en-US.json'), // en-* fallback
'en-US': require('./en-US.json'),
'en-XA': require('./en-XA.json'),
'en-US': require('./en-US.json'), // The 'source' strings, with descriptions
'en': require('./en-US.json'), // According to CLDR/ICU, 'en' == 'en-US' dates/numbers (Why?!)

// TODO: en-IE has just ~10 messages that are different from en-US. We should only ship those.
'en-AU': require('./en-IE.json'), // Don't fallback to en (which -> en-US)
'en-GB': require('./en-IE.json'), // Don't fallback to en (which -> en-US)
'en-IE': require('./en-IE.json'), // Don't fallback to en (which -> en-US)
'en-SG': require('./en-IE.json'), // Don't fallback to en (which -> en-US)
'en-ZA': require('./en-IE.json'), // Don't fallback to en (which -> en-US)
'en-IN': require('./en-IE.json'), // Don't fallback to en (which -> en-US)

'gsw': require('./de.json'), // swiss german. identical (for our purposes) to 'de'

// All locales from here have a messages file, though we allow fallback to the base locale when the files are identical
'ar-XB': require('./ar-XB.json'), // psuedolocalization
'ar': require('./ar.json'),
'bg': require('./bg.json'),
'ca': require('./ca.json'),
'cs': require('./cs.json'),
'da': require('./da.json'),
'de': require('./de.json'), // de-AT, de-CH identical, so they fall back into de
'el': require('./el.json'),
'en-XA': require('./en-XA.json'), // psuedolocalization
'es': require('./es.json'),
'fi': require('./fi.json'),
'fil': require('./fil.json'),
'fr': require('./fr.json'), // fr-CH identical, so it falls back into fr
'hi': require('./hi.json'),
'hr': require('./hr.json'),
'hu': require('./hu.json'),
'id': require('./id.json'),
'it': require('./it.json'),
'iw': require('./iw.json'),
'ja': require('./ja.json'),
'ko': require('./ko.json'),
'lt': require('./lt.json'),
'lv': require('./lv.json'),
'nl': require('./nl.json'),
'no': require('./no.json'),
'pl': require('./pl.json'),
'pt': require('./pt.json'), // pt-BR identical, so it falls back into pt
'pt-PT': require('./pt-PT.json'),
'ro': require('./ro.json'),
'ru': require('./ru.json'),
'sk': require('./sk.json'),
'sl': require('./sl.json'),
'sr': require('./sr.json'),
'sv': require('./sv.json'),
'ta': require('./ta.json'),
'te': require('./te.json'),
'th': require('./th.json'),
'tr': require('./tr.json'),
'uk': require('./uk.json'),
'vi': require('./vi.json'),
'zh-CN': require('./zh-CN.json'),
'zh-HK': require('./zh-HK.json'),
'zh-TW': require('./zh-TW.json'),
Copy link
Member

Choose a reason for hiding this comment

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

on looking more, it seems like we should have a 'zh' that uses 'zh-CN', but we can investigate more

};

module.exports = locales;
Loading