✨ chore: restructure the project, make it not use the astal application stuff
now it's more organized and I have more control over the shell behaviour
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
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
|
||||
};
|
||||
|
||||
const languages: Array<string> = Object.keys(i18nKeys);
|
||||
let language: string = getSystemLanguage();
|
||||
|
||||
export function getSystemLanguage(): string {
|
||||
const sysLanguage: (string|null|undefined) = GLib.getenv("LANG") || GLib.getenv("LANGUAGE");
|
||||
|
||||
if(!sysLanguage) {
|
||||
console.warn(`Intl: Couldn't get system language, fallback to default ${languages[0]}`);
|
||||
console.log("Intl: Please set the LANG or LANGUAGE environment variable");
|
||||
|
||||
return languages[0];
|
||||
}
|
||||
|
||||
return sysLanguage.split('.')[0];
|
||||
}
|
||||
|
||||
export function setLanguage(lang: string): string {
|
||||
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}`
|
||||
});
|
||||
}
|
||||
|
||||
export function tr(key: string): string {
|
||||
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;
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import { i18nStruct } from "../struct";
|
||||
|
||||
export default {
|
||||
language: "English (United States)",
|
||||
|
||||
cancel: "Cancel",
|
||||
accept: "Ok",
|
||||
devices: "Devices",
|
||||
others: "Others",
|
||||
|
||||
connected: "Connected",
|
||||
disconnected: "Disconnected",
|
||||
unknown: "Unknown",
|
||||
connecting: "Connecting",
|
||||
none: "None",
|
||||
limited: "Limited",
|
||||
apps: "Applications",
|
||||
|
||||
clear: "Clear",
|
||||
|
||||
connect: "Connect",
|
||||
disconnect: "Disconnect",
|
||||
|
||||
control_center: {
|
||||
tiles: {
|
||||
enabled: "Enabled",
|
||||
disabled: "Disabled",
|
||||
more: "More",
|
||||
|
||||
network: {
|
||||
network: "Network",
|
||||
wireless: "Wireless",
|
||||
wired: "Wired"
|
||||
},
|
||||
recording: {
|
||||
title: "Screen Recording",
|
||||
disabled_desc: "Start recording",
|
||||
enabled_desc: "Stop recording",
|
||||
},
|
||||
dnd: {
|
||||
title: "Do Not Disturb"
|
||||
},
|
||||
night_light: {
|
||||
title: "Night Light",
|
||||
default_desc: "Fidelity"
|
||||
}
|
||||
},
|
||||
pages: {
|
||||
more_settings: "More settings",
|
||||
sound: {
|
||||
title: "Sound",
|
||||
description: "Configure the audio output"
|
||||
},
|
||||
microphone: {
|
||||
title: "Microphone",
|
||||
description: "Configure the audio input"
|
||||
},
|
||||
night_light: {
|
||||
title: "Night Light",
|
||||
description: "Control Night Light and Gamma filters",
|
||||
gamma: "Gamma",
|
||||
temperature: "Temperature"
|
||||
},
|
||||
bluetooth: {
|
||||
title: "Bluetooth",
|
||||
description: "Manage Bluetooth devices",
|
||||
new_devices: "New devices",
|
||||
adapters: "Adapters",
|
||||
paired_devices: "Paired Devices",
|
||||
start_discovering: "Start discovering",
|
||||
stop_discovering: "Stop discovering",
|
||||
untrust_device: "Untrust device",
|
||||
unpair_device: "Unpair device",
|
||||
trust_device: "Trust device",
|
||||
pair_device: "Pair device"
|
||||
},
|
||||
network: {
|
||||
title: "Network",
|
||||
interface: "Interface"
|
||||
}
|
||||
}
|
||||
},
|
||||
ask_popup: {
|
||||
title: "Question"
|
||||
}
|
||||
} as i18nStruct;
|
||||
@@ -0,0 +1,86 @@
|
||||
import { i18nStruct } from "../struct";
|
||||
|
||||
export default {
|
||||
language: "Português (Brasil)",
|
||||
|
||||
cancel: "Cancelar",
|
||||
accept: "Ok",
|
||||
devices: "Dispositivos",
|
||||
others: "Outros",
|
||||
|
||||
connected: "Conectado",
|
||||
disconnected: "Desconectado",
|
||||
unknown: "Desconhecido",
|
||||
connecting: "Conectando",
|
||||
limited: "Limitado",
|
||||
none: "Nenhum",
|
||||
|
||||
disconnect: "Desconectar",
|
||||
connect: "Conectar",
|
||||
|
||||
apps: "Aplicativos",
|
||||
clear: "Limpar",
|
||||
|
||||
control_center: {
|
||||
tiles: {
|
||||
enabled: "Ligado",
|
||||
disabled: "Desligado",
|
||||
more: "Mais",
|
||||
|
||||
network: {
|
||||
network: "Rede",
|
||||
wireless: "Wi-Fi",
|
||||
wired: "Cabeada"
|
||||
},
|
||||
recording: {
|
||||
title: "Gravação de Tela",
|
||||
disabled_desc: "Iniciar gravação",
|
||||
enabled_desc: "Parar gravação",
|
||||
},
|
||||
dnd: {
|
||||
title: "Não Perturbe"
|
||||
},
|
||||
night_light: {
|
||||
title: "Luz Noturna",
|
||||
default_desc: "Fidelidade"
|
||||
}
|
||||
},
|
||||
pages: {
|
||||
more_settings: "Mais configurações",
|
||||
sound: {
|
||||
title: "Som",
|
||||
description: "Controle a saída de áudio"
|
||||
},
|
||||
microphone: {
|
||||
title: "Microfone",
|
||||
description: "Configure a entrada de áudio"
|
||||
},
|
||||
night_light: {
|
||||
title: "Luz Noturna",
|
||||
description: "Controle os filtros de Luz Noturna e Gama",
|
||||
temperature: "Temperatura",
|
||||
gamma: "Gama"
|
||||
},
|
||||
bluetooth: {
|
||||
title: "Bluetooth",
|
||||
description: "Gerencie dispositivos Bluetooth",
|
||||
new_devices: "Novos Dispositivos",
|
||||
adapters: "Adaptadores",
|
||||
paired_devices: "Dispositivos Pareados",
|
||||
start_discovering: "Começar a procurar dispositivos",
|
||||
stop_discovering: "Parar de procurar dispositivos",
|
||||
pair_device: "Parear dispositivo",
|
||||
trust_device: "Confiar no dispositivo",
|
||||
unpair_device: "Desparear dispositivo",
|
||||
untrust_device: "Deixar de confiar no dispositivo"
|
||||
},
|
||||
network: {
|
||||
title: "Rede",
|
||||
interface: "Interface"
|
||||
}
|
||||
}
|
||||
},
|
||||
ask_popup: {
|
||||
title: "Pergunta"
|
||||
}
|
||||
} as i18nStruct;
|
||||
@@ -0,0 +1,86 @@
|
||||
import { i18nStruct } from "../struct";
|
||||
|
||||
export default {
|
||||
language: "Русский (Российская Федерация)",
|
||||
|
||||
cancel: "Отменить",
|
||||
accept: "Ок",
|
||||
devices: "Устройства",
|
||||
others: "Другие",
|
||||
|
||||
connected: "Подключён",
|
||||
disconnected: "Отключён",
|
||||
unknown: "Неизвестный",
|
||||
connecting: "Подключение",
|
||||
none: "Ничего",
|
||||
limited: "Ограничен",
|
||||
apps: "Приложения",
|
||||
|
||||
clear: "Очистить",
|
||||
|
||||
connect: "Подключиться",
|
||||
disconnect: "Отключиться",
|
||||
|
||||
control_center: {
|
||||
tiles: {
|
||||
enabled: "Включить",
|
||||
disabled: "Отключить",
|
||||
more: "Больше",
|
||||
|
||||
network: {
|
||||
network: "Инетрнет",
|
||||
wireless: "Беспроводное",
|
||||
wired: "Проводное"
|
||||
},
|
||||
recording: {
|
||||
title: "Запись экрана",
|
||||
disabled_desc: "Начать запись",
|
||||
enabled_desc: "Остановить запись",
|
||||
},
|
||||
dnd: {
|
||||
title: "Не беспокоить"
|
||||
},
|
||||
night_light: {
|
||||
title: "Ночной свет",
|
||||
default_desc: "Тонн"
|
||||
}
|
||||
},
|
||||
pages: {
|
||||
more_settings: "Больше настроек",
|
||||
sound: {
|
||||
title: "Звук",
|
||||
description: "Настройка вывода звука"
|
||||
},
|
||||
microphone: {
|
||||
title: "Микрофон",
|
||||
description: "Настройка ввода звука"
|
||||
},
|
||||
night_light: {
|
||||
title: "Ночной свет",
|
||||
description: "Контроль интенсивности фильтрации синего света",
|
||||
gamma: "Гамма",
|
||||
temperature: "Температура"
|
||||
},
|
||||
bluetooth: {
|
||||
title: "Bluetooth",
|
||||
description: "Управление Bluetooth устройствами",
|
||||
new_devices: "Новые устройства",
|
||||
adapters: "Адапреты",
|
||||
paired_devices: "Привязанные устройства",
|
||||
start_discovering: "Начать поиск",
|
||||
stop_discovering: "Остановить поиск",
|
||||
untrust_device: "Недоверенное устройство",
|
||||
unpair_device: "Отвязанное устройство",
|
||||
trust_device: "Доверенное устройство",
|
||||
pair_device: "Привязанное устройство"
|
||||
},
|
||||
network: {
|
||||
title: "Интернет",
|
||||
interface: "Интерфейсы"
|
||||
}
|
||||
}
|
||||
},
|
||||
ask_popup: {
|
||||
title: "Вопрос"
|
||||
}
|
||||
} as i18nStruct;
|
||||
@@ -0,0 +1,86 @@
|
||||
export type i18nStruct = {
|
||||
language: string,
|
||||
|
||||
cancel: string,
|
||||
accept: string,
|
||||
|
||||
connected: string,
|
||||
disconnected: string,
|
||||
connecting: string,
|
||||
unknown: string,
|
||||
none: string,
|
||||
limited: string,
|
||||
|
||||
devices: string,
|
||||
others: string,
|
||||
|
||||
disconnect: string,
|
||||
connect: string,
|
||||
|
||||
apps: string;
|
||||
clear: string;
|
||||
|
||||
control_center: {
|
||||
tiles: {
|
||||
enabled: string,
|
||||
disabled: string,
|
||||
more: string,
|
||||
|
||||
network: {
|
||||
network: string,
|
||||
wireless: string,
|
||||
wired: string
|
||||
},
|
||||
recording: {
|
||||
title: string,
|
||||
disabled_desc: string,
|
||||
enabled_desc: string
|
||||
},
|
||||
dnd: {
|
||||
title: string
|
||||
},
|
||||
night_light: {
|
||||
title: string,
|
||||
default_desc: string
|
||||
}
|
||||
},
|
||||
pages: {
|
||||
more_settings: string,
|
||||
|
||||
sound: {
|
||||
title: string,
|
||||
description: string
|
||||
},
|
||||
microphone: {
|
||||
title: string,
|
||||
description: string
|
||||
},
|
||||
network: {
|
||||
title: string,
|
||||
interface: string
|
||||
},
|
||||
bluetooth: {
|
||||
title: string,
|
||||
description: string,
|
||||
adapters: string,
|
||||
new_devices: string,
|
||||
paired_devices: string,
|
||||
start_discovering: string,
|
||||
stop_discovering: string,
|
||||
trust_device: string,
|
||||
untrust_device: string,
|
||||
pair_device: string,
|
||||
unpair_device: string
|
||||
},
|
||||
night_light: {
|
||||
title: string,
|
||||
description: string,
|
||||
temperature: string,
|
||||
gamma: string
|
||||
}
|
||||
}
|
||||
},
|
||||
ask_popup: {
|
||||
title: string
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user