Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | 13x 13x 13x 13x 22007x 22007x 13x 367x | // SPDX-FileCopyrightText: 2024-2026 Hack23 AB
// SPDX-License-Identifier: Apache-2.0
/**
* @module Constants/LanguageCore
* @description Core language data โ codes, flags, names, presets, and utility functions.
*
* Languages: en, sv, da, no, fi, de, fr, es, nl, ar, he, ja, ko, zh
*/
import type { LanguageCode, LanguageMap, LanguagePreset } from '../types/index.js';
/** All supported language codes */
export const ALL_LANGUAGES: readonly LanguageCode[] = [
'en',
'sv',
'da',
'no',
'fi',
'de',
'fr',
'es',
'nl',
'ar',
'he',
'ja',
'ko',
'zh',
] as const;
/** Language presets for quick selection */
export const LANGUAGE_PRESETS: Record<LanguagePreset, readonly LanguageCode[]> = {
all: ALL_LANGUAGES,
'eu-core': ['en', 'de', 'fr', 'es', 'nl'],
nordic: ['en', 'sv', 'da', 'no', 'fi'],
};
/** Language flags for display */
export const LANGUAGE_FLAGS: LanguageMap = {
en: '๐ฌ๐ง',
sv: '๐ธ๐ช',
da: '๐ฉ๐ฐ',
no: '๐ณ๐ด',
fi: '๐ซ๐ฎ',
de: '๐ฉ๐ช',
fr: '๐ซ๐ท',
es: '๐ช๐ธ',
nl: '๐ณ๐ฑ',
ar: '๐ธ๐ฆ',
he: '๐ฎ๐ฑ',
ja: '๐ฏ๐ต',
ko: '๐ฐ๐ท',
zh: '๐จ๐ณ',
};
/** Native language names */
export const LANGUAGE_NAMES: LanguageMap = {
en: 'English',
sv: 'Svenska',
da: 'Dansk',
no: 'Norsk',
fi: 'Suomi',
de: 'Deutsch',
fr: 'Franรงais',
es: 'Espaรฑol',
nl: 'Nederlands',
ar: 'ุงูุนุฑุจูุฉ',
he: 'ืขืืจืืช',
ja: 'ๆฅๆฌ่ช',
ko: 'ํ๊ตญ์ด',
zh: 'ไธญๆ',
};
/**
* Get a language-specific string with English fallback
*
* @param map - Language map to look up
* @param lang - Language code
* @returns The language-specific value or English fallback
*/
export function getLocalizedString<T>(map: LanguageMap<T>, lang: string): T {
const code = lang as LanguageCode;
return map[code] ?? map.en;
}
/**
* Check if a language code is supported
*
* @param lang - Language code to check
* @returns True if the language is supported
*/
export function isSupportedLanguage(lang: string): lang is LanguageCode {
return ALL_LANGUAGES.includes(lang as LanguageCode);
}
/**
* Determine text direction for a language
*
* @param lang - Language code
* @returns 'rtl' for Arabic/Hebrew, 'ltr' otherwise
*/
export function getTextDirection(lang: string): 'ltr' | 'rtl' {
return lang === 'ar' || lang === 'he' ? 'rtl' : 'ltr';
}
|