Files
orca/src/shared/ui-language.ts
T
+4 ae64a215a3 Add Brazilian Portuguese UI localization (#31627)
* feat(i18n): add Brazilian Portuguese

* feat(i18n): migrate legacy Portuguese plugin preferences once

Co-authored-by: Jackson Florencio <120382485+Jackson-Florencio@users.noreply.github.com>
Co-authored-by: joaoguilhermesimon-collab <245094637+joaoguilhermesimon-collab@users.noreply.github.com>
Co-authored-by: heslanx <167841364+heslanx@users.noreply.github.com>
Co-authored-by: Janderson Fagner <135186779+janderson-fagner@users.noreply.github.com>
Co-authored-by: Carlos <141033701+eusoucarlosmedeiros@users.noreply.github.com>
Co-authored-by: João Messias Lima Pereira <41351492+joaorura@users.noreply.github.com>
Co-authored-by: oliveiraleandro1981 <46854234+oliveiraleandro1981@users.noreply.github.com>
Co-authored-by: hugolrf <12834009+hugolrf@users.noreply.github.com>
Co-authored-by: Jonathan Oliveira <50607380+eojonathan@users.noreply.github.com>
Co-authored-by: Antenor e Filhos <278213917+antenorefilhos@users.noreply.github.com>
Co-authored-by: Daniel Dias <85655597+DeVFirmino@users.noreply.github.com>
Co-authored-by: Sergio Alexandre de Carvalho <65230046+salexcarvalho@users.noreply.github.com>
Co-authored-by: “Melostack” MeloX <229196278+Melostack@users.noreply.github.com>

* rm design doc

* fix(i18n): complete Brazilian Portuguese catalog

---------

Co-authored-by: Jackson Florencio <120382485+Jackson-Florencio@users.noreply.github.com>
Co-authored-by: joaoguilhermesimon-collab <245094637+joaoguilhermesimon-collab@users.noreply.github.com>
Co-authored-by: heslanx <167841364+heslanx@users.noreply.github.com>
Co-authored-by: Janderson Fagner <135186779+janderson-fagner@users.noreply.github.com>
Co-authored-by: Carlos <141033701+eusoucarlosmedeiros@users.noreply.github.com>
Co-authored-by: João Messias Lima Pereira <41351492+joaorura@users.noreply.github.com>
Co-authored-by: oliveiraleandro1981 <46854234+oliveiraleandro1981@users.noreply.github.com>
Co-authored-by: hugolrf <12834009+hugolrf@users.noreply.github.com>
Co-authored-by: Jonathan Oliveira <50607380+eojonathan@users.noreply.github.com>
Co-authored-by: Antenor e Filhos <278213917+antenorefilhos@users.noreply.github.com>
Co-authored-by: Daniel Dias <85655597+DeVFirmino@users.noreply.github.com>
Co-authored-by: Sergio Alexandre de Carvalho <65230046+salexcarvalho@users.noreply.github.com>
Co-authored-by: “Melostack” MeloX <229196278+Melostack@users.noreply.github.com>
2026-10-21 13:14:08 -07:00

49 lines
1.5 KiB
TypeScript

export const UI_LANGUAGE_SYSTEM = 'system'
export const UI_LANGUAGE_ENGLISH = 'en'
export const UI_LANGUAGE_CHINESE = 'zh'
export const UI_LANGUAGE_KOREAN = 'ko'
export const UI_LANGUAGE_JAPANESE = 'ja'
export const UI_LANGUAGE_SPANISH = 'es'
export const UI_LANGUAGE_FRENCH = 'fr'
export const UI_LANGUAGE_PORTUGUESE = 'pt'
export type BuiltInUiLanguage =
| typeof UI_LANGUAGE_SYSTEM
| typeof UI_LANGUAGE_ENGLISH
| typeof UI_LANGUAGE_CHINESE
| typeof UI_LANGUAGE_KOREAN
| typeof UI_LANGUAGE_JAPANESE
| typeof UI_LANGUAGE_SPANISH
| typeof UI_LANGUAGE_FRENCH
| typeof UI_LANGUAGE_PORTUGUESE
export type PluginUiLanguage = `plugin:${string}`
export type UiLanguage = BuiltInUiLanguage | PluginUiLanguage
const UI_LANGUAGE_VALUES = new Set<BuiltInUiLanguage>([
UI_LANGUAGE_SYSTEM,
UI_LANGUAGE_ENGLISH,
UI_LANGUAGE_CHINESE,
UI_LANGUAGE_KOREAN,
UI_LANGUAGE_JAPANESE,
UI_LANGUAGE_SPANISH,
UI_LANGUAGE_FRENCH,
UI_LANGUAGE_PORTUGUESE
])
const PLUGIN_UI_LANGUAGE_RE =
/^plugin:[a-z0-9]+(?:-[a-z0-9]+)*\.[a-z0-9]+(?:-[a-z0-9]+)*\/[a-z]{2,3}(?:-[a-z0-9]{2,8})*$/i
export function isPluginUiLanguage(value: unknown): value is PluginUiLanguage {
return typeof value === 'string' && PLUGIN_UI_LANGUAGE_RE.test(value)
}
export function normalizeUiLanguage(value: unknown): UiLanguage {
if (isPluginUiLanguage(value)) {
return value
}
return UI_LANGUAGE_VALUES.has(value as BuiltInUiLanguage)
? (value as BuiltInUiLanguage)
: UI_LANGUAGE_SYSTEM
}