feat: add pt-BR localization support and locale option (#797)

This commit is contained in:
André Mácola 2026-06-05 22:15:09 -03:00 committed by GitHub
parent 5581205c4d
commit 11a6a59eb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 1924 additions and 2 deletions

View File

@ -2,20 +2,21 @@ import { createI18n } from "vue-i18n";
import zhCN from "./locales/zh-CN";
import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/safeStorage";
export type Locale = "en" | "es" | "it" | "zh-CN" | "zh-TW";
export type Locale = "en" | "es" | "it" | "pt-BR" | "zh-CN" | "zh-TW";
type LocaleMessages = Record<string, unknown>;
type I18nGlobal = {
locale: { value: Locale };
setLocaleMessage: (locale: Locale, messages: LocaleMessages) => void;
};
const supportedLocales: Locale[] = ["en", "es", "it", "zh-CN", "zh-TW"];
const supportedLocales: Locale[] = ["en", "es", "it", "pt-BR", "zh-CN", "zh-TW"];
const defaultLocale: Locale = "zh-CN";
const loadedLocales = new Set<Locale>([defaultLocale]);
const localeLoaders: Record<Exclude<Locale, "zh-CN">, () => Promise<{ default: LocaleMessages }>> = {
en: () => import("./locales/en"),
es: () => import("./locales/es"),
it: () => import("./locales/it"),
"pt-BR": () => import("./locales/pt-BR"),
"zh-TW": () => import("./locales/zh-TW"),
};
@ -43,6 +44,7 @@ export function localeFromLanguageTag(value: string | null | undefined): Locale
if (normalized === "en" || normalized.startsWith("en-")) return "en";
if (normalized === "es" || normalized.startsWith("es-")) return "es";
if (normalized === "it" || normalized.startsWith("it-")) return "it";
if (normalized === "pt" || normalized.startsWith("pt-")) return "pt-BR";
return null;
}

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@ export const LOCALE_OPTIONS: { value: Locale; flag: string; label: string }[] =
{ value: "en", flag: "🇺🇸", label: "English" },
{ value: "es", flag: "🇪🇸", label: "Español" },
{ value: "it", flag: "🇮🇹", label: "Italiano" },
{ value: "pt-BR", flag: "🇧🇷", label: "Português" },
{ value: "zh-CN", flag: "🇨🇳", label: "简体中文" },
{ value: "zh-TW", flag: "繁", label: "繁體中文" },
];