mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 12:22:09 +00:00
i18n: removed duplicate translation services and fixed imports
This commit is contained in:
parent
2eff8d6db4
commit
b98e843a9d
40 changed files with 36 additions and 194 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import "root:/modules/common/"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import "root:/services"
|
||||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell.Wayland
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/services"
|
||||
import "root:/"
|
||||
import "root:/modules/common/functions/string_utils.js" as StringUtils
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/services"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/services"
|
||||
import "root:/"
|
||||
import "root:/modules/common/functions/string_utils.js" as StringUtils
|
||||
import "root:/modules/common/functions/file_utils.js" as FileUtils
|
||||
import Qt5Compat.GraphicalEffects
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import "root:/"
|
||||
import "root:/services/"
|
||||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import "root:/"
|
||||
import "root:/services/"
|
||||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import "root:/"
|
|||
import "root:/services"
|
||||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/services/"
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/"
|
||||
import "root:/services/"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/modules/common/functions/color_utils.js" as ColorUtils
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import QtQuick.Layouts
|
|||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Widgets
|
||||
import "root:/"
|
||||
import "root:/services/"
|
||||
import "root:/modules/common/"
|
||||
import "root:/modules/common/widgets/"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import "root:/"
|
||||
import "root:/services/"
|
||||
import "root:/modules/common/"
|
||||
import "root:/modules/common/widgets/"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import "root:/"
|
||||
import "root:/services/"
|
||||
import "root:/modules/common/"
|
||||
import "root:/modules/common/widgets/"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import "root:/"
|
||||
import "root:/services/"
|
||||
import "root:/modules/common/"
|
||||
import "root:/modules/common/widgets/"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import Quickshell
|
|||
import Quickshell.Io
|
||||
import Quickshell.Widgets
|
||||
import Quickshell.Hyprland
|
||||
import "root:/"
|
||||
import "root:/services/"
|
||||
import "root:/modules/common/"
|
||||
import "root:/modules/common/widgets/"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import "root:/"
|
||||
import "root:/services"
|
||||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import "root:/"
|
|||
import "root:/services"
|
||||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/services/"
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/"
|
||||
import "root:/services"
|
||||
import "./calendar"
|
||||
import "./todo"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import "./calendar"
|
|||
import "./notifications"
|
||||
import "./todo"
|
||||
import "./volumeMixer"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import "root:/modules/common/widgets"
|
|||
import "root:/modules/common/functions/string_utils.js" as StringUtils
|
||||
import "root:/modules/common/functions/file_utils.js" as FileUtils
|
||||
import "./quickToggles/"
|
||||
import "root:/services/"
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/"
|
||||
import "root:/modules/common/widgets"
|
||||
import "./calendar_layout.js" as CalendarLayout
|
||||
import QtQuick
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/services"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import "../"
|
||||
import "root:/"
|
||||
import "root:/services"
|
||||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "../"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Hyprland
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "../"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import Quickshell.Io
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import "root:/modules/common"
|
|||
import "root:/modules/common/widgets"
|
||||
import "root:/modules/common/functions/string_utils.js" as StringUtils
|
||||
import "../"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "../"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import Quickshell.Io
|
||||
import Quickshell
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/services"
|
||||
import "root:/"
|
||||
import "root:/modules/common/functions/color_utils.js" as ColorUtils
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/services"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import "root:/services"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//@ pragma Env QT_SCALE_FACTOR=1
|
||||
|
||||
pragma ComponentBehavior: "Bound"
|
||||
import "./"
|
||||
import "./modules/common/"
|
||||
import "./modules/common/widgets"
|
||||
import "./modules/common/functions/string_utils.js" as StringUtils
|
||||
|
|
@ -18,7 +19,6 @@ import Quickshell.Io
|
|||
import Quickshell.Widgets
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
import "./services/"
|
||||
|
||||
ShellRoot {
|
||||
id: root
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ pragma ComponentBehavior: Bound
|
|||
import "root:/modules/common/functions/string_utils.js" as StringUtils
|
||||
import "root:/modules/common/functions/object_utils.js" as ObjectUtils
|
||||
import "root:/modules/common"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import Quickshell;
|
||||
import Quickshell.Io;
|
||||
import Qt.labs.platform
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ pragma Singleton
|
|||
pragma ComponentBehavior: Bound
|
||||
|
||||
import "root:/modules/common"
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import Quickshell;
|
||||
import Quickshell.Io;
|
||||
import Qt.labs.platform
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ pragma ComponentBehavior: Bound
|
|||
// From https://github.com/caelestia-dots/shell/ (`quickshell` branch) with modifications.
|
||||
// License: GPLv3
|
||||
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Hyprland
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import "root:/"
|
||||
import "root:/modules/common"
|
||||
import "root:/modules/common/functions/string_utils.js" as StringUtils
|
||||
import Quickshell;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ pragma ComponentBehavior: Bound
|
|||
// From https://git.outfoxxed.me/outfoxxed/nixnew
|
||||
// It does not have a license, but the author is okay with redistribution.
|
||||
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import QtQml.Models
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
|
|
|
|||
|
|
@ -1,170 +0,0 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "root:/modules/common/"
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property var translations: ({})
|
||||
property string currentLanguage: "en_US"
|
||||
property var availableLanguages: ["en_US"]
|
||||
property bool isScanning: false
|
||||
property bool isLoading: false
|
||||
|
||||
Process {
|
||||
id: scanLanguagesProcess
|
||||
command: ["find", Qt.resolvedUrl(Directories.config + "/quickshell/translations/").toString().replace("file://", ""), "-name", "*.json", "-exec", "basename", "{}", ".json", ";"]
|
||||
running: false
|
||||
|
||||
stdout: SplitParser {
|
||||
onRead: data => {
|
||||
if (data.trim().length === 0) return
|
||||
|
||||
var files = data.trim().split('\n')
|
||||
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var lang = files[i].trim()
|
||||
if (lang.length > 0 && root.availableLanguages.indexOf(lang) === -1) {
|
||||
root.availableLanguages.push(lang)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onExited: (exitCode, exitStatus) => {
|
||||
root.isScanning = false
|
||||
if (exitCode !== 0) {
|
||||
root.availableLanguages = ["en_US"]
|
||||
}
|
||||
root.loadTranslations()
|
||||
}
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: translationFileView
|
||||
onLoaded: {
|
||||
var textContent = ""
|
||||
try {
|
||||
textContent = text()
|
||||
} catch (e) {
|
||||
root.translations = {}
|
||||
root.isLoading = false
|
||||
return
|
||||
}
|
||||
|
||||
if (textContent.length === 0) {
|
||||
root.translations = {}
|
||||
root.isLoading = false
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
var jsonData = JSON.parse(textContent)
|
||||
root.translations = jsonData
|
||||
root.isLoading = false
|
||||
} catch (e) {
|
||||
root.translations = {}
|
||||
root.isLoading = false
|
||||
}
|
||||
}
|
||||
onLoadFailed: (error) => {
|
||||
root.translations = {}
|
||||
root.isLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
function detectSystemLanguage() {
|
||||
var locale = Qt.locale().name
|
||||
return locale
|
||||
}
|
||||
|
||||
function getLanguageCode() {
|
||||
var configLang = "auto"
|
||||
try {
|
||||
configLang = ConfigOptions.language.ui
|
||||
} catch (e) {
|
||||
configLang = "auto"
|
||||
}
|
||||
|
||||
if (configLang === "auto") {
|
||||
return detectSystemLanguage()
|
||||
} else {
|
||||
if (root.availableLanguages.indexOf(configLang) !== -1) {
|
||||
return configLang
|
||||
} else {
|
||||
return detectSystemLanguage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadTranslations() {
|
||||
if (root.isScanning) {
|
||||
return
|
||||
}
|
||||
|
||||
var targetLang = getLanguageCode()
|
||||
root.currentLanguage = targetLang
|
||||
|
||||
// Use empty translations for English (default language)
|
||||
if (targetLang === "en_US" || targetLang === "en") {
|
||||
root.translations = {}
|
||||
return
|
||||
}
|
||||
|
||||
// Check if target language is available
|
||||
if (root.availableLanguages.indexOf(targetLang) === -1) {
|
||||
root.currentLanguage = "en_US"
|
||||
root.translations = {}
|
||||
return
|
||||
}
|
||||
|
||||
// Load translation file
|
||||
root.isLoading = true
|
||||
var translationsPath = Qt.resolvedUrl(Directories.config + "/quickshell/translations/" + targetLang + ".json")
|
||||
translationFileView.path = translationsPath
|
||||
}
|
||||
|
||||
function tr(text) {
|
||||
if (!text) {
|
||||
return ""
|
||||
}
|
||||
|
||||
var key = text.toString()
|
||||
|
||||
if (root.isLoading) {
|
||||
return key
|
||||
}
|
||||
|
||||
if (root.currentLanguage === "en_US" || root.currentLanguage === "en" || !root.translations) {
|
||||
return key
|
||||
}
|
||||
|
||||
if (root.translations.hasOwnProperty(key)) {
|
||||
var translation = root.translations[key]
|
||||
if (translation && translation.toString().trim().length > 0) {
|
||||
return translation.toString()
|
||||
} else {
|
||||
return translation.toString()
|
||||
}
|
||||
}
|
||||
|
||||
return key // Fallback to key name
|
||||
}
|
||||
|
||||
function reloadTranslations() {
|
||||
root.scanLanguages()
|
||||
}
|
||||
|
||||
function scanLanguages() {
|
||||
var translationsDir = Qt.resolvedUrl(Directories.config + "/quickshell/translations/").toString().replace("file://", "")
|
||||
root.isScanning = true
|
||||
scanLanguagesProcess.running = true
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
root.scanLanguages()
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ import QtQuick.Window
|
|||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Hyprland
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import "root:/modules/common/"
|
||||
import "root:/modules/common/widgets/"
|
||||
import "root:/modules/common/functions/color_utils.js" as ColorUtils
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import QtQuick.Window
|
|||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Hyprland
|
||||
import "root:/services/"
|
||||
import "root:/"
|
||||
import "root:/modules/common/"
|
||||
import "root:/modules/common/widgets/"
|
||||
import "root:/modules/common/functions/color_utils.js" as ColorUtils
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ def clean_translation_files(translations_dir: str, source_dir: str, backup: bool
|
|||
|
||||
if backup:
|
||||
# Create backup
|
||||
backup_file = Path(translations_dir) / f"{lang}.json.backup"
|
||||
backup_file = Path(translations_dir) / f"{lang}.json.bak"
|
||||
with open(backup_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(translations, f, ensure_ascii=False, indent=2)
|
||||
print(f"Created backup: {backup_file}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue