[go: nahoru, domu]

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

i18n: add es-419 #9171

Merged
merged 5 commits into from
Jun 12, 2019
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
25 changes: 25 additions & 0 deletions lighthouse-core/lib/i18n/locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,31 @@ 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
Member

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.

// Aliases of es-419: https://raw.githubusercontent.com/unicode-cldr/cldr-core/master/supplemental/parentLocales.json
'es-AR': require('./locales/es-419.json'),
'es-BO': require('./locales/es-419.json'),
'es-BR': require('./locales/es-419.json'),
'es-BZ': require('./locales/es-419.json'),
'es-CL': require('./locales/es-419.json'),
'es-CO': require('./locales/es-419.json'),
'es-CR': require('./locales/es-419.json'),
'es-CU': require('./locales/es-419.json'),
'es-DO': require('./locales/es-419.json'),
'es-EC': require('./locales/es-419.json'),
'es-GT': require('./locales/es-419.json'),
'es-HN': require('./locales/es-419.json'),
'es-MX': require('./locales/es-419.json'),
'es-NI': require('./locales/es-419.json'),
'es-PA': require('./locales/es-419.json'),
'es-PE': require('./locales/es-419.json'),
'es-PR': require('./locales/es-419.json'),
'es-PY': require('./locales/es-419.json'),
'es-SV': require('./locales/es-419.json'),
'es-US': require('./locales/es-419.json'),
'es-UY': require('./locales/es-419.json'),
'es-VE': require('./locales/es-419.json'),

'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