diff --git a/Sources/VoilyApp/App/AppController.swift b/Sources/VoilyApp/App/AppController.swift index 7c5dd69..3b1ed70 100644 --- a/Sources/VoilyApp/App/AppController.swift +++ b/Sources/VoilyApp/App/AppController.swift @@ -180,6 +180,10 @@ final class AppController: NSObject { injectedASRCaptureSessionFactory ?? defaultASRCaptureSessionFactory } + var appSettings: AppSettings { + settings + } + init( windowActions: WindowActions, appUpdater: AppUpdater = AppUpdater(), diff --git a/Sources/VoilyApp/App/VoilyApp.swift b/Sources/VoilyApp/App/VoilyApp.swift index 19b3fac..909d7f2 100644 --- a/Sources/VoilyApp/App/VoilyApp.swift +++ b/Sources/VoilyApp/App/VoilyApp.swift @@ -11,21 +11,34 @@ struct VoilyApp: App { } .defaultSize(width: 1120, height: 760) .commands { - SettingsWindowCommands(appController: appDelegate.appController) + SettingsWindowCommands( + appController: appDelegate.appController, + settings: appDelegate.appController.appSettings + ) } } } +enum SettingsCommandLocalization { + static func settingsTitle(languageCode: String) -> String { + AppLocalization.localized("Settings...", languageCode: languageCode) + } +} + private struct SettingsWindowCommands: Commands { let appController: AppController + let settings: AppSettings @Environment(\.openWindow) private var openWindow var body: some Commands { registerOpenSettingsWindowAction() + let settingsTitle = SettingsCommandLocalization.settingsTitle( + languageCode: settings.appInterfaceLanguageCode + ) return CommandGroup(replacing: .appSettings) { - Button(AppLocalization.localized("Settings...")) { + Button(settingsTitle) { appController.showSettingsWindow() } .keyboardShortcut(",", modifiers: .command) diff --git a/Tests/VoilyTests/App/SettingsWindowCommandsTests.swift b/Tests/VoilyTests/App/SettingsWindowCommandsTests.swift new file mode 100644 index 0000000..6915b85 --- /dev/null +++ b/Tests/VoilyTests/App/SettingsWindowCommandsTests.swift @@ -0,0 +1,27 @@ +import XCTest +@testable import Voily +@testable import VoilyCore + +final class SettingsWindowCommandsTests: XCTestCase { + func testSettingsCommandTitleUsesExplicitInterfaceLanguage() { + XCTAssertEqual( + SettingsCommandLocalization.settingsTitle(languageCode: AppInterfaceLanguage.japanese.rawValue), + "設定…" + ) + } + + func testAppBundleProvidesInterfaceLocalizationResources() { + XCTAssertEqual( + AppLocalization.localized("界面语言", languageCode: AppInterfaceLanguage.english.rawValue), + "Interface Language" + ) + XCTAssertEqual( + AppLocalization.localized("界面语言", languageCode: AppInterfaceLanguage.traditionalChinese.rawValue), + "介面語言" + ) + XCTAssertEqual( + AppLocalization.localized("界面语言", languageCode: AppInterfaceLanguage.japanese.rawValue), + "表示言語" + ) + } +} diff --git a/project.yml b/project.yml index 6eadf56..9fa5e30 100644 --- a/project.yml +++ b/project.yml @@ -80,9 +80,13 @@ targets: - path: Sources/VoilyApp - path: Resources/VoilyApp/Assets.xcassets - path: Resources/VoilyApp/en.lproj + type: folder - path: Resources/VoilyApp/ja.lproj + type: folder - path: Resources/VoilyApp/zh-Hans.lproj + type: folder - path: Resources/VoilyApp/zh-Hant.lproj + type: folder - path: Resources/VoilyApp/BrandIcons type: folder info: