From c6328b53f569f9d8c3837734f79f37f687fc0212 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 12:11:53 +1100 Subject: [PATCH 01/15] Bump version number --- config/Version.internal.xcconfig | 4 ++-- config/Version.public.xcconfig | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/Version.internal.xcconfig b/config/Version.internal.xcconfig index 8af91ef31928..ab24b0327380 100644 --- a/config/Version.internal.xcconfig +++ b/config/Version.internal.xcconfig @@ -1,4 +1,4 @@ -VERSION_SHORT=20.9 +VERSION_SHORT=21.0 // Internal long version example: VERSION_LONG=9.9.0.20180423 -VERSION_LONG=20.9.0.20221014 +VERSION_LONG=21.0.0.20221017 diff --git a/config/Version.public.xcconfig b/config/Version.public.xcconfig index 9c6135db0ba0..219e10b6aa93 100644 --- a/config/Version.public.xcconfig +++ b/config/Version.public.xcconfig @@ -1,4 +1,4 @@ -VERSION_SHORT=20.9 +VERSION_SHORT=21.0 // Public long version example: VERSION_LONG=9.9.0.0 -VERSION_LONG=20.9.0.2 +VERSION_LONG=21.0.0.0 From ff147e89379a5913630a59bcff9ba1cb4aaa73c1 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 12:11:58 +1100 Subject: [PATCH 02/15] Update draft release notes for 21.0. --- WordPress/Resources/release_notes.txt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/WordPress/Resources/release_notes.txt b/WordPress/Resources/release_notes.txt index 0fa50087e2eb..4c49a17c540f 100644 --- a/WordPress/Resources/release_notes.txt +++ b/WordPress/Resources/release_notes.txt @@ -1,7 +1,13 @@ -You can now cancel a WordPress.com login while you’re already logged in to a self-hosted site—no more getting stuck on the login screen if you change your mind. +* [*] Fixed an issue where the cached notifications are retained after logging out of WordPress.com account [#19360] +* [**] [Jetpack-only] Added a share extension. Now users can share content to Jetpack through iOS's share sheet. This was previously only available on the WordPress app. [#19383] +* [*] Update launch screen. [#19341] +* [*] [Jetpack-only] Add ability to set custom app icon for Jetpack app. [#19378] +* [**] [Jetpack-only] Added a "Save as Draft" extension. Now users can save content to Jetpack through iOS's share sheet. This was previously only available on the WordPress app. [#19414] +* [**] [Jetpack-only] Enables Rich Notifications for the Jetpack app. Now we display more details on most of the push notifications. This was previously only available on the WordPress app. [#19415] +* [*] Reader: Comment Details have been redesigned. [#19387] +* [*] [internal] A refactor in weekly roundup notification scheduler. [#19422] +* [*] [internal] A low level database refactor around fetching cards in the Reader tab. [#19427] +* [*] Stories: Fixed an issue where the keyboard would overlap with the publish dialog in landscape. [#19350] +* [*] [internal] A refactor in fetch Reader posts and their comments. [#19458] +* [*] Fixed an issue where the navigation bar becomes invisible when swiping back to Login Prologue screen. [#19461] -We also squashed several bugs in this latest update. - -- Once upon a time, we fixed an issue where deleting one image in a Story Post draft would prevent the next image in the story from loading. And everyone lived happily ever after. -- On iPad displays, the “Turn on notifications” button no longer sits overtop the instructions for turning on push notifications. The “No result” side menu text now fits on screen, too. -- Content above the Powered by Jetpack banner now stays visible and responsive while you’re scrolling. Up, up, and away. From cde05ad559253274f88b7f525c1571f9c79ba4c4 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 12:11:58 +1100 Subject: [PATCH 03/15] Update draft release notes for 21.0. --- WordPress/Jetpack/Resources/release_notes.txt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/WordPress/Jetpack/Resources/release_notes.txt b/WordPress/Jetpack/Resources/release_notes.txt index ca8dbb1e2331..4c49a17c540f 100644 --- a/WordPress/Jetpack/Resources/release_notes.txt +++ b/WordPress/Jetpack/Resources/release_notes.txt @@ -1,7 +1,13 @@ -You can now cancel a WordPress.com login while you’re already logged in to a self-hosted site—no more getting stuck on the login screen if you change your mind. +* [*] Fixed an issue where the cached notifications are retained after logging out of WordPress.com account [#19360] +* [**] [Jetpack-only] Added a share extension. Now users can share content to Jetpack through iOS's share sheet. This was previously only available on the WordPress app. [#19383] +* [*] Update launch screen. [#19341] +* [*] [Jetpack-only] Add ability to set custom app icon for Jetpack app. [#19378] +* [**] [Jetpack-only] Added a "Save as Draft" extension. Now users can save content to Jetpack through iOS's share sheet. This was previously only available on the WordPress app. [#19414] +* [**] [Jetpack-only] Enables Rich Notifications for the Jetpack app. Now we display more details on most of the push notifications. This was previously only available on the WordPress app. [#19415] +* [*] Reader: Comment Details have been redesigned. [#19387] +* [*] [internal] A refactor in weekly roundup notification scheduler. [#19422] +* [*] [internal] A low level database refactor around fetching cards in the Reader tab. [#19427] +* [*] Stories: Fixed an issue where the keyboard would overlap with the publish dialog in landscape. [#19350] +* [*] [internal] A refactor in fetch Reader posts and their comments. [#19458] +* [*] Fixed an issue where the navigation bar becomes invisible when swiping back to Login Prologue screen. [#19461] -The Jetpack app can run weekly roundups in the background while you’re using other apps. Up, up, and away. - -On iPad displays, the “Turn on notifications” button no longer sits overtop the instructions for turning on push notifications. The “No result” side menu text now fits on screen, too. - -Once upon a time, we fixed an issue where deleting one image in a Story Post draft would prevent the next image in the story from loading. And everyone lived happily ever after. From 5ac32022ff09fa76bd2b77075cee9793816e8e55 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 12:11:58 +1100 Subject: [PATCH 04/15] Release Notes: add new section for next version (21.1) --- RELEASE-NOTES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 99916bd8df19..9a1a819a2ff9 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,3 +1,7 @@ +21.1 +----- + + 21.0 ----- * [*] Fixed an issue where the cached notifications are retained after logging out of WordPress.com account [#19360] From b4dfb74d2a8ecf036a51cd5c28015135c285b7aa Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 12:53:46 +1100 Subject: [PATCH 05/15] Update internal pods to latest stable versions Notice the Sentry update, which happened because it is a Tracks dependency. For the first time ever, running `bundle exec pod update ...` printed this kind of warning: ``` [!] `` attempted to initialize an object with an unknown UUID. `FEC3B81A26C2915A00A395C7` for attribute: `files`. This can be the result of a merge and the unknown UUID is being discarded. ``` --- Podfile | 4 ++-- Podfile.lock | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Podfile b/Podfile index 5a4b8738d9c4..2a47db4b1c41 100644 --- a/Podfile +++ b/Podfile @@ -47,7 +47,7 @@ def wordpress_ui end def wordpress_kit - pod 'WordPressKit', '~> 4.58.1-beta.1' + pod 'WordPressKit', '~> 4.58', '>= 4.58.1' # pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :tag => '' # pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :branch => '' # pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :commit => '' @@ -222,7 +222,7 @@ abstract_target 'Apps' do pod 'Gridicons', '~> 1.1.0' - pod 'WordPressAuthenticator', '~> 3.2', '>= 3.2.2-beta.1' + pod 'WordPressAuthenticator', '~> 3.2', '>= 3.2.2' # pod 'WordPressAuthenticator', git: 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', branch: 'fix/prologue-nav-bar' # pod 'WordPressAuthenticator', :git => 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', :commit => '' # 'WordPressAuthenticator', :path => '../WordPressAuthenticator-iOS' diff --git a/Podfile.lock b/Podfile.lock index 066d8c7346ac..905f10afa669 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -481,9 +481,9 @@ PODS: - SDWebImageWebPCoder (0.8.5): - libwebp (~> 1.0) - SDWebImage/Core (~> 5.10) - - Sentry (7.27.0): - - Sentry/Core (= 7.27.0) - - Sentry/Core (7.27.0) + - Sentry (7.28.0): + - Sentry/Core (= 7.28.0) + - Sentry/Core (7.28.0) - Sodium (0.9.1) - Starscream (3.0.6) - SVProgressHUD (2.2.5) @@ -491,7 +491,7 @@ PODS: - WordPress-Aztec-iOS (1.19.8) - WordPress-Editor-iOS (1.19.8): - WordPress-Aztec-iOS (= 1.19.8) - - WordPressAuthenticator (3.2.2-beta.1): + - WordPressAuthenticator (3.2.2): - Alamofire (~> 4.8) - CocoaLumberjack (~> 3.5) - GoogleSignIn (~> 6.0.1) @@ -501,7 +501,7 @@ PODS: - WordPressKit (~> 4.18-beta) - WordPressShared (~> 1.12-beta) - WordPressUI (~> 1.7-beta) - - WordPressKit (4.58.1-beta.1): + - WordPressKit (4.58.1): - Alamofire (~> 4.8.0) - CocoaLumberjack (~> 3.4) - NSObject-SafeExpectations (= 0.0.4) @@ -601,8 +601,8 @@ DEPENDENCIES: - Starscream (= 3.0.6) - SVProgressHUD (= 2.2.5) - WordPress-Editor-iOS (~> 1.19.8) - - WordPressAuthenticator (>= 3.2.2-beta.1, ~> 3.2) - - WordPressKit (~> 4.58.1-beta.1) + - WordPressAuthenticator (>= 3.2.2, ~> 3.2) + - WordPressKit (>= 4.58.1, ~> 4.58) - WordPressShared (~> 1.18.0) - WordPressUI (~> 1.12.5) - WPMediaPicker (~> 1.8.4) @@ -613,7 +613,6 @@ DEPENDENCIES: SPEC REPOS: https://github.com/wordpress-mobile/cocoapods-specs.git: - WordPressAuthenticator - - WordPressKit trunk: - Alamofire - AlamofireImage @@ -651,6 +650,7 @@ SPEC REPOS: - UIDeviceIdentifier - WordPress-Aztec-iOS - WordPress-Editor-iOS + - WordPressKit - WordPressShared - WordPressUI - WPMediaPicker @@ -857,15 +857,15 @@ SPEC CHECKSUMS: RNTAztecView: 168824a26c9e9b19f6f032a739efab296771b351 SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d - Sentry: 026b36fdc09531604db9279e55f047fe652e3f4a + Sentry: 2c6053e4cfe6dea6608135dea1928ffbb4ecfba5 Sodium: 23d11554ecd556196d313cf6130d406dfe7ac6da Starscream: ef3ece99d765eeccb67de105bfa143f929026cf5 SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6 UIDeviceIdentifier: e6a801d25f4f178de5bdf475ffe29050d0148176 WordPress-Aztec-iOS: 7d11d598f14c82c727c08b56bd35fbeb7dafb504 WordPress-Editor-iOS: 9eb9f12f21a5209cb837908d81ffe1e31cb27345 - WordPressAuthenticator: eae458ed9d8252ad972f6078e5b04faed0948bf5 - WordPressKit: a882aab63b1fb8cc4366c368910ded797a73ae5f + WordPressAuthenticator: 5110c62de1b1b1eb1f2a43fd2599f7f6c7a6659d + WordPressKit: 476ac76ac7ba610a694c55729cc4f0191bb820dc WordPressShared: e5a479220643f46dc4d7726ef8dd45f18bf0c53b WordPressUI: c5be816f6c7b3392224ac21de9e521e89fa108ac WPMediaPicker: 5a74a91e11c1047e942a65de0193f93432fc2c6d @@ -880,6 +880,6 @@ SPEC CHECKSUMS: ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba ZIPFoundation: ae5b4b813d216d3bf0a148773267fff14bd51d37 -PODFILE CHECKSUM: cf16960c63b027f1dd7a6987c9bd742337122e66 +PODFILE CHECKSUM: 414e767e2d770a8f141d427b2d743a5bbe610fc1 COCOAPODS: 1.11.2 From 3fc0ac0a67158c180ce263208c81af8242430640 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 12:57:01 +1100 Subject: [PATCH 06/15] Refresh project file after CocoaPods warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Running `bundle exec pod update ...` in the previous commit, b2b297c979465c14814ddaed5c5b636e7f08160d, printed a warning: ``` [!] `` attempted to initialize an object with an unknown UUID. `FEC3B81A26C2915A00A395C7` for attribute: `files`. This can be the result of a merge and the unknown UUID is being discarded. ``` CocoaPods suggests there might have been a merge conflict not resolved properly in the project file, which is something bound to happen from time to time in a project with as many contributors as ours—and because of the inconvenient way Xcode generates and manages the file. Whenever I run into that kind of issue on my end, I add a new file then remove it. That procedure is enough to make Xcode "refresh" the project file, which usually gets rid of any dead reference, like the one CocoaPods highlighted. And that's exactly what this commit tracks. I also verified this changed by running the tests. --- WordPress/WordPress.xcodeproj/project.pbxproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/WordPress/WordPress.xcodeproj/project.pbxproj b/WordPress/WordPress.xcodeproj/project.pbxproj index ee70af56433c..70ace6b4063d 100644 --- a/WordPress/WordPress.xcodeproj/project.pbxproj +++ b/WordPress/WordPress.xcodeproj/project.pbxproj @@ -8489,7 +8489,6 @@ F465980528E66A5A00D5F49A /* white-on-blue-icon-app-60@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "white-on-blue-icon-app-60@3x.png"; sourceTree = ""; }; F465980628E66A5A00D5F49A /* white-on-blue-icon-app-60@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "white-on-blue-icon-app-60@2x.png"; sourceTree = ""; }; F465980728E66A5B00D5F49A /* white-on-blue-icon-app-83.5@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "white-on-blue-icon-app-83.5@2x.png"; sourceTree = ""; }; - F47DB4A8EC2E6844E213A3FA /* Pods_WordPressShareExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WordPressShareExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; }; F4BECD1A288EE5220078391A /* SuggestionsViewModelType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SuggestionsViewModelType.swift; sourceTree = ""; }; F4D9AF4E288AD2E300803D40 /* SuggestionViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuggestionViewModelTests.swift; sourceTree = ""; }; F4D9AF50288AE23500803D40 /* SuggestionTableViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuggestionTableViewTests.swift; sourceTree = ""; }; @@ -12507,7 +12506,6 @@ 8584FDB4192437160019C02E /* Utility */ = { isa = PBXGroup; children = ( - 175721152754D31F00DE38BC /* AppIcon.swift */, 8B85AED8259230C500ADBEC9 /* AB Testing */, FA25FB242609B98E0005E08F /* App Configuration */, F181EDE326B2AC3100C61241 /* BackgroundTasks */, @@ -18418,7 +18416,6 @@ 17039226282E6D2F00F602E9 /* ViewsVisitorsLineChartCell.xib in Resources */, FABB28472603067C00C8785C /* Launch Screen.storyboard in Resources */, F465978F28E65F8A00D5F49A /* celadon-on-white-icon-app-60@2x.png in Resources */, - FEC3B81A26C2915A00A395C7 /* SingleButtonTableViewCell.xib in Resources */, FABB203F2602FC2C00C8785C /* ReaderRecommendedSiteCardCell.xib in Resources */, FE23EB4A26E7C91F005A1698 /* richCommentTemplate.html in Resources */, FABB20402602FC2C00C8785C /* Nunito-Bold.ttf in Resources */, From d751a7a91f44e15ecb06c6070d2c742c5f6e9814 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 12:15:24 +1100 Subject: [PATCH 07/15] Remove Jetpack-only entries from WordPress 21.0 raw release notes --- WordPress/Resources/release_notes.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/WordPress/Resources/release_notes.txt b/WordPress/Resources/release_notes.txt index 4c49a17c540f..b0fd054d66a0 100644 --- a/WordPress/Resources/release_notes.txt +++ b/WordPress/Resources/release_notes.txt @@ -1,13 +1,8 @@ * [*] Fixed an issue where the cached notifications are retained after logging out of WordPress.com account [#19360] -* [**] [Jetpack-only] Added a share extension. Now users can share content to Jetpack through iOS's share sheet. This was previously only available on the WordPress app. [#19383] * [*] Update launch screen. [#19341] -* [*] [Jetpack-only] Add ability to set custom app icon for Jetpack app. [#19378] -* [**] [Jetpack-only] Added a "Save as Draft" extension. Now users can save content to Jetpack through iOS's share sheet. This was previously only available on the WordPress app. [#19414] -* [**] [Jetpack-only] Enables Rich Notifications for the Jetpack app. Now we display more details on most of the push notifications. This was previously only available on the WordPress app. [#19415] * [*] Reader: Comment Details have been redesigned. [#19387] * [*] [internal] A refactor in weekly roundup notification scheduler. [#19422] * [*] [internal] A low level database refactor around fetching cards in the Reader tab. [#19427] * [*] Stories: Fixed an issue where the keyboard would overlap with the publish dialog in landscape. [#19350] * [*] [internal] A refactor in fetch Reader posts and their comments. [#19458] * [*] Fixed an issue where the navigation bar becomes invisible when swiping back to Login Prologue screen. [#19461] - From 6b3286d5c6a628e62923b30754ce326608b9fe42 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 12:16:39 +1100 Subject: [PATCH 08/15] Remove "Jetpack-only" prefix from Jetpack 21.0 release notes --- WordPress/Jetpack/Resources/release_notes.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/WordPress/Jetpack/Resources/release_notes.txt b/WordPress/Jetpack/Resources/release_notes.txt index 4c49a17c540f..881237caeb9c 100644 --- a/WordPress/Jetpack/Resources/release_notes.txt +++ b/WordPress/Jetpack/Resources/release_notes.txt @@ -1,13 +1,12 @@ * [*] Fixed an issue where the cached notifications are retained after logging out of WordPress.com account [#19360] -* [**] [Jetpack-only] Added a share extension. Now users can share content to Jetpack through iOS's share sheet. This was previously only available on the WordPress app. [#19383] +* [**] Added a share extension. Now users can share content to Jetpack through iOS's share sheet. This was previously only available on the WordPress app. [#19383] * [*] Update launch screen. [#19341] -* [*] [Jetpack-only] Add ability to set custom app icon for Jetpack app. [#19378] -* [**] [Jetpack-only] Added a "Save as Draft" extension. Now users can save content to Jetpack through iOS's share sheet. This was previously only available on the WordPress app. [#19414] -* [**] [Jetpack-only] Enables Rich Notifications for the Jetpack app. Now we display more details on most of the push notifications. This was previously only available on the WordPress app. [#19415] +* [*] Add ability to set custom app icon for Jetpack app. [#19378] +* [**] Added a "Save as Draft" extension. Now users can save content to Jetpack through iOS's share sheet. This was previously only available on the WordPress app. [#19414] +* [**] Enables Rich Notifications for the Jetpack app. Now we display more details on most of the push notifications. This was previously only available on the WordPress app. [#19415] * [*] Reader: Comment Details have been redesigned. [#19387] * [*] [internal] A refactor in weekly roundup notification scheduler. [#19422] * [*] [internal] A low level database refactor around fetching cards in the Reader tab. [#19427] * [*] Stories: Fixed an issue where the keyboard would overlap with the publish dialog in landscape. [#19350] * [*] [internal] A refactor in fetch Reader posts and their comments. [#19458] * [*] Fixed an issue where the navigation bar becomes invisible when swiping back to Login Prologue screen. [#19461] - From 65bcdd4c02a5e3a3b17efc6405f00c29b377de72 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 13:34:16 +1100 Subject: [PATCH 09/15] Ensure `differenceLabel` is a localized strings literals `bundle exec fastlane complete_code_freeze` failed with the following error, thrown as part of the `generate_strings_file_for_glotpress` lane: ``` [13:20:21]: genstrings: error: bad entry in file WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift (line = 58): Argument is not a literal string. [13:20:21]: fastlane finished with errors [!] genstrings: error: bad entry in file WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift (line = 58): Argument is not a literal string. ``` --- .../ViewsVisitorsLineChartCell.swift | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift b/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift index 6cbbc037b815..feaff9d29b99 100644 --- a/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift +++ b/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift @@ -54,14 +54,34 @@ struct StatsSegmentedControlData { } var differenceLabel: String { - let stringFormatValue = differencePercent != 0 ? "%@%@ (%@%%)" : "%@%@" - let stringFormat = NSLocalizedString(stringFormatValue, comment: "Difference label for Insights Overview stat, indicating change from previous period. Ex: +99.9K(5%)") - return String.localizedStringWithFormat( - stringFormat, - difference < 0 ? "" : "+", - difference.abbreviatedString(), - differencePercent.abbreviatedString() - ) + // We want to show something like "+1.2K (5%)" if we have a percentage difference and "1.2K" if we don't. + // Because localized strings need to be strings literal, we cannot embed any conditional logic in the `localizedString...` call. + // We therefore need to generate different string literals base on the state. + let differenceSign = difference < 0 ? "" : "+" + if differencePercent != 0 { + let stringFormat = NSLocalizedString( + "insights.visitorsLineChartCell.differenceLabelWithPercentage", + value: "%@%@ (%@%%)", + comment: "Difference label for Insights Overview stat, indicating change from previous period, including percentage value. Example: +99.9K (5%)" + ) + return String.localizedStringWithFormat( + stringFormat, + differenceSign, + difference.abbreviatedString(), + differencePercent.abbreviatedString() + ) + } else { + let stringFormat = NSLocalizedString( + "insights.visitorsLineChartCell.differenceLabelWithoutPercentage", + value: "%@%@", + comment: "Difference label for Insights Overview stat, indicating change from previous period. Example: +99.9K" + ) + return String.localizedStringWithFormat( + stringFormat, + differenceSign, + difference.abbreviatedString() + ) + } } var differenceTextColor: UIColor { From 6e9225f725597015774ae1d300aba0d4b7d127ad Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 13:38:34 +1100 Subject: [PATCH 10/15] Update strings for localization --- .../Resources/en.lproj/Localizable.strings | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/WordPress/Resources/en.lproj/Localizable.strings b/WordPress/Resources/en.lproj/Localizable.strings index 6444316a74b6..d54bdf825659 100644 --- a/WordPress/Resources/en.lproj/Localizable.strings +++ b/WordPress/Resources/en.lproj/Localizable.strings @@ -130,8 +130,7 @@ /* Let's the user know that a third party sharing service was reconnected. The %@ is a placeholder for the service name. */ "%@ was reconnected." = "%@ was reconnected."; -/* Difference label for Insights Overview stat, indicating change from previous period. Ex: +99.9K(5%) - Difference label for Period Overview stat, indicating change from previous period. Ex: +99.9K (5%) */ +/* Difference label for Period Overview stat, indicating change from previous period. Ex: +99.9K (5%) */ "%@%@ (%@%%)" = "%1$@%2$@ (%3$@%%)"; /* Accessibility label for a post in the post list. The parameters are the title, and date respectively. For example, \"Let it Go, 1 hour ago.\" */ @@ -1798,9 +1797,6 @@ /* A label title. */ "Comments per page" = "Comments per page"; -/* Insights 'Comments Total' header */ -"Comments Total" = "Comments Total"; - /* Setting: WordPress.com Community */ "Community" = "Community"; @@ -3404,9 +3400,6 @@ Label for number of followers. */ "Followers" = "Followers"; -/* Insights 'Followers Total' header */ -"Followers Total" = "Followers Total"; - /* Accessibility label for following buttons. Title of the Following Reader tab User is following the blog. @@ -3991,6 +3984,12 @@ /* Title displayed on the feature introduction view that announces the updated Stats Insight screen. */ "Insights update" = "Insights update"; +/* Difference label for Insights Overview stat, indicating change from previous period. Example: +99.9K */ +"insights.visitorsLineChartCell.differenceLabelWithoutPercentage" = "%1$@%2$@"; + +/* Difference label for Insights Overview stat, indicating change from previous period, including percentage value. Example: +99.9K (5%) */ +"insights.visitorsLineChartCell.differenceLabelWithPercentage" = "%1$@%2$@ (%3$@%%)"; + /* Button label to install a plugin Confirmation button displayd in alert displayed when user installs their first plugin. */ "Install" = "Install"; @@ -4172,7 +4171,8 @@ /* Message to show when Publicize connection synchronization failed */ "Jetpack Social connection synchronization failed" = "Jetpack Social connection synchronization failed"; -/* Section title for Publicize services in Sharing screen */ +/* Insights 'Jetpack Social Connections' header + Section title for Publicize services in Sharing screen */ "Jetpack Social Connections" = "Jetpack Social Connections"; /* Message to show when Publicize service synchronization failed */ @@ -4217,9 +4217,6 @@ /* Post a photo prompt for the jetpack prologue */ "jetpack.prologue.prompt.postPhoto" = "Post a photo"; -/* Read an article prompt for the jetpack prologue */ -"jetpack.prologue.prompt.readArticle" = "Read an article"; - /* Respond to comments prompt for the jetpack prologue */ "jetpack.prologue.prompt.respondComments" = "Respond to comments"; @@ -4229,8 +4226,8 @@ /* Search for plugins prompt for the jetpack prologue */ "jetpack.prologue.prompt.searchPlugins" = "Search for plugins"; -/* Search for posts or sites prompt for the jetpack prologue */ -"jetpack.prologue.prompt.searchPosts" = "Search for posts or sites"; +/* Update a plugin prompt for the jetpack prologue */ +"jetpack.prologue.prompt.updatePlugin" = "Update a plugin"; /* Watch your stats prompt for the jetpack prologue */ "jetpack.prologue.prompt.watchStats" = "Watch your stats"; @@ -4397,9 +4394,6 @@ /* VoiceOver accessibility hint, informing the user the button can be used to like a comment */ "Likes the Comment." = "Likes the Comment."; -/* Insights 'Likes Total' header */ -"Likes Total" = "Likes Total"; - /* Message to show when a request for a WP.com API endpoint is throttled */ "Limit reached. You can try again in 1 minute. Trying again before that will only increase the time you have to wait before the ban is lifted. If you think this is in error, contact support." = "Limit reached. You can try again in 1 minute. Trying again before that will only increase the time you have to wait before the ban is lifted. If you think this is in error, contact support."; @@ -4907,6 +4901,7 @@ /* Label for a button that moves a page to the trash folder Label for a option that moves a post to the trash folder + Title for button on the comment details page that moves the comment to trash when tapped. Trash option in the trash confirmation alert. Trash option in the trash page confirmation alert. Trashes the comment */ @@ -6175,9 +6170,6 @@ Text for privacy settings: Public */ "Public" = "Public"; -/* Insights 'Publicize' header */ -"Publicize" = "Publicize"; - /* Button shown when the author is asked for publishing confirmation. Button title. Publishes a post. Label for the publish (verb) button. Tapping publishes a draft post. @@ -7075,6 +7067,9 @@ Verb. Title of a button. Pressing lets the user share a post to others. */ "Share" = "Share"; +/* Accessibility label for button to share a comment from a notification */ +"Share comment" = "Share comment"; + /* Informational text for Collect Information setting */ "Share information with our analytics tool about your use of services while logged in to your WordPress.com account." = "Share information with our analytics tool about your use of services while logged in to your WordPress.com account."; @@ -7539,6 +7534,9 @@ /* The status of the post. Should be the same as in core WP. */ "Status" = "Status"; +/* Section title for the moderation section of the comment details screen. */ +"STATUS" = "STATUS"; + /* Title of the first alert preparing users to grant permission for us to send them push notifications. */ "Stay in the loop" = "Stay in the loop"; @@ -8401,13 +8399,18 @@ /* Label for total followers */ "Total" = "Total"; -/* 'This Year' label for total number of comments. */ +/* 'This Year' label for total number of comments. + Insights 'Total Comments' header */ "Total Comments" = "Total Comments"; /* Label displaying total number of Email followers. %@ is the total. */ "Total Email Followers: %@" = "Total Email Followers: %@"; -/* 'This Year' label for total number of likes. */ +/* Insights 'Total Followers' header */ +"Total Followers" = "Total Followers"; + +/* 'This Year' label for total number of likes. + Insights 'Total Likes' header */ "Total Likes" = "Total Likes"; /* 'This Year' label for the total number of posts. */ From 47c1500ee30af365a4498e6cf449196f7d5f9595 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 20:04:08 +1100 Subject: [PATCH 11/15] Fix a typo in a comment Co-authored-by: Olivier Halligon --- .../Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift b/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift index feaff9d29b99..77222c7662e4 100644 --- a/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift +++ b/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift @@ -56,7 +56,7 @@ struct StatsSegmentedControlData { var differenceLabel: String { // We want to show something like "+1.2K (5%)" if we have a percentage difference and "1.2K" if we don't. // Because localized strings need to be strings literal, we cannot embed any conditional logic in the `localizedString...` call. - // We therefore need to generate different string literals base on the state. + // We therefore need to generate different string literals based on the state. let differenceSign = difference < 0 ? "" : "+" if differencePercent != 0 { let stringFormat = NSLocalizedString( From 7e7210dd8f382be49e3e618df05e7f9c09d1ac8b Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 22:02:58 +1100 Subject: [PATCH 12/15] Tweak a localization to remove any assumption on "+" localization See discussion at https://github.com/wordpress-mobile/WordPress-iOS/pull/19472#discussion_r996700821 --- .../ViewsVisitorsLineChartCell.swift | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift b/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift index 77222c7662e4..78c50d7d535d 100644 --- a/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift +++ b/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift @@ -57,30 +57,45 @@ struct StatsSegmentedControlData { // We want to show something like "+1.2K (5%)" if we have a percentage difference and "1.2K" if we don't. // Because localized strings need to be strings literal, we cannot embed any conditional logic in the `localizedString...` call. // We therefore need to generate different string literals based on the state. - let differenceSign = difference < 0 ? "" : "+" - if differencePercent != 0 { - let stringFormat = NSLocalizedString( - "insights.visitorsLineChartCell.differenceLabelWithPercentage", - value: "%@%@ (%@%%)", + switch (difference > 0, differencePercent != 0) { + case (true, true): // E.g.: +1.2k (5%) + stringFormat = NSLocalizedString( + "insights.visitorsLineChartCell.differenceLabelPosiviteWithPercentage", + value: "+%@ (%@%%)", comment: "Difference label for Insights Overview stat, indicating change from previous period, including percentage value. Example: +99.9K (5%)" ) return String.localizedStringWithFormat( stringFormat, - differenceSign, difference.abbreviatedString(), differencePercent.abbreviatedString() ) - } else { - let stringFormat = NSLocalizedString( - "insights.visitorsLineChartCell.differenceLabelWithoutPercentage", - value: "%@%@", + case (true, false): // E.g.: +1.2k + // We cannot assume every locale would translate an English string like "+1.2k" in the same way. + // So, even though we have only a "+" prefix, we ought to make this string localized. + stringFormat = NSLocalizedString( + "insights.visitorsLineChartCell.differenceLabelPosiviteWithoutPercentage", + value: "+%@", comment: "Difference label for Insights Overview stat, indicating change from previous period. Example: +99.9K" ) return String.localizedStringWithFormat( stringFormat, - differenceSign, difference.abbreviatedString() ) + case (false, true): // E.g. 1.2k (5%) + stringFormat = NSLocalizedString( + "insights.visitorsLineChartCell.differenceLabelNotPosiviteWithPercentage", + value: "%@ (%@%%)", + comment: "Difference label for Insights Overview stat, indicating change from previous period, including percentage value, when the change is 0 or less. Example: 99.9K (5%)" + ) + return String.localizedStringWithFormat( + stringFormat, + difference.abbreviatedString(), + differencePercent.abbreviatedString() + ) + break + case (false, false): // E.g.: 1.2k + // There's no + sign nor percentage value here, we don't need to add any localization treatment. + return difference.abbreviatedString() } } From daec387a70218ba91c4799c1cb2e54193dc44329 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 17 Oct 2022 22:09:28 +1100 Subject: [PATCH 13/15] Update strings for localization --- WordPress/Resources/en.lproj/Localizable.strings | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/WordPress/Resources/en.lproj/Localizable.strings b/WordPress/Resources/en.lproj/Localizable.strings index d54bdf825659..6e11246c0392 100644 --- a/WordPress/Resources/en.lproj/Localizable.strings +++ b/WordPress/Resources/en.lproj/Localizable.strings @@ -3984,11 +3984,14 @@ /* Title displayed on the feature introduction view that announces the updated Stats Insight screen. */ "Insights update" = "Insights update"; +/* Difference label for Insights Overview stat, indicating change from previous period, including percentage value, when the change is 0 or less. Example: 99.9K (5%) */ +"insights.visitorsLineChartCell.differenceLabelNotPosiviteWithPercentage" = "%1$@ (%2$@%%)"; + /* Difference label for Insights Overview stat, indicating change from previous period. Example: +99.9K */ -"insights.visitorsLineChartCell.differenceLabelWithoutPercentage" = "%1$@%2$@"; +"insights.visitorsLineChartCell.differenceLabelPosiviteWithoutPercentage" = "+%@"; /* Difference label for Insights Overview stat, indicating change from previous period, including percentage value. Example: +99.9K (5%) */ -"insights.visitorsLineChartCell.differenceLabelWithPercentage" = "%1$@%2$@ (%3$@%%)"; +"insights.visitorsLineChartCell.differenceLabelPosiviteWithPercentage" = "+%1$@ (%2$@%%)"; /* Button label to install a plugin Confirmation button displayd in alert displayed when user installs their first plugin. */ From cd7b1311c47ddf1ca3668f7383e291dad7ccba13 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 18 Oct 2022 12:19:01 +1100 Subject: [PATCH 14/15] Refine `differenceLabel` implementation and add tests --- .../ViewsVisitorsLineChartCell.swift | 51 ++++++++----------- WordPress/WordPress.xcodeproj/project.pbxproj | 8 ++- .../StatsSegmentedControlDataTests.swift | 48 +++++++++++++++++ 3 files changed, 74 insertions(+), 33 deletions(-) create mode 100644 WordPress/WordPressTest/StatsSegmentedControlDataTests.swift diff --git a/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift b/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift index 78c50d7d535d..0769cc600175 100644 --- a/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift +++ b/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift @@ -54,48 +54,37 @@ struct StatsSegmentedControlData { } var differenceLabel: String { - // We want to show something like "+1.2K (5%)" if we have a percentage difference and "1.2K" if we don't. - // Because localized strings need to be strings literal, we cannot embed any conditional logic in the `localizedString...` call. - // We therefore need to generate different string literals based on the state. - switch (difference > 0, differencePercent != 0) { - case (true, true): // E.g.: +1.2k (5%) - stringFormat = NSLocalizedString( - "insights.visitorsLineChartCell.differenceLabelPosiviteWithPercentage", - value: "+%@ (%@%%)", - comment: "Difference label for Insights Overview stat, indicating change from previous period, including percentage value. Example: +99.9K (5%)" + // We want to show something like "+10.2K (+5%)" if we have a percentage difference and "1.2K" if we don't. + // + // Negative cases automatically appear with a negative sign "-10.2K (-5%)" by using `abbreviatedString()`. + // `abbreviatedString()` also handles formatting big numbers, i.e. 10,200 will become 10.2K. + let formatter = NumberFormatter() + formatter.locale = .current + let plusSign = difference <= 0 ? "" : "\(formatter.plusSign ?? "")" + + if differencePercent != 0 { + let stringFormat = NSLocalizedString( + "insights.visitorsLineChartCell.differenceLabelWithPercentage", + value: "%1$@%2$@ (%3$@%%)", + comment: "Text for the Insights Overview stat difference label. Shows the change from the previous period, including the percentage value. E.g.: +12.3K (5%). %1$@ is the placeholder for the change sign ('-', '+', or none). %2$@ is the placeholder for the change numerical value. %3$@ is the placeholder for the change percentage value, excluding the % sign." ) return String.localizedStringWithFormat( stringFormat, + plusSign, difference.abbreviatedString(), differencePercent.abbreviatedString() ) - case (true, false): // E.g.: +1.2k - // We cannot assume every locale would translate an English string like "+1.2k" in the same way. - // So, even though we have only a "+" prefix, we ought to make this string localized. - stringFormat = NSLocalizedString( - "insights.visitorsLineChartCell.differenceLabelPosiviteWithoutPercentage", - value: "+%@", - comment: "Difference label for Insights Overview stat, indicating change from previous period. Example: +99.9K" + } else { + let stringFormat = NSLocalizedString( + "insights.visitorsLineChartCell.differenceLabelWithoutPercentage", + value: "%1$@%2$@", + comment: "Text for the Insights Overview stat difference label. Shows the change from the previous period. E.g.: +12.3K. %1$@ is the placeholder for the change sign ('-', '+', or none). %2$@ is the placeholder for the change numerical value." ) return String.localizedStringWithFormat( stringFormat, + plusSign, difference.abbreviatedString() ) - case (false, true): // E.g. 1.2k (5%) - stringFormat = NSLocalizedString( - "insights.visitorsLineChartCell.differenceLabelNotPosiviteWithPercentage", - value: "%@ (%@%%)", - comment: "Difference label for Insights Overview stat, indicating change from previous period, including percentage value, when the change is 0 or less. Example: 99.9K (5%)" - ) - return String.localizedStringWithFormat( - stringFormat, - difference.abbreviatedString(), - differencePercent.abbreviatedString() - ) - break - case (false, false): // E.g.: 1.2k - // There's no + sign nor percentage value here, we don't need to add any localization treatment. - return difference.abbreviatedString() } } diff --git a/WordPress/WordPress.xcodeproj/project.pbxproj b/WordPress/WordPress.xcodeproj/project.pbxproj index 70ace6b4063d..bd60643f13aa 100644 --- a/WordPress/WordPress.xcodeproj/project.pbxproj +++ b/WordPress/WordPress.xcodeproj/project.pbxproj @@ -748,6 +748,7 @@ 3FEC241525D73E8B007AFE63 /* ConfettiView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FEC241425D73E8B007AFE63 /* ConfettiView.swift */; }; 3FF1A853242D5FCB00373F5D /* WPTabBarController+ReaderTabNavigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FF1A852242D5FCB00373F5D /* WPTabBarController+ReaderTabNavigation.swift */; }; 3FFA5ED22876152E00830E28 /* JetpackButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FFA5ED12876152E00830E28 /* JetpackButton.swift */; }; + 3FFE3C0828FE00D10021BB96 /* StatsSegmentedControlDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FFE3C0728FE00D10021BB96 /* StatsSegmentedControlDataTests.swift */; }; 400199AB222590E100EB0906 /* AllTimeStatsRecordValueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 400199AA222590E100EB0906 /* AllTimeStatsRecordValueTests.swift */; }; 400199AD22259FF300EB0906 /* AnnualAndMostPopularTimeStatsRecordValueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 400199AC22259FF300EB0906 /* AnnualAndMostPopularTimeStatsRecordValueTests.swift */; }; 400A2C772217A8A0000A8A59 /* VisitsSummaryStatsRecordValue+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 400A2C752217A8A0000A8A59 /* VisitsSummaryStatsRecordValue+CoreDataClass.swift */; }; @@ -6091,6 +6092,7 @@ 3FEC241425D73E8B007AFE63 /* ConfettiView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfettiView.swift; sourceTree = ""; }; 3FF1A852242D5FCB00373F5D /* WPTabBarController+ReaderTabNavigation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WPTabBarController+ReaderTabNavigation.swift"; sourceTree = ""; }; 3FFA5ED12876152E00830E28 /* JetpackButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackButton.swift; sourceTree = ""; }; + 3FFE3C0728FE00D10021BB96 /* StatsSegmentedControlDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsSegmentedControlDataTests.swift; sourceTree = ""; }; 400199AA222590E100EB0906 /* AllTimeStatsRecordValueTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllTimeStatsRecordValueTests.swift; sourceTree = ""; }; 400199AC22259FF300EB0906 /* AnnualAndMostPopularTimeStatsRecordValueTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnnualAndMostPopularTimeStatsRecordValueTests.swift; sourceTree = ""; }; 400A2C752217A8A0000A8A59 /* VisitsSummaryStatsRecordValue+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VisitsSummaryStatsRecordValue+CoreDataClass.swift"; sourceTree = ""; }; @@ -10957,9 +10959,12 @@ 40F50B7F221310D400CBBB73 /* FollowersStatsRecordValueTests.swift */, 40E7FEC72211EEC00032834E /* LastPostStatsRecordValueTests.swift */, 40EE948122132F5800CD264F /* PublicizeConectionStatsRecordValueTests.swift */, + 938466B82683CA0E00A538DC /* ReferrerDetailsViewModelTests.swift */, 400A2C922217B463000A8A59 /* ReferrerStatsRecordValueTests.swift */, 40C403ED2215CE9500E8C894 /* SearchResultsStatsRecordValueTests.swift */, + 3FDDFE9527C8178C00606933 /* SiteStatsInformationTests.swift */, 40E7FEC42211DF790032834E /* StatsRecordTests.swift */, + 3FFE3C0728FE00D10021BB96 /* StatsSegmentedControlDataTests.swift */, 40F50B81221310F000CBBB73 /* StatsTestCase.swift */, 931215E0267DE1C0008C3B69 /* StatsTotalRowDataTests.swift */, 4054F4632214F94D00D261AB /* StreakStatsRecordValueTests.swift */, @@ -10969,8 +10974,6 @@ 40C403F72215D88100E8C894 /* TopViewedStatsTests.swift */, 400A2C942217B68D000A8A59 /* TopViewedVideoStatsRecordValueTests.swift */, 400A2C962217B883000A8A59 /* VisitsSummaryStatsRecordValueTests.swift */, - 938466B82683CA0E00A538DC /* ReferrerDetailsViewModelTests.swift */, - 3FDDFE9527C8178C00606933 /* SiteStatsInformationTests.swift */, ); name = Stats; sourceTree = ""; @@ -22204,6 +22207,7 @@ C738CB0F28626466001BE107 /* QRLoginScanningCoordinatorTests.swift in Sources */, 8B6214E627B1B446001DF7B6 /* BlogDashboardServiceTests.swift in Sources */, C856749A243F4292001A995E /* TenorMockDataHelper.swift in Sources */, + 3FFE3C0828FE00D10021BB96 /* StatsSegmentedControlDataTests.swift in Sources */, D81C2F5820F86CEA002AE1F1 /* NetworkStatus.swift in Sources */, E1C545801C6C79BB001CEB0E /* MediaSettingsTests.swift in Sources */, C3439B5F27FE3A3C0058DA55 /* SiteCreationWizardLauncherTests.swift in Sources */, diff --git a/WordPress/WordPressTest/StatsSegmentedControlDataTests.swift b/WordPress/WordPressTest/StatsSegmentedControlDataTests.swift new file mode 100644 index 000000000000..f0914ec1f0e5 --- /dev/null +++ b/WordPress/WordPressTest/StatsSegmentedControlDataTests.swift @@ -0,0 +1,48 @@ +import Nimble +import XCTest +@testable import WordPress + +class StatsSegmentedControlDataTests: XCTestCase { + + func testDifferenceLabel() { + expect(StatsSegmentedControlData.fixture(difference: -12_345, differencePercent: -1).differenceLabel) + == "-12.3K (-1%)" + expect(StatsSegmentedControlData.fixture(difference: -12_345, differencePercent: 0).differenceLabel) + == "-12.3K" + expect(StatsSegmentedControlData.fixture(difference: -12_345, differencePercent: 1).differenceLabel) + == "-12.3K (1%)" + expect(StatsSegmentedControlData.fixture(difference: 0, differencePercent: -1).differenceLabel) + == "0 (-1%)" + expect(StatsSegmentedControlData.fixture(difference: 0, differencePercent: 0).differenceLabel) + == "0" + expect(StatsSegmentedControlData.fixture(difference: 0, differencePercent: 1).differenceLabel) + == "0 (1%)" + expect(StatsSegmentedControlData.fixture(difference: 12_345, differencePercent: -1).differenceLabel) + == "+12.3K (-1%)" + expect(StatsSegmentedControlData.fixture(difference: 12_345, differencePercent: 0).differenceLabel) + == "+12.3K" + expect(StatsSegmentedControlData.fixture(difference: 12_345, differencePercent: 1).differenceLabel) + == "+12.3K (1%)" + } +} + +extension StatsSegmentedControlData { + + static func fixture( + segmentTitle: String = "title", + segmentData: Int = 0, + segmentPrevData: Int = 1, + difference: Int = 2, + differenceText: String = "text", + differencePercent: Int = 3 + ) -> StatsSegmentedControlData { + StatsSegmentedControlData( + segmentTitle: segmentTitle, + segmentData: segmentData, + segmentPrevData: segmentPrevData, + difference: difference, + differenceText: differenceText, + differencePercent: differencePercent + ) + } +} From ede3b8e55bb2b3073e43125b5cae601ae1f4982b Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 18 Oct 2022 12:58:06 +1100 Subject: [PATCH 15/15] Update strings for localization --- WordPress/Resources/en.lproj/Localizable.strings | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/WordPress/Resources/en.lproj/Localizable.strings b/WordPress/Resources/en.lproj/Localizable.strings index 6e11246c0392..4fe4f3f5070f 100644 --- a/WordPress/Resources/en.lproj/Localizable.strings +++ b/WordPress/Resources/en.lproj/Localizable.strings @@ -3984,14 +3984,11 @@ /* Title displayed on the feature introduction view that announces the updated Stats Insight screen. */ "Insights update" = "Insights update"; -/* Difference label for Insights Overview stat, indicating change from previous period, including percentage value, when the change is 0 or less. Example: 99.9K (5%) */ -"insights.visitorsLineChartCell.differenceLabelNotPosiviteWithPercentage" = "%1$@ (%2$@%%)"; +/* Text for the Insights Overview stat difference label. Shows the change from the previous period. E.g.: +12.3K. %1$@ is the placeholder for the change sign ('-', '+', or none). %2$@ is the placeholder for the change numerical value. */ +"insights.visitorsLineChartCell.differenceLabelWithoutPercentage" = "%1$@%2$@"; -/* Difference label for Insights Overview stat, indicating change from previous period. Example: +99.9K */ -"insights.visitorsLineChartCell.differenceLabelPosiviteWithoutPercentage" = "+%@"; - -/* Difference label for Insights Overview stat, indicating change from previous period, including percentage value. Example: +99.9K (5%) */ -"insights.visitorsLineChartCell.differenceLabelPosiviteWithPercentage" = "+%1$@ (%2$@%%)"; +/* Text for the Insights Overview stat difference label. Shows the change from the previous period, including the percentage value. E.g.: +12.3K (5%). %1$@ is the placeholder for the change sign ('-', '+', or none). %2$@ is the placeholder for the change numerical value. %3$@ is the placeholder for the change percentage value, excluding the % sign. */ +"insights.visitorsLineChartCell.differenceLabelWithPercentage" = "%1$@%2$@ (%3$@%%)"; /* Button label to install a plugin Confirmation button displayd in alert displayed when user installs their first plugin. */