🌐 i18n: add french locales for france and belgium

french is now available in colorshell thanks to @Elgemp4 in #19!!
This commit is contained in:
João Dias
2025-10-31 14:12:57 -03:00
committed by GitHub
3 changed files with 140 additions and 35 deletions
+17 -15
View File
@@ -1,20 +1,22 @@
import GLib from "gi://GLib?version=2.0"; import GLib from "gi://GLib?version=2.0";
const i18nKeys = { const i18nKeys = {
"en_US": (await import("./lang/en_US")).default, en_US: (await import("./lang/en_US")).default,
"pt_BR": (await import("./lang/pt_BR")).default, fr_FR: (await import("./lang/fr_FR")).default,
"ru_RU": (await import("./lang/ru_RU")).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<string> = Object.keys(i18nKeys); const languages: Array<string> = Object.keys(i18nKeys);
let language: string = getSystemLanguage(); let language: string = getSystemLanguage();
export function getSystemLanguage(): string { export function getSystemLanguage(): string {
const sysLanguage: (string|null|undefined) = GLib.getenv("LANG") ?? GLib.getenv("LANGUAGE"), const sysLanguage: string | null | undefined =
splitted: Array<string>|undefined = sysLanguage?.split('.'); GLib.getenv("LANG") ?? GLib.getenv("LANGUAGE"),
splitted: Array<string> | undefined = sysLanguage?.split(".");
if(!splitted || !languages.includes(splitted![0])) { if (!splitted || !languages.includes(splitted![0])) {
console.warn(`Intl: Falling back to default \`${languages[0]}\``); console.warn(`Intl: Falling back to default \`${languages[0]}\``);
return languages[0]; return languages[0];
} }
@@ -24,14 +26,14 @@ export function getSystemLanguage(): string {
export function setLanguage(lang: string): string { export function setLanguage(lang: string): string {
languages.map((cur: string) => { languages.map((cur: string) => {
if(cur === lang) { if (cur === lang) {
language = lang; language = lang;
return lang; return lang;
} }
}); });
throw new Error(`Intl: couldn't set language: ${lang}`, { throw new Error(`Intl: couldn't set language: ${lang}`, {
cause: `language ${lang} not found in languages of type ${typeof languages}` cause: `language ${lang} not found in languages of type ${typeof languages}`,
}); });
} }
@@ -39,16 +41,16 @@ export function tr(key: string): string {
let result = i18nKeys[language as keyof typeof i18nKeys], let result = i18nKeys[language as keyof typeof i18nKeys],
defResult = i18nKeys[languages[0] as keyof typeof i18nKeys]; defResult = i18nKeys[languages[0] as keyof typeof i18nKeys];
for(const keyString of key.split('.')) { for (const keyString of key.split(".")) {
result = result[keyString as keyof typeof result] as never; result = result[keyString as keyof typeof result] as never;
defResult = defResult[keyString as keyof typeof defResult] as never; defResult = defResult[keyString as keyof typeof defResult] as never;
} }
return (typeof result == "string") ? return typeof result == "string"
result ? result
: ((typeof defResult == "string") ? : typeof defResult == "string"
defResult ? defResult
: "not found / is not of type \"string\""); : 'not found / is not of type "string"';
} }
export function trGet() { export function trGet() {
+105
View File
@@ -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;
+1 -3
View File
@@ -8,9 +8,7 @@
"lib": ["ES2024"], "lib": ["ES2024"],
"moduleResolution": "bundler", "moduleResolution": "bundler",
"skipLibCheck": true, "skipLibCheck": true,
"types": [ "types": ["./@types"],
"./@types"
],
"strict": true, "strict": true,
"jsx": "react-jsx", "jsx": "react-jsx",
"jsxImportSource": "ags/gtk4" "jsxImportSource": "ags/gtk4"