diff --git a/.config/quickshell/ii/Translation.qml b/.config/quickshell/ii/Translation.qml index 3cfdce116..f579cef65 100644 --- a/.config/quickshell/ii/Translation.qml +++ b/.config/quickshell/ii/Translation.qml @@ -84,7 +84,7 @@ Singleton { function getLanguageCode() { var configLang = "auto" try { - configLang = ConfigOptions.language.ui + configLang = Config.options.language.ui } catch (e) { configLang = "auto" } diff --git a/.config/quickshell/ii/modules/common/Config.qml b/.config/quickshell/ii/modules/common/Config.qml index 25c9ab23f..35b125cd5 100644 --- a/.config/quickshell/ii/modules/common/Config.qml +++ b/.config/quickshell/ii/modules/common/Config.qml @@ -215,6 +215,7 @@ Singleton { } property JsonObject language: JsonObject { + property string ui: "auto" // UI language. "auto" for system locale, or specific language code like "zh_CN", "en_US" property JsonObject translator: JsonObject { property string engine: "auto" // Run `trans -list-engines` for available engines. auto should use google property string targetLanguage: "auto" // Run `trans -list-all` for available languages diff --git a/.config/quickshell/ii/modules/settings/InterfaceConfig.qml b/.config/quickshell/ii/modules/settings/InterfaceConfig.qml index 5fa784dce..296c2d5e9 100644 --- a/.config/quickshell/ii/modules/settings/InterfaceConfig.qml +++ b/.config/quickshell/ii/modules/settings/InterfaceConfig.qml @@ -465,4 +465,74 @@ ContentPage { } } } + ContentSection { + title: Translation.tr("Language") + + ContentSubsection { + title: Translation.tr("Interface Language") + tooltip: Translation.tr("Select the language for the user interface.\n\"Auto\" will use your system's locale.") + + ConfigSelectionArray { + id: languageSelector + currentValue: Config.options.language.ui + configOptionName: "language.ui" + onSelected: newValue => { + Config.options.language.ui = newValue; + reloadNotice.visible = true; + } + options: { + var baseOptions = [ + { + displayName: Translation.tr("Auto (System)"), + value: "auto" + } + ]; + + // Generate language options from available languages + // Intl.DisplayNames is not used. Show the language code with underscore replaced by hyphen. + for (var i = 0; i < Translation.availableLanguages.length; i++) { + var lang = Translation.availableLanguages[i]; + var displayName = lang.replace('_', '-'); + baseOptions.push({ displayName: displayName, value: lang }); + } + + return baseOptions; + } + } + + Rectangle { + id: reloadNotice + visible: false + Layout.fillWidth: true + Layout.topMargin: 8 + height: noticeText.implicitHeight + 16 + radius: 8 + color: Appearance.m3colors.m3secondaryContainer + border.color: Appearance.m3colors.m3outline + border.width: 1 + + Row { + anchors.fill: parent + anchors.margins: 8 + spacing: 8 + + MaterialSymbol { + anchors.verticalCenter: parent.verticalCenter + text: "info" + iconSize: 20 + color: Appearance.m3colors.m3onSecondaryContainer + } + + StyledText { + id: noticeText + anchors.verticalCenter: parent.verticalCenter + width: parent.width - 36 + text: Translation.tr("Language setting saved. Please restart the quickshell to apply the new language.") + color: Appearance.m3colors.m3onSecondaryContainer + wrapMode: Text.WordWrap + } + } + } + } + } } diff --git a/.config/quickshell/translations/zh_CN.json b/.config/quickshell/translations/zh_CN.json index 229a38096..a7b54fe09 100644 --- a/.config/quickshell/translations/zh_CN.json +++ b/.config/quickshell/translations/zh_CN.json @@ -393,5 +393,10 @@ "Lap": "计时", "Welcome app": "欢迎应用", "Corner style": "角落样式", - "Bar layout": "条栏布局" + "Bar layout": "条栏布局", + "Language": "语言", + "Select the language for the user interface.\n\"Auto\" will use your system's locale.": "选择用户界面的语言。\n\"自动\" 将使用系统语言环境。", + "Language setting saved. Please restart the quickshell to apply the new language.": "语言设置已保存。请重启 quickshell 以应用新语言。", + "Auto (System)": "自动(系统)", + "Interface Language": "界面语言" } \ No newline at end of file