1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-11 00:02:28 -04:00

i18n: decouple time and language locale

fixes #1876
This commit is contained in:
bbedward
2026-03-01 15:17:15 -05:00
parent f4a10de790
commit db53a9a719
5 changed files with 349 additions and 114 deletions

View File

@@ -1,5 +1,6 @@
pragma Singleton
pragma ComponentBehavior: Bound
import QtQuick
import Qt.labs.folderlistmodel
import Quickshell
@@ -24,7 +25,9 @@ Singleton {
readonly property url translationsFolder: Qt.resolvedUrl("../translations/poexports")
readonly property alias folder: dir.folder
property var presentLocales: ({ "en": Qt.locale("en") })
property var presentLocales: ({
"en": Qt.locale("en")
})
property var translations: ({})
property bool translationsLoaded: false
@@ -65,7 +68,9 @@ Singleton {
}
function locale() {
return presentLocales[_resolvedLocale] ?? presentLocales["en"];
if (SessionData.timeLocale)
return Qt.locale(SessionData.timeLocale);
return Qt.locale();
}
function _loadPresentLocales() {
@@ -84,7 +89,8 @@ Singleton {
function _pickTranslation() {
for (let i = 0; i < _candidates.length; i++) {
const cand = _candidates[i];
if (presentLocales[cand] === undefined) continue;
if (presentLocales[cand] === undefined)
continue;
_resolvedLocale = cand;
useLocale(cand, cand.startsWith("en") ? "" : translationsFolder + "/" + cand + ".json");
return;

View File

@@ -129,6 +129,7 @@ Singleton {
property var hiddenInputDeviceNames: []
property string locale: ""
property string timeLocale: ""
property string launcherLastMode: "all"
property string appDrawerLastMode: "apps"

View File

@@ -80,6 +80,7 @@ var SPEC = {
hiddenInputDeviceNames: { def: [] },
locale: { def: "", onChange: "updateLocale" },
timeLocale: { def: "" },
launcherLastMode: { def: "all" },
appDrawerLastMode: { def: "apps" },