activity, capabilities, chat history and the locale picker (21 -> 2)
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.
This commit is contained in:
@@ -6,9 +6,22 @@
|
||||
*/
|
||||
export type ShippedLocale = { code: string; label: string };
|
||||
|
||||
export const SHIPPED_LOCALES: ShippedLocale[] = [
|
||||
{ code: 'en-GB', label: 'English (UK)' },
|
||||
{ code: 'pt-PT', label: 'Português (Portugal)' },
|
||||
];
|
||||
/**
|
||||
* 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';
|
||||
|
||||
Reference in New Issue
Block a user