WordPress / openverse-frontend

The gateway to the Openverse. Openverse is a search tool for CC-licensed and public domain content across the internet.
https://wordpress.org/openverse
MIT License
71 stars 63 forks source link

[@nuxtjs/i18n] Locale ISO code is required to generate alternate link #824

Closed zackkrida closed 2 years ago

zackkrida commented 2 years ago

Description

This error warning shows up ~38 times in development, per page refresh / load. This is caused by some locales in https://github.com/WordPress/openverse-frontend/blob/text-color-fixes/src/locales/scripts/valid-locales.json that don't have an iso attribute.

We should identify why these languages don't have an iso, and fix or remove the languages.

If you replace this line

https://github.com/WordPress/openverse-frontend/blob/c6f06754475690a88114b19af462df8ee64a9c9f/nuxt.config.js#L166

with ...(locales.filter((i) => i.iso) ?? []), you can observe these errors disappear.

Resolution

obulat commented 2 years ago

The iso field is used by Nuxt i18n to fill in the hreflang attribute for alternative links to other language versions of the page inside the head for SEO purposes. It is supposed to be in ISO 639-1 format, with optional country codes. Some of the locales in the valid-locales.json don't have an ISO 639-1 code assigned to them.

Full list of locales that don't have the `iso` field ``` {'code': 'pcm', 'name': 'Nigerian Pidgin', 'wpLocale': 'pcm', 'dir': 'ltr', 'translated': 0, 'file': 'pcm.json'} {'code': 'nqo', 'name': 'N’ko', 'wpLocale': 'nqo', 'dir': 'rtl', 'translated': 0, 'file': 'nqo.json'} {'code': 'scn', 'name': 'Sicilian', 'wpLocale': 'scn', 'dir': 'ltr', 'translated': 0, 'file': 'scn.json'} {'code': 'rhg', 'name': 'Rohingya', 'wpLocale': 'rhg', 'dir': 'ltr', 'translated': 0, 'file': 'rhg.json'} {'code': 'pirate', 'name': 'English (Pirate)', 'wpLocale': 'art_xpirate', 'dir': 'ltr', 'translated': 0, 'file': 'pirate.json'} {'code': 'szl', 'name': 'Silesian', 'wpLocale': 'szl', 'dir': 'ltr', 'translated': 0, 'file': 'szl.json'} {'code': 'pcd', 'name': 'Picard', 'wpLocale': 'pcd', 'dir': 'ltr', 'translated': 0, 'file': 'pcd.json'} {'code': 'sah', 'name': 'Sakha', 'wpLocale': 'sah', 'dir': 'ltr', 'translated': 0, 'file': 'sah.json'} {'code': 'pap-aw', 'name': 'Papiamento (Aruba)', 'wpLocale': 'pap_AW', 'dir': 'ltr', 'translated': 0, 'file': 'pap-aw.json'} {'code': 'skr', 'name': 'Saraiki', 'wpLocale': 'skr', 'dir': 'rtl', 'translated': 0, 'file': 'skr.json'} {'code': 'pap-cw', 'name': 'Papiamento (Curaçao and Bonaire)', 'wpLocale': 'pap_CW', 'dir': 'ltr', 'translated': 0, 'file': 'pap-cw.json'} {'code': 'twd', 'name': 'Tweants', 'wpLocale': 'twd', 'dir': 'ltr', 'translated': 0, 'file': 'twd.json'} {'code': 'hsb', 'name': 'Upper Sorbian', 'wpLocale': 'hsb', 'dir': 'ltr', 'translated': 0, 'file': 'hsb.json'} {'code': 'vec', 'name': 'Venetian', 'wpLocale': 'vec', 'dir': 'ltr', 'translated': 0, 'file': 'vec.json'} {'code': 'tzm', 'name': 'Tamazight (Central Atlas)', 'wpLocale': 'tzm', 'dir': 'ltr', 'translated': 0, 'file': 'tzm.json'} {'code': 'zgh', 'name': 'Tamazight', 'wpLocale': 'zgh', 'dir': 'ltr', 'translated': 0, 'file': 'zgh.json'} {'code': 'syr', 'name': 'Syriac', 'wpLocale': 'syr', 'dir': 'ltr', 'translated': 0, 'file': 'syr.json'} {'code': 'me', 'name': 'Montenegrin', 'wpLocale': 'me_ME', 'dir': 'ltr', 'translated': 0, 'file': 'me.json'} {'code': 'art-xemoji', 'name': 'Emoji', 'wpLocale': 'art_xemoji', 'dir': 'ltr', 'translated': 0, 'file': 'art-xemoji.json'} {'code': 'ceb', 'name': 'Cebuano', 'wpLocale': 'ceb', 'dir': 'ltr', 'translated': 0, 'file': 'ceb.json'} {'code': 'fon', 'name': 'Fon', 'wpLocale': 'fon', 'dir': 'ltr', 'translated': 0, 'file': 'fon.json'} {'code': 'bal', 'name': 'Catalan (Balear)', 'wpLocale': 'bal', 'dir': 'ltr', 'translated': 0, 'file': 'bal.json'} {'code': 'frp', 'name': 'Arpitan', 'wpLocale': 'frp', 'dir': 'ltr', 'translated': 0, 'file': 'frp.json'} {'code': 'ast', 'name': 'Asturian', 'wpLocale': 'ast', 'dir': 'ltr', 'translated': 0, 'file': 'ast.json'} {'code': 'bcc', 'name': 'Balochi Southern', 'wpLocale': 'bcc', 'dir': 'rtl', 'translated': 0, 'file': 'bcc.json'} {'code': 'bho', 'name': 'Bhojpuri', 'wpLocale': 'bho', 'dir': 'ltr', 'translated': 0, 'file': 'bho.json'} {'code': 'brx', 'name': 'Bodo', 'wpLocale': 'brx', 'dir': 'ltr', 'translated': 0, 'file': 'brx.json'} {'code': 'gax', 'name': 'Borana-Arsi-Guji Oromo', 'wpLocale': 'gax', 'dir': 'ltr', 'translated': 0, 'file': 'gax.json'} {'code': 'fur', 'name': 'Friulian', 'wpLocale': 'fur', 'dir': 'ltr', 'translated': 0, 'file': 'fur.json'} {'code': 'dsb', 'name': 'Lower Sorbian', 'wpLocale': 'dsb', 'dir': 'ltr', 'translated': 0, 'file': 'dsb.json'} {'code': 'lij', 'name': 'Ligurian', 'wpLocale': 'lij', 'dir': 'ltr', 'translated': 0, 'file': 'lij.json'} {'code': 'lmo', 'name': 'Lombard', 'wpLocale': 'lmo', 'dir': 'ltr', 'translated': 0, 'file': 'lmo.json'} {'code': 'mai', 'name': 'Maithili', 'wpLocale': 'mai', 'dir': 'ltr', 'translated': 0, 'file': 'mai.json'} {'code': 'mfe', 'name': 'Mauritian Creole', 'wpLocale': 'mfe', 'dir': 'ltr', 'translated': 0, 'file': 'mfe.json'} {'code': 'haw', 'name': 'Hawaiian', 'wpLocale': 'haw_US', 'dir': 'ltr', 'translated': 0, 'file': 'haw.json'} {'code': 'haz', 'name': 'Hazaragi', 'wpLocale': 'haz', 'dir': 'rtl', 'translated': 0, 'file': 'haz.json'} {'code': 'kab', 'name': 'Kabyle', 'wpLocale': 'kab', 'dir': 'ltr', 'translated': 0, 'file': 'kab.json'} {'code': 'kaa', 'name': 'Karakalpak', 'wpLocale': 'kaa', 'dir': 'ltr', 'translated': 0, 'file': 'kaa.json'} ```

I think we could simply use ...(locales.filter((i) => i.iso) ?? []), to filter out these locales, as they do not have any translations available.

sarayourfriend commented 2 years ago

Is this (the missing iso field) something we should also report upstream to the WP i18n folks?