The locale picker's labels are now AUTONYMS computed from Intl -- each language named in its own language, so "Português europeu" reads as Portuguese whichever locale the UI is in. That is the convention for a language picker and the useful behaviour: somebody who cannot read the current language still has to find theirs. CapabilityPage interpolated the capability KIND into six strings by lowercasing it in code. "skill" does not lowercase into a Portuguese noun, so kind is a parameter now. What is left is two strings, both deliberate: see the next commit message.
28 lines
1.3 KiB
TypeScript
28 lines
1.3 KiB
TypeScript
/**
|
|
* The UI locales that actually ship — regional BCP 47 tags, per docs/localization.md D2. This is the
|
|
* one list `I18nBridge` merges catalogs for and `Languages.tsx` offers for UI localization; it is
|
|
* deliberately separate from the broader "languages you speak" / "translate to" lists, which are a
|
|
* different feature (see the doc's open question 4) and are not limited to locales with a catalog.
|
|
*/
|
|
export type ShippedLocale = { code: string; label: string };
|
|
|
|
/**
|
|
* The label is an AUTONYM — each language named in its own language, so "Português" reads as Portuguese
|
|
* whichever locale the UI is currently in. That is the convention for a language picker and it is the
|
|
* useful behaviour: somebody who cannot read the current language still has to find theirs.
|
|
*
|
|
* Computed rather than written down, for the same reason the spoken-language list is (see Languages.tsx):
|
|
* `Intl` already knows every language's name in every locale, including its own.
|
|
*/
|
|
const autonym = (code: string): string => {
|
|
const name = new Intl.DisplayNames([code], { type: 'language', fallback: 'code' }).of(code) ?? code;
|
|
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
};
|
|
|
|
export const SHIPPED_LOCALES: ShippedLocale[] = ['en-GB', 'pt-PT'].map((code) => ({
|
|
code,
|
|
label: autonym(code),
|
|
}));
|
|
|
|
export const FALLBACK_LOCALE = 'en-GB';
|