Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/VoilyApp/App/AppController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ final class AppController: NSObject {
injectedASRCaptureSessionFactory ?? defaultASRCaptureSessionFactory
}

var appSettings: AppSettings {
settings
}

init(
windowActions: WindowActions,
appUpdater: AppUpdater = AppUpdater(),
Expand Down
17 changes: 15 additions & 2 deletions Sources/VoilyApp/App/VoilyApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions Tests/VoilyTests/App/SettingsWindowCommandsTests.swift
Original file line number Diff line number Diff line change
@@ -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),
"表示言語"
)
}
}
4 changes: 4 additions & 0 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading