Skip to content

Commit 0c36106

Browse files
[PM-27098] Add plurals for times (#2052)
1 parent b686247 commit 0c36106

File tree

19 files changed

+136
-195
lines changed

19 files changed

+136
-195
lines changed

AuthenticatorShared/Core/Platform/Models/Enum/ClearClipboardValueTests.swift

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import BitwardenKit
2-
import BitwardenResources
32

43
// MARK: - SessionTimeoutValue
54

65
/// An enumeration of session timeout values to choose from.
76
/// BWA does not use the custom value.
87
///
9-
extension SessionTimeoutValue: @retroactive CaseIterable, Menuable {
8+
extension SessionTimeoutValue: @retroactive CaseIterable {
109
/// All of the cases to show in the menu.
1110
public static let allCases: [Self] = [
1211
.immediately,
@@ -19,30 +18,4 @@ extension SessionTimeoutValue: @retroactive CaseIterable, Menuable {
1918
.onAppRestart,
2019
.never,
2120
]
22-
23-
/// The localized string representation of a `SessionTimeoutValue`.
24-
public var localizedName: String {
25-
switch self {
26-
case .immediately:
27-
Localizations.immediately
28-
case .oneMinute:
29-
Localizations.xMinutes(1)
30-
case .fiveMinutes:
31-
Localizations.xMinutes(5)
32-
case .fifteenMinutes:
33-
Localizations.xMinutes(15)
34-
case .thirtyMinutes:
35-
Localizations.xMinutes(30)
36-
case .oneHour:
37-
Localizations.oneHour
38-
case .fourHours:
39-
Localizations.fourHours
40-
case .onAppRestart:
41-
Localizations.onRestart
42-
case .never:
43-
Localizations.never
44-
case .custom:
45-
Localizations.custom
46-
}
47-
}
4821
}

AuthenticatorShared/Core/Platform/Models/Enum/SessionTimeoutValueTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ final class SessionTimeoutValueTests: BitwardenTestCase {
3232
XCTAssertEqual(SessionTimeoutValue.fiveMinutes.localizedName, Localizations.xMinutes(5))
3333
XCTAssertEqual(SessionTimeoutValue.fifteenMinutes.localizedName, Localizations.xMinutes(15))
3434
XCTAssertEqual(SessionTimeoutValue.thirtyMinutes.localizedName, Localizations.xMinutes(30))
35-
XCTAssertEqual(SessionTimeoutValue.oneHour.localizedName, Localizations.oneHour)
36-
XCTAssertEqual(SessionTimeoutValue.fourHours.localizedName, Localizations.fourHours)
35+
XCTAssertEqual(SessionTimeoutValue.oneHour.localizedName, Localizations.xHours(1))
36+
XCTAssertEqual(SessionTimeoutValue.fourHours.localizedName, Localizations.xHours(4))
3737
XCTAssertEqual(SessionTimeoutValue.onAppRestart.localizedName, Localizations.onRestart)
3838
XCTAssertEqual(SessionTimeoutValue.never.localizedName, Localizations.never)
3939
XCTAssertEqual(SessionTimeoutValue.custom(123).localizedName, Localizations.custom)

AuthenticatorShared/Core/Platform/Services/TestHelpers/MockPasteboardService.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@testable import AuthenticatorShared
2+
import BitwardenKit
23

34
class MockPasteboardService: PasteboardService {
45
var clearClipboardValue: ClearClipboardValue = .never

AuthenticatorShared/UI/Vault/AuthenticatorItem/AuthenticatorItemState.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ enum TotpPeriodOptions: Int, Menuable, CaseIterable {
161161
var localizedName: String {
162162
switch self {
163163
case .thirty:
164-
Localizations.thirtySeconds
164+
Localizations.xSeconds(30)
165165
case .sixty:
166-
Localizations.sixtySeconds
166+
Localizations.xSeconds(60)
167167
case .ninety:
168-
Localizations.ninetySeconds
168+
Localizations.xSeconds(90)
169169
}
170170
}
171171
}

AuthenticatorShared/Core/Platform/Models/Enum/ClearClipboardValue.swift renamed to BitwardenKit/Core/Platform/Models/Enum/ClearClipboardValue.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import BitwardenKit
21
import BitwardenResources
32
import Foundation
43

54
// MARK: - ClearClipboardValue
65

76
/// The time after which the clipboard should be cleared.
87
///
9-
enum ClearClipboardValue: Int, Menuable {
8+
public enum ClearClipboardValue: Int, Menuable {
109
/// Do not clear the clipboard.
1110
case never = -1
1211

@@ -29,7 +28,7 @@ enum ClearClipboardValue: Int, Menuable {
2928
case fiveMinutes = 300
3029

3130
/// All of the cases to show in the menu, in order.
32-
static let allCases: [Self] = [
31+
public static let allCases: [Self] = [
3332
.never,
3433
.tenSeconds,
3534
.twentySeconds,
@@ -40,16 +39,16 @@ enum ClearClipboardValue: Int, Menuable {
4039
]
4140

4241
/// The name of the value to display in the menu.
43-
var localizedName: String {
42+
public var localizedName: String {
4443
switch self {
4544
case .never:
4645
Localizations.never
4746
case .tenSeconds:
48-
Localizations.tenSeconds
47+
Localizations.xSeconds(10)
4948
case .twentySeconds:
50-
Localizations.twentySeconds
49+
Localizations.xSeconds(20)
5150
case .thirtySeconds:
52-
Localizations.thirtySeconds
51+
Localizations.xSeconds(30)
5352
case .oneMinute:
5453
Localizations.xMinutes(1)
5554
case .twoMinutes:

BitwardenShared/Core/Platform/Models/Enum/ClearClipboardValueTests.swift renamed to BitwardenKit/Core/Platform/Models/Enum/ClearClipboardValueTests.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import XCTest
2-
1+
import BitwardenKit
32
import BitwardenResources
4-
@testable import BitwardenShared
3+
import XCTest
54

65
class ClearClipboardValueTests: BitwardenTestCase {
76
// MARK: Tests
87

98
/// `localizedName` returns the correct values.
109
func test_localizedName() {
1110
XCTAssertEqual(ClearClipboardValue.never.localizedName, Localizations.never)
12-
XCTAssertEqual(ClearClipboardValue.tenSeconds.localizedName, Localizations.tenSeconds)
13-
XCTAssertEqual(ClearClipboardValue.twentySeconds.localizedName, Localizations.twentySeconds)
14-
XCTAssertEqual(ClearClipboardValue.thirtySeconds.localizedName, Localizations.thirtySeconds)
11+
XCTAssertEqual(ClearClipboardValue.tenSeconds.localizedName, Localizations.xSeconds(10))
12+
XCTAssertEqual(ClearClipboardValue.twentySeconds.localizedName, Localizations.xSeconds(20))
13+
XCTAssertEqual(ClearClipboardValue.thirtySeconds.localizedName, Localizations.xSeconds(30))
1514
XCTAssertEqual(ClearClipboardValue.oneMinute.localizedName, Localizations.xMinutes(1))
1615
XCTAssertEqual(ClearClipboardValue.twoMinutes.localizedName, Localizations.xMinutes(2))
1716
XCTAssertEqual(ClearClipboardValue.fiveMinutes.localizedName, Localizations.xMinutes(5))

BitwardenKit/Core/Platform/Models/Enum/SessionTimeoutValue.swift

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import BitwardenResources
2+
13
// MARK: - SessionTimeoutValue
24

35
/// An enumeration of session timeout values to choose from.
46
///
5-
public enum SessionTimeoutValue: Codable, RawRepresentable, Equatable, Hashable, Sendable {
7+
public enum SessionTimeoutValue: Codable, RawRepresentable, Equatable, Hashable, Menuable, Sendable {
68
/// Time out immediately.
79
case immediately
810

@@ -38,6 +40,32 @@ public enum SessionTimeoutValue: Codable, RawRepresentable, Equatable, Hashable,
3840
rawValue * 60
3941
}
4042

43+
/// The localized string representation of a `SessionTimeoutValue`.
44+
public var localizedName: String {
45+
switch self {
46+
case .immediately:
47+
Localizations.immediately
48+
case .oneMinute:
49+
Localizations.xMinutes(1)
50+
case .fiveMinutes:
51+
Localizations.xMinutes(5)
52+
case .fifteenMinutes:
53+
Localizations.xMinutes(15)
54+
case .thirtyMinutes:
55+
Localizations.xMinutes(30)
56+
case .oneHour:
57+
Localizations.xHours(1)
58+
case .fourHours:
59+
Localizations.xHours(4)
60+
case .onAppRestart:
61+
Localizations.onRestart
62+
case .never:
63+
Localizations.never
64+
case .custom:
65+
Localizations.custom
66+
}
67+
}
68+
4169
/// The session timeout value in minutes.
4270
public var rawValue: Int {
4371
switch self {

BitwardenResources/Localizations/en.lproj/Localizable.strings

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@
131131
"LastSync" = "Last sync:";
132132
"Length" = "Length";
133133
"Lock" = "Lock";
134-
"OneHour" = "1 hour";
135-
"FourHours" = "4 hours";
136134
"Immediately" = "Immediately";
137135
"VaultTimeout" = "Vault timeout";
138136
"VaultTimeoutAction" = "Vault timeout action";
@@ -439,9 +437,6 @@
439437
"VaultLockedIdentity" = "Your vault is locked. Verify your identity to continue.";
440438
"Dark" = "Dark";
441439
"Light" = "Light";
442-
"TenSeconds" = "10 seconds";
443-
"ThirtySeconds" = "30 seconds";
444-
"TwentySeconds" = "20 seconds";
445440
"ClearClipboard" = "Clear clipboard";
446441
"ClearClipboardDescription" = "Automatically clear copied values from your clipboard.";
447442
"DefaultUriMatchDetection" = "Default URI match detection";
@@ -584,11 +579,6 @@
584579
"SendDeleted" = "Send deleted";
585580
"SendUpdated" = "Send saved";
586581
"NewSendCreated" = "Send created";
587-
"OneDay" = "1 day";
588-
"TwoDays" = "2 days";
589-
"ThreeDays" = "3 days";
590-
"SevenDays" = "7 days";
591-
"ThirtyDays" = "30 days";
592582
"Custom" = "Custom";
593583
"ShareOnSave" = "Share this Send upon save";
594584
"SendDisabledWarning" = "Due to an enterprise policy, you are only able to delete an existing Send.";
@@ -841,7 +831,6 @@
841831
"OneHourAndXMinute" = "One hour and %1$@ minutes";
842832
"XHoursAndOneMinute" = "%1$@ hours and one minute";
843833
"XHoursAndYMinutes" = "%1$@ hours and %2$@ minutes";
844-
"XHours" = "%1$@ hours";
845834
"PasskeyManagementExplanationLong" = "Use Bitwarden to save new passkeys and log in with passkeys stored in your vault.";
846835
"AutofillServicesExplanationLong" = "The Android Autofill Framework is used to assist in filling login information into other apps on your device.";
847836
"UseInlineAutofillExplanationLong" = "Use inline autofill if your selected keyboard supports it. Otherwise, use the default overlay.";
@@ -1147,7 +1136,6 @@
11471136
"LoggingDuration" = "Logging duration";
11481137
"LogsWillBeAutomaticallyDeletedAfter30DaysDescriptionLong" = "Logs will be automatically deleted after 30 days. Bitwarden is only able to access your log data when you share it.";
11491138
"ForDetailsOnWhatIsAndIsntLoggedVisitTheBitwardenHelpCenter" = "For details on what is and isn’t logged, visit the **[Bitwarden help center](%1$@)**.";
1150-
"OneWeek" = "1 week";
11511139
"ShowMore" = "Show more";
11521140
"ShowLess" = "Show less";
11531141
"ItemNameX" = "Item name, %1$@";
@@ -1242,7 +1230,6 @@
12421230
"LearnMoreLink" = "[Learn more](%1$@)";
12431231
"LocalCodes" = "Local codes";
12441232
"NeedHelpVisitOurHelpCenterForGuidance" = "Need help? Visit our Help Center for guidance.";
1245-
"NinetySeconds" = "90 seconds";
12461233
"NoAskMe" = "No, ask me";
12471234
"NoCodes" = "You don’t have any codes to display";
12481235
"None" = "None";
@@ -1260,7 +1247,6 @@
12601247
"SetSaveLocallyAsYourDefaultSaveOption" = "Set “Save locally” as your default save option?";
12611248
"SetSaveToBitwardenAsYourDefaultSaveOption" = "Set “Save to Bitwarden” as your default save option?";
12621249
"SignInUsingUniqueCodes" = "Sign in using unique codes";
1263-
"SixtySeconds" = "60 seconds";
12641250
"Skip" = "Skip";
12651251
"Steam" = "Steam";
12661252
"StoreAllOfYourLoginsAndSyncVerificationCodesDirectlyWithTheAuthenticatorApp" = "Store all of your logins and sync verification codes directly with the Authenticator app.";

BitwardenResources/Localizations/en.lproj/Localizable.stringsdict

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,41 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<!-- A number of days, used in menu selections. For example, the number of days to keep a send before deletion. -->
6+
<key>XDays</key>
7+
<dict>
8+
<key>NSStringLocalizedFormatKey</key>
9+
<string>%#@days@</string>
10+
<key>days</key>
11+
<dict>
12+
<key>NSStringFormatSpecTypeKey</key>
13+
<string>NSStringPluralRuleType</string>
14+
<key>NSStringFormatValueTypeKey</key>
15+
<string>d</string>
16+
<key>one</key>
17+
<string>%d day</string>
18+
<key>other</key>
19+
<string>%d days</string>
20+
</dict>
21+
</dict>
22+
<!-- A number of hours, used in menu selections. For example, how long to log events in the flight recorder. -->
23+
<key>XHours</key>
24+
<dict>
25+
<key>NSStringLocalizedFormatKey</key>
26+
<string>%#@hours@</string>
27+
<key>hours</key>
28+
<dict>
29+
<key>NSStringFormatSpecTypeKey</key>
30+
<string>NSStringPluralRuleType</string>
31+
<key>NSStringFormatValueTypeKey</key>
32+
<string>d</string>
33+
<key>one</key>
34+
<string>%d hour</string>
35+
<key>other</key>
36+
<string>%d hours</string>
37+
</dict>
38+
</dict>
39+
<!-- A number of minutes, used in menu selections. For example, the amount of time to keep the vault unlocked after being unlocked. -->
540
<key>XMinutes</key>
641
<dict>
742
<key>NSStringLocalizedFormatKey</key>
@@ -18,5 +53,39 @@
1853
<string>%d minutes</string>
1954
</dict>
2055
</dict>
56+
<!-- A number of seconds, used in menu selection. For example, how long to keep copied fields in the clipboard before clearing. -->
57+
<key>XSeconds</key>
58+
<dict>
59+
<key>NSStringLocalizedFormatKey</key>
60+
<string>%#@seconds@</string>
61+
<key>seconds</key>
62+
<dict>
63+
<key>NSStringFormatSpecTypeKey</key>
64+
<string>NSStringPluralRuleType</string>
65+
<key>NSStringFormatValueTypeKey</key>
66+
<string>d</string>
67+
<key>one</key>
68+
<string>%d second</string>
69+
<key>other</key>
70+
<string>%d seconds</string>
71+
</dict>
72+
</dict>
73+
<!-- A number of weeks, used in menu selection. For example, how long to log events in the flight recorder. -->
74+
<key>XWeeks</key>
75+
<dict>
76+
<key>NSStringLocalizedFormatKey</key>
77+
<string>%#@weeks@</string>
78+
<key>weeks</key>
79+
<dict>
80+
<key>NSStringFormatSpecTypeKey</key>
81+
<string>NSStringPluralRuleType</string>
82+
<key>NSStringFormatValueTypeKey</key>
83+
<string>d</string>
84+
<key>one</key>
85+
<string>%d week</string>
86+
<key>other</key>
87+
<string>%d weeks</string>
88+
</dict>
89+
</dict>
2190
</dict>
2291
</plist>

0 commit comments

Comments
 (0)