Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions lighthouse-core/lib/i18n/locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const locales = {
'el': require('./locales/el.json'),
'en-XA': require('./locales/en-XA.json'), // psuedolocalization
'es': require('./locales/es.json'),
'es-419': require('./locales/es-419.json'),
Copy link
Member

@paulirish paulirish Jun 11, 2019

Choose a reason for hiding this comment

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

much like en-gb, it appears we have to account for the parent/child locales ourselves. Why?? I have no idea.

But here's the list of es-419 child locales: es-AR, es-BO, es-BR, es-BZ, es-CL, es-CO, es-CR, es-CU, es-DO, es-EC, es-GT, es-HN, es-MX, es-NI, es-PA, es-PE, es-PR, es-PY, es-SV, es-US, es-UY, es-VE

Source in the CLDR: https://raw.githubusercontent.com/unicode-cldr/cldr-core/master/supplemental/parentLocales.json

( And tc39/ecma402#87 isn't a thing yet.)

Copy link
Member

Choose a reason for hiding this comment

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

I know this because I started writing this patch yesterday, before I saw your PR.

But where I went is a dark dark place.... (syntax-wise, at least)

@@ -14,6 +14,9 @@
 
 /** @typedef {Record<string, {message: string}>} LocaleMessages */
 
+const es419 = require('./locales/es-419.json');
+const es419locales = 'es-AR, es-BO, es-BR, es-BZ, es-CL, es-CO, es-CR, es-CU, es-DO, es-EC, es-GT, es-HN, es-MX, es-NI, es-PA, es-PE, es-PR, es-PY, es-SV, es-US, es-UY, es-VE';
+
 // The keys within this const must exactly match the LH.Locale type in externs.d.ts
 /** @type {Record<LH.Locale, LocaleMessages>} */
 const locales = {
@@ -28,6 +31,9 @@ const locales = {
   'en-ZA': require('./locales/en-GB.json'), // Alias of 'en-GB'
   'en-IN': require('./locales/en-GB.json'), // Alias of 'en-GB'
 
+  // https://raw.githubusercontent.com/unicode-cldr/cldr-core/master/supplemental/parentLocales.json
+  ...Object.fromEntries(es419locales.split(', ').map(locale => [locale, es419])),
+
   // All locales from here have a messages file, though we allow fallback to the base locale when the files are identical
   'ar-XB': require('./locales/ar-XB.json'), // psuedolocalization
   'ar': require('./locales/ar.json'),

🤢

Copy link
Collaborator

Choose a reason for hiding this comment

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

i like it

Copy link
Contributor

Choose a reason for hiding this comment

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

no fromEntries yet (Node 10)

Copy link
Member

Choose a reason for hiding this comment

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

yah fromEntries ended up being a pain in the ass. Node 10 and TSC both being real cranky about it. Not worth it.

Copy link
Member Author

Choose a reason for hiding this comment

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

TL;DR fancy js is fancy, but fancy regex replacements is also fancy, and much easier.

'fi': require('./locales/fi.json'),
'fil': require('./locales/fil.json'),
'fr': require('./locales/fr.json'), // fr-CH identical, so it falls back into fr
Expand Down
Loading