Skip to content

Commit 36408b0

Browse files
authored
Remove localized strings from AppConstants (#24293)
* Remove AppConstants.AboutScreen * Remove AppConstants.AppRatings * Remove shareTitle * Replace Settings * Remove AppConstants.Settings * Remove AppConstants.Logout
1 parent 1aab54f commit 36408b0

File tree

10 files changed

+101
-69
lines changed

10 files changed

+101
-69
lines changed

WordPress/Classes/Utility/App Configuration/AppConstants.swift

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,3 @@ import WordPressKit
1414
static let mobileAnnounceAppId = "2"
1515
@objc static let authKeychainServiceName = "public-api.wordpress.com"
1616
}
17-
18-
// MARK: - Localized Strings
19-
extension AppConstants {
20-
21-
struct AboutScreen {
22-
static let blogName = NSLocalizedString("News", comment: "Title of a button that displays the WordPress.org blog")
23-
static let workWithUs = NSLocalizedString("Contribute", comment: "Title of button that displays the WordPress.org contributor page")
24-
static let workWithUsURL = "https://make.wordpress.org/mobile/handbook"
25-
}
26-
27-
struct AppRatings {
28-
static let prompt = NSLocalizedString("appRatings.wordpress.prompt", value: "What do you think about WordPress?", comment: "This is the string we display when prompting the user to review the WordPress app")
29-
}
30-
31-
struct Settings {
32-
static let aboutTitle: String = NSLocalizedString("About WordPress", comment: "Link to About screen for WordPress for iOS")
33-
static let shareButtonTitle = NSLocalizedString("Share WordPress with a friend", comment: "Title for a button that recommends the app to others")
34-
static let whatIsNewTitle = NSLocalizedString("What's New in WordPress", comment: "Opens the What's New / Feature Announcement modal")
35-
}
36-
37-
struct Logout {
38-
static let alertTitle = NSLocalizedString("Log out of WordPress?", comment: "LogOut confirmation text, whenever there are no local changes")
39-
}
40-
41-
struct Zendesk {
42-
static let ticketSubject = NSLocalizedString("WordPress for iOS Support", comment: "Subject of new Zendesk ticket.")
43-
}
44-
}

WordPress/Classes/Utility/ZendeskUtils.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import BuildSettingsKit
23
import WordPressAuthenticator
34
import WordPressKit
45
import WordPressShared
@@ -1107,7 +1108,6 @@ private extension ZendeskUtils {
11071108
static let unknownValue = "unknown"
11081109
static let noValue = "none"
11091110
static let platformTag = "iOS"
1110-
static let ticketSubject = AppConstants.Zendesk.ticketSubject
11111111
static let blogSeperator = "\n----------\n"
11121112
static let jetpackTag = "jetpack"
11131113
static let wpComTag = "wpcom"
@@ -1121,6 +1121,15 @@ private extension ZendeskUtils {
11211121
static let sourcePlatform = AppConstants.zendeskSourcePlatform
11221122
static let gutenbergIsDefault = "mobile_gutenberg_is_default"
11231123
static let mobileSelfHosted = "selected_site_self_hosted"
1124+
1125+
static var ticketSubject: String {
1126+
switch BuildSettings.current.brand {
1127+
case .wordpress:
1128+
NSLocalizedString("WordPress for iOS Support", comment: "Subject of new Zendesk ticket.")
1129+
case .jetpack:
1130+
NSLocalizedString("Jetpack for iOS Support", comment: "Subject of new Zendesk ticket.")
1131+
}
1132+
}
11241133
}
11251134

11261135
enum TicketFieldIDs {

WordPress/Classes/ViewRelated/Me/App Settings/About/AppAboutScreenConfiguration.swift

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import BuildSettingsKit
23
import WordPressUI
34
import UIKit
45
import WordPressShared
@@ -48,7 +49,7 @@ class AppAboutScreenConfiguration: AboutScreenConfiguration {
4849
self?.tracker.buttonPressed(.twitter)
4950
self?.webViewPresenter.presentInNavigationControlller(url: Links.twitter, context: context)
5051
}),
51-
AboutItem(title: AppConstants.AboutScreen.blogName, subtitle: AppConstants.productBlogDisplayURL, cellStyle: .value1, action: { [weak self] context in
52+
AboutItem(title: Strings.current.blogName, subtitle: AppConstants.productBlogDisplayURL, cellStyle: .value1, action: { [weak self] context in
5253
self?.tracker.buttonPressed(.blog)
5354
self?.webViewPresenter.presentInNavigationControlller(url: Links.blog, context: context)
5455
})
@@ -68,7 +69,7 @@ class AppAboutScreenConfiguration: AboutScreenConfiguration {
6869
AboutItem(title: "", cellStyle: .appLogos, accessoryType: .none)
6970
] : nil,
7071
[
71-
AboutItem(title: AppConstants.AboutScreen.workWithUs, subtitle: TextContent.workWithUsSubtitle, cellStyle: .subtitle, accessoryType: .disclosureIndicator, action: { [weak self] context in
72+
AboutItem(title: Strings.current.workWithUs, subtitle: TextContent.workWithUsSubtitle, cellStyle: .subtitle, accessoryType: .disclosureIndicator, action: { [weak self] context in
7273
self?.tracker.buttonPressed(.workWithUs)
7374
self?.webViewPresenter.presentInNavigationControlller(url: Links.workWithUs, context: context)
7475
}),
@@ -104,7 +105,7 @@ class AppAboutScreenConfiguration: AboutScreenConfiguration {
104105
private enum Links {
105106
static let twitter = URL(string: AppConstants.productTwitterURL)!
106107
static let blog = URL(string: AppConstants.productBlogURL)!
107-
static let workWithUs = URL(string: AppConstants.AboutScreen.workWithUsURL)!
108+
static let workWithUs = URL(string: Strings.current.workWithUsURL)!
108109
static let automattic = URL(string: "https://automattic.com")!
109110
}
110111
}
@@ -166,3 +167,28 @@ class LegalAndMoreSubmenuConfiguration: AboutScreenConfiguration {
166167
static let sourceCode = URL(string: WPGithubMainURL)!
167168
}
168169
}
170+
171+
private struct Strings {
172+
var blogName: String
173+
var workWithUs: String
174+
var workWithUsURL: String
175+
176+
static var current: Strings {
177+
switch BuildSettings.current.brand {
178+
case .wordpress: .wordpress
179+
case .jetpack: .jetpack
180+
}
181+
}
182+
183+
static let wordpress = Strings(
184+
blogName: NSLocalizedString("News", comment: "Title of a button that displays the WordPress.org blog"),
185+
workWithUs: NSLocalizedString("Contribute", comment: "Title of button that displays the WordPress.org contributor page"),
186+
workWithUsURL: "https://make.wordpress.org/mobile/handbook"
187+
)
188+
189+
static let jetpack = Strings(
190+
blogName: NSLocalizedString("Blog", comment: "Title of a button that displays the WordPress.com blog"),
191+
workWithUs: NSLocalizedString("Work With Us", comment: "Title of button that displays the Automattic Work With Us web page"),
192+
workWithUsURL: "https://automattic.com/work-with-us"
193+
)
194+
}

WordPress/Classes/ViewRelated/Me/App Settings/AppSettingsViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,7 @@ private extension AppSettingsViewController {
589589
if let presenter = RootViewCoordinator.shared.whatIsNewScenePresenter as? WhatIsNewScenePresenter,
590590
presenter.versionHasAnnouncements,
591591
FeatureFlag.whatsNew.enabled {
592-
let whatIsNewRow = NavigationItemRow(title: AppConstants.Settings.whatIsNewTitle,
593-
action: presentWhatIsNew())
592+
let whatIsNewRow = NavigationItemRow(title: WhatIsNewScenePresenter.title, action: presentWhatIsNew())
594593
rows.append(whatIsNewRow)
595594
}
596595

WordPress/Classes/ViewRelated/Me/Me Main/MeViewController.swift

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import UIKit
2+
import BuildSettingsKit
23
import WordPressShared
34
import AutomatticAbout
45

@@ -559,7 +560,7 @@ extension MeViewController: SearchableActivityConvertable {
559560

560561
// MARK: - Constants
561562

562-
private extension MeViewController {
563+
extension MeViewController {
563564
enum RowTitles {
564565
static let appSettings = NSLocalizedString("App Settings", comment: "Link to App Settings section")
565566
static let myProfile = NSLocalizedString("My Profile", comment: "Link to My Profile section")
@@ -568,15 +569,30 @@ private extension MeViewController {
568569
static let support = NSLocalizedString("Help & Support", comment: "Link to Help section")
569570
static let logIn = NSLocalizedString("Log In", comment: "Label for logging in to WordPress.com account")
570571
static let logOut = NSLocalizedString("Log Out", comment: "Label for logging out from WordPress.com account")
571-
static let about = AppConstants.Settings.aboutTitle
572+
static var about: String {
573+
switch BuildSettings.current.brand {
574+
case .wordpress:
575+
NSLocalizedString("About WordPress", comment: "Link to About screen for WordPress for iOS")
576+
case .jetpack:
577+
NSLocalizedString("About Jetpack for iOS", comment: "Link to About screen for Jetpack for iOS")
578+
}
579+
}
572580
}
573581

574582
enum HeaderTitles {
575583
static let wpAccount = NSLocalizedString("WordPress.com Account", comment: "WordPress.com sign-in/sign-out section header title")
576584
}
577585

578586
enum LogoutAlert {
579-
static let defaultTitle = AppConstants.Logout.alertTitle
587+
static var defaultTitle: String {
588+
switch BuildSettings.current.brand {
589+
case .wordpress:
590+
NSLocalizedString("Log out of WordPress?", comment: "LogOut confirmation text, whenever there are no local changes")
591+
case .jetpack:
592+
NSLocalizedString("Log out of Jetpack?", comment: "LogOut confirmation text, whenever there are no local changes")
593+
}
594+
}
595+
580596
static let unsavedTitleSingular = NSLocalizedString("You have changes to %d post that hasn't been uploaded to your site. Logging out now will delete those changes. Log out anyway?",
581597
comment: "Warning displayed before logging out. The %d placeholder will contain the number of local posts (SINGULAR!)")
582598
static let unsavedTitlePlural = NSLocalizedString("You have changes to %d posts that haven’t been uploaded to your site. Logging out now will delete those changes. Log out anyway?",

WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationsViewController+AppRatings.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import UIKit
2+
import BuildSettingsKit
13
import StoreKit
24

35
// MARK: - App Ratings
@@ -6,7 +8,7 @@ extension NotificationsViewController {
68
static let contactURL = "https://support.wordpress.com/contact/"
79

810
func setupAppRatings() {
9-
inlinePromptView.setupHeading(AppConstants.AppRatings.prompt)
11+
inlinePromptView.setupHeading(ratingPrompt)
1012
let yesTitle = NSLocalizedString("notifications.appRatings.prompt.yes.buttonTitle", value: "I like it",
1113
comment: "This is one of the buttons we display inside of the prompt to review the app")
1214
let noTitle = NSLocalizedString("notifications.appRatings.prompt.no.buttonTitle", value: "Could improve",
@@ -87,3 +89,12 @@ extension NotificationsViewController {
8789
hideInlinePrompt(delay: 0.0)
8890
}
8991
}
92+
93+
private var ratingPrompt: String {
94+
switch BuildSettings.current.brand {
95+
case .wordpress:
96+
NSLocalizedString("appRatings.wordpress.prompt", value: "What do you think about WordPress?", comment: "This is the string we display when prompting the user to review the WordPress app")
97+
case .jetpack:
98+
NSLocalizedString("appRatings.jetpack.prompt", value: "What do you think about Jetpack?", comment: "This is the string we display when prompting the user to review the Jetpack app")
99+
}
100+
}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1+
import UIKit
2+
import BuildSettingsKit
3+
14
/// Constants for share app content interoperability with table view.
25
///
36
extension ShareAppContentPresenter {
47
struct RowConstants {
5-
static let buttonTitle = AppConstants.Settings.shareButtonTitle
8+
static var buttonTitle: String {
9+
switch BuildSettings.current.brand {
10+
case .wordpress:
11+
NSLocalizedString("Share WordPress with a friend", comment: "Title for a button that recommends the app to others")
12+
case .jetpack:
13+
NSLocalizedString("Share Jetpack with a friend", comment: "Title for a button that recommends the app to others")
14+
}
15+
}
16+
617
static let buttonIconImage: UIImage? = .init(systemName: "square.and.arrow.up")
718
}
819
}

WordPress/Classes/ViewRelated/Support/LogOutActionHandler.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import UIKit
2+
import BuildSettingsKit
23

34
struct LogOutActionHandler {
45

@@ -33,7 +34,10 @@ struct LogOutActionHandler {
3334
}
3435

3536
private struct Strings {
36-
static let alertDefaultTitle = AppConstants.Logout.alertTitle
37+
static var alertDefaultTitle: String {
38+
MeViewController.LogoutAlert.defaultTitle
39+
}
40+
3741
static let alertUnsavedTitleSingular = NSLocalizedString("You have changes to %d post that hasn't been uploaded to your site. Logging out now will delete those changes. Log out anyway?",
3842
comment: "Warning displayed before logging out. The %d placeholder will contain the number of local posts (SINGULAR!)")
3943
static let alertUnsavedTitlePlural = NSLocalizedString("You have changes to %d posts that haven’t been uploaded to your site. Logging out now will delete those changes. Log out anyway?",

WordPress/Classes/ViewRelated/WhatsNew/Presenter/WhatIsNewScenePresenter.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import UIKit
2+
import BuildSettingsKit
13
import WordPressFlux
24

35
class WhatIsNewScenePresenter: ScenePresenter {
@@ -10,6 +12,8 @@ class WhatIsNewScenePresenter: ScenePresenter {
1012

1113
private let store: AnnouncementsStore
1214

15+
static var title: String { WhatIsNewStrings.title }
16+
1317
private func shouldPresentWhatIsNew(on viewController: UIViewController) -> Bool {
1418
if UIDevice.isPad() && versionsDisabledForIpad.contains(self.store.appVersionName) {
1519
return false
@@ -142,7 +146,15 @@ private extension WhatIsNewScenePresenter {
142146
}
143147

144148
enum WhatIsNewStrings {
145-
static let title = AppConstants.Settings.whatIsNewTitle
149+
static var title: String {
150+
switch BuildSettings.current.brand {
151+
case .wordpress:
152+
NSLocalizedString("What's New in WordPress", comment: "Opens the What's New / Feature Announcement modal")
153+
case .jetpack:
154+
NSLocalizedString("What's New in Jetpack", comment: "Opens the What's New / Feature Announcement modal")
155+
}
156+
}
157+
146158
static let versionPrefix = NSLocalizedString("Version ", comment: "Description for the version label in the What's new page.")
147159
static let continueButtonTitle = NSLocalizedString("Continue", comment: "Title for the continue button in the What's New page.")
148160
static let gotItButtonTitle = NSLocalizedString("Got it", comment: "Title for the continue button in the dashboard's custom What's New page.")

WordPress/Jetpack/AppConstants.swift

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,3 @@ import WordPressKit
1414
static let mobileAnnounceAppId = "6"
1515
@objc static let authKeychainServiceName = "jetpack.public-api.wordpress.com"
1616
}
17-
18-
// MARK: - Localized Strings
19-
extension AppConstants {
20-
21-
struct AboutScreen {
22-
static let blogName = NSLocalizedString("Blog", comment: "Title of a button that displays the WordPress.com blog")
23-
static let workWithUs = NSLocalizedString("Work With Us", comment: "Title of button that displays the Automattic Work With Us web page")
24-
static let workWithUsURL = "https://automattic.com/work-with-us"
25-
}
26-
27-
struct AppRatings {
28-
static let prompt = NSLocalizedString("appRatings.jetpack.prompt", value: "What do you think about Jetpack?", comment: "This is the string we display when prompting the user to review the Jetpack app")
29-
}
30-
31-
struct Settings {
32-
static let aboutTitle = NSLocalizedString("About Jetpack for iOS", comment: "Link to About screen for Jetpack for iOS")
33-
static let shareButtonTitle = NSLocalizedString("Share Jetpack with a friend", comment: "Title for a button that recommends the app to others")
34-
static let whatIsNewTitle = NSLocalizedString("What's New in Jetpack", comment: "Opens the What's New / Feature Announcement modal")
35-
}
36-
37-
struct Logout {
38-
static let alertTitle = NSLocalizedString("Log out of Jetpack?", comment: "LogOut confirmation text, whenever there are no local changes")
39-
}
40-
41-
struct Zendesk {
42-
static let ticketSubject = NSLocalizedString("Jetpack for iOS Support", comment: "Subject of new Zendesk ticket.")
43-
}
44-
}

0 commit comments

Comments
 (0)