From 1436dafbf29a4aba0c87bfd04896079b7737f9d0 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 24 Feb 2024 09:34:14 +0530 Subject: [PATCH] Support Brazilian Portuguese --- .../Sidebar/Preferences/LanguageSelector.tsx | 2 ++ packages/ui/i18n.ts | 20 +++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/apps/photos/src/components/Sidebar/Preferences/LanguageSelector.tsx b/apps/photos/src/components/Sidebar/Preferences/LanguageSelector.tsx index 15ba2fa9ce..e8f8bf6c28 100644 --- a/apps/photos/src/components/Sidebar/Preferences/LanguageSelector.tsx +++ b/apps/photos/src/components/Sidebar/Preferences/LanguageSelector.tsx @@ -25,6 +25,8 @@ export const localeName = (locale: SupportedLocale) => { return 'Nederlands'; case 'es-ES': return 'EspaƱol'; + case 'pt-BR': + return 'Brazilian Portuguese'; } }; diff --git a/packages/ui/i18n.ts b/packages/ui/i18n.ts index 82530c9535..29906fdda6 100644 --- a/packages/ui/i18n.ts +++ b/packages/ui/i18n.ts @@ -5,7 +5,6 @@ import { isDevBuild } from "@/utils/env"; import { getUserLocales } from "get-user-locale"; import { includes } from "@/utils/type-guards"; import { - type LSKey, getLSString, setLSString, removeLSString, @@ -31,6 +30,7 @@ export const supportedLocales = [ "zh-CN" /* Simplified Chinese */, "nl-NL" /* Dutch */, "es-ES" /* Spanish */, + "pt-BR" /* Portuguese, Brazilian */, ] as const; /** The type of {@link supportedLocales}. */ @@ -193,21 +193,25 @@ const closestSupportedLocale = ( const ss = savedLocaleString; if (ss && includes(supportedLocales, ss)) return ss; - for (const us of getUserLocales()) { + for (const ls of getUserLocales()) { // Exact match - if (us && includes(supportedLocales, us)) return us; + if (ls && includes(supportedLocales, ls)) return ls; // Language match - if (us.startsWith("en")) { + if (ls.startsWith("en")) { return "en-US"; - } else if (us.startsWith("fr")) { + } else if (ls.startsWith("fr")) { return "fr-FR"; - } else if (us.startsWith("zh")) { + } else if (ls.startsWith("zh")) { return "zh-CN"; - } else if (us.startsWith("nl")) { + } else if (ls.startsWith("nl")) { return "nl-NL"; - } else if (us.startsWith("es")) { + } else if (ls.startsWith("es")) { return "es-ES"; + } else if (ls.startsWith("pt-BR")) { + // We'll never get here (it'd already be an exact match), just kept + // to keep this list consistent. + return "pt-BR"; } }