Skip to content

Commit 246d124

Browse files
committed
Append English names to language picker
Add an englishDisplayName computed property to AppLanguage that returns English labels for each case. Update SettingsView to display the localized name plus the English name (e.g. "Localized (English)") in the language picker. Add unit test testEnglishDisplayNameMapping_forPickerLabels to verify the englishDisplayName values. This improves clarity by showing English labels alongside localized names in the picker.
1 parent fa851a0 commit 246d124

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

CycleOne/Core/Localization/AppLanguage.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ enum AppLanguage: String, CaseIterable, Identifiable {
4949
}
5050
}
5151

52+
var englishDisplayName: String {
53+
switch self {
54+
case .system:
55+
"System"
56+
case .english:
57+
"English"
58+
case .filipino:
59+
"Filipino"
60+
case .japanese:
61+
"Japanese"
62+
case .korean:
63+
"Korean"
64+
}
65+
}
66+
5267
static func fromStoredValue(_ rawValue: String?) -> AppLanguage {
5368
AppLanguage(rawValue: rawValue ?? "") ?? .system
5469
}

CycleOne/Views/Settings/SettingsView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ struct SettingsView: View {
109109
selection: $selectedLanguageCode
110110
) {
111111
ForEach(AppLanguage.allCases) { language in
112-
Text(language.displayNameKey).tag(language.rawValue)
112+
(Text(language.displayNameKey)
113+
+ Text(" (\(language.englishDisplayName))"))
114+
.tag(language.rawValue)
113115
}
114116
}
115117
.pickerStyle(.menu)

CycleOneTests/AppLanguageTests.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ final class AppLanguageTests: XCTestCase {
3131
XCTAssertEqual(AppLanguage.korean.locale.identifier, "ko")
3232
}
3333

34+
func testEnglishDisplayNameMapping_forPickerLabels() {
35+
XCTAssertEqual(AppLanguage.system.englishDisplayName, "System")
36+
XCTAssertEqual(AppLanguage.english.englishDisplayName, "English")
37+
XCTAssertEqual(AppLanguage.filipino.englishDisplayName, "Filipino")
38+
XCTAssertEqual(AppLanguage.japanese.englishDisplayName, "Japanese")
39+
XCTAssertEqual(AppLanguage.korean.englishDisplayName, "Korean")
40+
}
41+
3442
func testLocalizedString_usesLanguageSpecificBundle() {
3543
XCTAssertEqual(
3644
AppLanguage.english.localizedString("tab.settings", defaultValue: "Settings"),

0 commit comments

Comments
 (0)