You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
1.9 KiB
94 lines
1.9 KiB
// ui18.ts
|
|
|
|
export type SupportedLocale =
|
|
| 'es' // Español
|
|
| 'en' // English
|
|
| 'de' // Deutsch
|
|
| 'fr' // Français
|
|
| 'it' // Italiano
|
|
| 'pt' // Português
|
|
| 'ca' // Català
|
|
| 'eu' // Euskara
|
|
| 'gl'; // Galego
|
|
|
|
|
|
|
|
/**
|
|
* Locale por defecto del sistema
|
|
*/
|
|
export const DEFAULT_LOCALE: SupportedLocale = 'es';
|
|
|
|
/**
|
|
* Lista de todos los locales soportados
|
|
*/
|
|
export const SUPPORTED_LOCALES: readonly SupportedLocale[] = [
|
|
'es',
|
|
'en',
|
|
'de',
|
|
'fr',
|
|
'it',
|
|
'pt',
|
|
'ca',
|
|
'eu',
|
|
'gl'
|
|
] as const;
|
|
|
|
|
|
// ============================================================================
|
|
// I18N STRING TYPES
|
|
// ============================================================================
|
|
|
|
/**
|
|
* Objeto con traducciones tipadas
|
|
* Garantiza que al menos existe el locale por defecto
|
|
*/
|
|
export type I18nTranslations = {
|
|
[K in SupportedLocale]?: string;
|
|
} & {
|
|
[DEFAULT_LOCALE]: string; // Español es obligatorio
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
* String internacionalizable
|
|
*
|
|
* Puede ser:
|
|
* - `string`: Texto simple (mismo en todos los idiomas)
|
|
* - `I18nTranslations`: Objeto con traducciones por locale
|
|
*
|
|
* @example
|
|
* // Simple (mismo en todos los idiomas)
|
|
* const label: I18nString = "OK";
|
|
*
|
|
* // Con traducciones
|
|
* const greeting: I18nString = {
|
|
* es: "Hola",
|
|
* en: "Hello",
|
|
* de: "Hallo"
|
|
* };
|
|
*
|
|
* // Solo español (obligatorio) + algún otro
|
|
* const name: I18nString = {
|
|
* es: "Configuración",
|
|
* en: "Configuration"
|
|
* };
|
|
*/
|
|
export type I18nString = string | I18nTranslations;
|
|
|
|
|
|
// ============================================================================
|
|
// LOCALE METADATA
|
|
// ============================================================================
|
|
|
|
/**
|
|
* Información sobre un locale
|
|
*/
|
|
export interface LocaleInfo {
|
|
code: SupportedLocale;
|
|
name: string;
|
|
nativeName: string;
|
|
flag: string;
|
|
rtl?: boolean;
|
|
}
|