diff --git a/src/i18n/intl.ts b/src/i18n/intl.ts index 9324c36..643d471 100644 --- a/src/i18n/intl.ts +++ b/src/i18n/intl.ts @@ -1,56 +1,58 @@ import GLib from "gi://GLib?version=2.0"; - const i18nKeys = { - "en_US": (await import("./lang/en_US")).default, - "pt_BR": (await import("./lang/pt_BR")).default, - "ru_RU": (await import("./lang/ru_RU")).default + en_US: (await import("./lang/en_US")).default, + fr_FR: (await import("./lang/fr_FR")).default, + fr_BE: (await import("./lang/fr_FR")).default, + pt_BR: (await import("./lang/pt_BR")).default, + ru_RU: (await import("./lang/ru_RU")).default, }; const languages: Array = Object.keys(i18nKeys); let language: string = getSystemLanguage(); - +console.log(language); export function getSystemLanguage(): string { - const sysLanguage: (string|null|undefined) = GLib.getenv("LANG") ?? GLib.getenv("LANGUAGE"), - splitted: Array|undefined = sysLanguage?.split('.'); + const sysLanguage: string | null | undefined = + GLib.getenv("LANG") ?? GLib.getenv("LANGUAGE"), + splitted: Array | undefined = sysLanguage?.split("."); - if(!splitted || !languages.includes(splitted![0])) { - console.warn(`Intl: Falling back to default \`${languages[0]}\``); - return languages[0]; - } + if (!splitted || !languages.includes(splitted![0])) { + console.warn(`Intl: Falling back to default \`${languages[0]}\``); + return languages[0]; + } - return splitted![0]; + return splitted![0]; } export function setLanguage(lang: string): string { - languages.map((cur: string) => { - if(cur === lang) { - language = lang; - return lang; - } - }); + languages.map((cur: string) => { + if (cur === lang) { + language = lang; + return lang; + } + }); - throw new Error(`Intl: couldn't set language: ${lang}`, { - cause: `language ${lang} not found in languages of type ${typeof languages}` - }); + throw new Error(`Intl: couldn't set language: ${lang}`, { + cause: `language ${lang} not found in languages of type ${typeof languages}`, + }); } export function tr(key: string): string { - let result = i18nKeys[language as keyof typeof i18nKeys], - defResult = i18nKeys[languages[0] as keyof typeof i18nKeys]; + let result = i18nKeys[language as keyof typeof i18nKeys], + defResult = i18nKeys[languages[0] as keyof typeof i18nKeys]; - for(const keyString of key.split('.')) { - result = result[keyString as keyof typeof result] as never; - defResult = defResult[keyString as keyof typeof defResult] as never; - } + for (const keyString of key.split(".")) { + result = result[keyString as keyof typeof result] as never; + defResult = defResult[keyString as keyof typeof defResult] as never; + } - return (typeof result == "string") ? - result - : ((typeof defResult == "string") ? - defResult - : "not found / is not of type \"string\""); + return typeof result == "string" + ? result + : typeof defResult == "string" + ? defResult + : 'not found / is not of type "string"'; } export function trGet() { - return i18nKeys[getSystemLanguage() as keyof typeof i18nKeys]; + return i18nKeys[getSystemLanguage() as keyof typeof i18nKeys]; } diff --git a/src/i18n/lang/fr_FR.ts b/src/i18n/lang/fr_FR.ts new file mode 100644 index 0000000..5323bd2 --- /dev/null +++ b/src/i18n/lang/fr_FR.ts @@ -0,0 +1,105 @@ +import { i18nStruct } from "../struct"; + +export default { + language: "Français (France)", + + cancel: "Annuler", + accept: "Ok", + devices: "Appareils", + others: "Autres", + + connected: "Connecté", + disconnected: "Déconnecté", + unknown: "Inconnu", + connecting: "Connexion en cours", + none: "Aucun", + limited: "Limité", + apps: "Applications", + + clear: "Effacer", + + connect: "Se connecter", + disconnect: "Se déconnecter", + copy_to_clipboard: "Copier dans le presse-papiers", + + media: { + play: "Lecture", + pause: "Pause", + next: "Suivant", + previous: "Précédent", + loop: "Boucle", + no_loop: "Pas de boucle", + song_loop: "Répéter le morceau", + shuffle_order: "Lecture aléatoire", + follow_order: "Lecture dans l'ordre", + no_artist: "Aucun artiste", + no_title: "Aucun titre", + }, + control_center: { + tiles: { + enabled: "Activé", + disabled: "Désactivé", + more: "Plus", + + network: { + network: "Réseau", + wireless: "Sans fil", + wired: "Filaire", + }, + recording: { + title: "Enregistrement de l'écran", + disabled_desc: "Démarrer l'enregistrement", + enabled_desc: "Arrêter l'enregistrement", + }, + dnd: { + title: "Ne pas déranger", + }, + night_light: { + title: "Éclairage nocturne", + default_desc: "Fidélité", + }, + }, + pages: { + more_settings: "Plus de paramètres", + sound: { + title: "Son", + description: "Configurer la sortie audio", + }, + microphone: { + title: "Microphone", + description: "Configurer l'entrée audio", + }, + night_light: { + title: "Éclairage nocturne", + description: "Contrôler l'éclairage nocturne et les filtres Gamma", + gamma: "Gamma", + temperature: "Température", + }, + backlight: { + title: "Rétroéclairage", + description: "Contrôler la luminosité de vos écrans", + refresh: "Actualiser les rétroéclairages", + }, + bluetooth: { + title: "Bluetooth", + description: "Gérer les appareils Bluetooth", + new_devices: "Nouveaux appareils", + adapters: "Adaptateurs", + paired_devices: "Appareils appairés", + start_discovering: "Démarrer la recherche", + stop_discovering: "Arrêter la recherche", + untrust_device: "Retirer la confiance", + unpair_device: "Désappairer", + trust_device: "Faire confiance", + pair_device: "Appairer", + }, + network: { + title: "Réseau", + interface: "Interface", + }, + }, + }, + ask_popup: { + title: "Question", + }, +} satisfies i18nStruct; diff --git a/tsconfig.json b/tsconfig.json index f8a1697..11853fa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,9 +8,7 @@ "lib": ["ES2024"], "moduleResolution": "bundler", "skipLibCheck": true, - "types": [ - "./@types" - ], + "types": ["./@types"], "strict": true, "jsx": "react-jsx", "jsxImportSource": "ags/gtk4"