From e4475a8e83287b3e291065b0c192a4711616d8f8 Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Tue, 31 Oct 2023 12:19:43 +0800 Subject: [PATCH 1/2] fix: the date following localized date description --- Clendar/Base/ContentView.swift | 6 +++--- Clendar/Helper/Extensions/Date+Extensions.swift | 6 +++++- .../Helper/Extensions/DateFormatter+Extensions.swift | 11 +++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Clendar/Base/ContentView.swift b/Clendar/Base/ContentView.swift index 7417d0c9..e685fe26 100644 --- a/Clendar/Base/ContentView.swift +++ b/Clendar/Base/ContentView.swift @@ -215,7 +215,7 @@ extension ContentView { .clipShape(Circle()) .accessibilityHidden(true) .overlay( - Text(date.toDateString(calendar: store.calendar)) + Text(date.toNumericDateString(calendar: store.calendar)) .minimumScaleFactor(0.5) .font(.boldFontWithSize(17)) .foregroundColor( @@ -227,13 +227,13 @@ extension ContentView { } }, trailing: { date in - Text(date.toDateString(calendar: store.calendar)) + Text(date.toNumericDateString(calendar: store.calendar)) .minimumScaleFactor(0.5) .font(.boldFontWithSize(15)) .foregroundColor(Color(.gray).opacity(0.3)) }, header: { date in - Text(date.toDayString(calendar: store.calendar).localizedUppercase) + Text(date.toNumericDateString(calendar: store.calendar).localizedUppercase) .minimumScaleFactor(0.5) .font(.regularFontWithSize(12)) .foregroundColor(.appGray) diff --git a/Clendar/Helper/Extensions/Date+Extensions.swift b/Clendar/Helper/Extensions/Date+Extensions.swift index aef4f92b..17481fa7 100644 --- a/Clendar/Helper/Extensions/Date+Extensions.swift +++ b/Clendar/Helper/Extensions/Date+Extensions.swift @@ -63,7 +63,11 @@ extension Date { func toDateString(calendar: Calendar = CalendarIdentifier.current.calendar) -> String { DateFormatter.asString(self, format: "d", calendar: calendar) } - + + func toNumericDateString(calendar: Calendar = CalendarIdentifier.current.calendar) -> String { + DateFormatter.asNonlocalizedString(self, format: "d", calendar: calendar) + } + func toDateAndMonthString(calendar: Calendar = CalendarIdentifier.current.calendar) -> String { DateFormatter.asString(self, format: "MMM d", calendar: calendar) } diff --git a/Clendar/Helper/Extensions/DateFormatter+Extensions.swift b/Clendar/Helper/Extensions/DateFormatter+Extensions.swift index c3942494..c57540f6 100644 --- a/Clendar/Helper/Extensions/DateFormatter+Extensions.swift +++ b/Clendar/Helper/Extensions/DateFormatter+Extensions.swift @@ -31,4 +31,15 @@ extension DateFormatter { dateFormatter.calendar = calendar return dateFormatter.string(from: date) } + + static func asNonlocalizedString( + _ date: Date, + format: String, + calendar: Calendar = CalendarIdentifier.current.calendar + ) -> String { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = format + dateFormatter.calendar = calendar + return dateFormatter.string(from: date) + } } From 08c5df239c19f6754a04f9f4422a7c9af92d87f0 Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Tue, 31 Oct 2023 12:28:36 +0800 Subject: [PATCH 2/2] fix: some translation in Chinese Simplified --- Clendar/Resources/Localization/Localizable.xcstrings | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Clendar/Resources/Localization/Localizable.xcstrings b/Clendar/Resources/Localization/Localizable.xcstrings index 141a24c7..04cadf3d 100644 --- a/Clendar/Resources/Localization/Localizable.xcstrings +++ b/Clendar/Resources/Localization/Localizable.xcstrings @@ -618,7 +618,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "완전히 새롭게 재설계됨" + "value" : "全新设计" } }, "zh-Hant" : { @@ -1286,7 +1286,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "日曆類型" + "value" : "日历类型" } }, "zh-Hant" : { @@ -11926,7 +11926,7 @@ "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "您擁有 Clendar+。 謝謝你的支持! 😊" + "value" : "您拥有 Clendar+。 谢谢你的支持! 😊" } }, "zh-Hant" : {