diff --git a/CHANGELOG.md b/CHANGELOG.md index 39e6897..5051baa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- **Style card captions**: resolve each built-in style’s short description through the in-app language override, so switching App Language updates the caption instead of showing a localization key or the system language. / **风格卡片说明**:内置风格的说明小字改为走应用内语言设置;切换 App 语言后说明会跟着变,而不再显示本地化 key 或跟随系统语言。 + ## [2.2.0] - 2026-09-18 ### Added diff --git a/OSGKeyboard/Views/PersonalReplyStyleSection.swift b/OSGKeyboard/Views/PersonalReplyStyleSection.swift index 0e11c61..3c07115 100644 --- a/OSGKeyboard/Views/PersonalReplyStyleSection.swift +++ b/OSGKeyboard/Views/PersonalReplyStyleSection.swift @@ -196,9 +196,11 @@ struct PersonalReplyStyleSection: View { Image(systemName: "arrow.clockwise") } Text( - isGenerating - ? "personalReplyStyle.regenerating" - : "personalReplyStyle.regenerate" + AppL10n.string( + isGenerating + ? "personalReplyStyle.regenerating" + : "personalReplyStyle.regenerate" + ) ) } .font(TypeStyle.bodyEmph) diff --git a/OSGKeyboard/Views/PolishStylesView.swift b/OSGKeyboard/Views/PolishStylesView.swift index 06a6b5e..9fee57d 100644 --- a/OSGKeyboard/Views/PolishStylesView.swift +++ b/OSGKeyboard/Views/PolishStylesView.swift @@ -169,7 +169,10 @@ struct PolishStylesView: View { .foregroundStyle(palette.textPrimary) .lineLimit(1) .padding(.trailing, 32) - Text(descriptionKey(for: pack)) + // AppL10n honors Settings → App Language; Text(String) would + // show the raw key, and a bare LocalizedStringKey would follow + // the system language instead (see Scripts/check_l10n_keys.sh). + Text(AppL10n.string(descriptionKey(for: pack), language: config.uiLanguage)) .font(TypeStyle.caption2) .foregroundStyle(palette.textTertiary) .lineLimit(2) @@ -229,19 +232,11 @@ struct PolishStylesView: View { } } + /// Host-bundle caption keys. Resolved at the render site with `AppL10n` + /// so Settings → App Language wins over the launch-time system locale. private func descriptionKey(for pack: PolishStylePack) -> String { guard pack.kind == .builtin else { return "polishStyles.custom.description" } - switch pack.id { - case "builtin.structured": return "polishStyles.structured.description" - case "builtin.formal": return "polishStyles.formal.description" - case "builtin.dating": return "polishStyles.dating.description" - case "builtin.chat": return "polishStyles.chat.description" - case "builtin.flex": return "polishStyles.flex.description" - case "builtin.corp": return "polishStyles.corp.description" - case "builtin.diba": return "polishStyles.diba.description" - case "builtin.xhs": return "polishStyles.xhs.description" - default: return "polishStyles.light.description" - } + return "polishStyles.\(pack.id.dropFirst("builtin.".count)).description" } private func reload() { @@ -464,7 +459,9 @@ struct PolishStyleEditorSheet: View { Text(AppL10n.string("polishStyles.editor.hint")) } } - .navigationTitle(isNew ? "polishStyles.add" : "polishStyles.edit") + .navigationTitle( + AppL10n.string(isNew ? "polishStyles.add" : "polishStyles.edit") + ) .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .cancellationAction) { diff --git a/OSGKeyboardTests/PolishStylesL10nTests.swift b/OSGKeyboardTests/PolishStylesL10nTests.swift new file mode 100644 index 0000000..532640f --- /dev/null +++ b/OSGKeyboardTests/PolishStylesL10nTests.swift @@ -0,0 +1,26 @@ +// PolishStylesL10nTests.swift +// OSGKeyboard · Tests +// +// Style-card captions live in the host Localizable.strings table and must be +// resolved through AppL10n so the in-app language override wins. + +@testable import OSGKeyboard +@testable import OSGKeyboardShared +import XCTest + +final class PolishStylesL10nTests: XCTestCase { + func testBuiltinStyleCardDescriptionsHonorInAppLanguage() { + let slugs = PolishStylePackCatalog.builtins.map { + String($0.id.dropFirst("builtin.".count)) + } + ["custom"] + + for slug in slugs { + let key = "polishStyles.\(slug).description" + let english = AppL10n.string(key, language: .english) + let chinese = AppL10n.string(key, language: .chinese) + XCTAssertNotEqual(english, key, "missing English copy for \(key)") + XCTAssertNotEqual(chinese, key, "missing Chinese copy for \(key)") + XCTAssertNotEqual(english, chinese, "\(key) is not bilingual") + } + } +}