Skip to content

Commit af44cd8

Browse files
author
Sharma Elanthiriayan
committed
Move localized strings to Localization enum.
1 parent 9bb6b8b commit af44cd8

File tree

1 file changed

+53
-49
lines changed

1 file changed

+53
-49
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewModel.swift

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,9 @@ private extension SettingsViewModel {
166166
func configureSections() {
167167
// Selected Store
168168
let selectedStoreSection: Section = {
169-
let selectedStoreTitle = NSLocalizedString(
170-
"Selected Store",
171-
comment: "My Store > Settings > Selected Store information section. " +
172-
"This is the heading listed above the information row that displays the store website and their username."
173-
).uppercased()
174-
175169
let storeRows: [Row] = sites.count > 1 ?
176170
[.selectedStore, .switchStore] : [.selectedStore]
177-
178-
return Section(title: selectedStoreTitle,
171+
return Section(title: Localization.selectedStoreTitle,
179172
rows: storeRows,
180173
footerHeight: UITableView.automaticDimension)
181174
}()
@@ -188,88 +181,57 @@ private extension SettingsViewModel {
188181
return nil
189182
}
190183

191-
let pluginsTitle = NSLocalizedString(
192-
"Plugins",
193-
comment: "My Store > Settings > Plugins section title"
194-
).uppercased()
195-
return Section(title: pluginsTitle,
184+
return Section(title: Localization.pluginsTitle,
196185
rows: [.plugins],
197186
footerHeight: UITableView.automaticDimension)
198187
}()
199188

200189
// Store settings
201-
let storeSettingsSection: Section = {
202-
let storeSettingsTitle = NSLocalizedString(
203-
"Store Settings",
204-
comment: "My Store > Settings > Store Settings section title"
205-
).uppercased()
206-
return Section(title: storeSettingsTitle,
207-
rows: [.inPersonPayments],
208-
footerHeight: UITableView.automaticDimension)
209-
}()
190+
let storeSettingsSection = Section(title: Localization.storeSettingsTitle,
191+
rows: [.inPersonPayments],
192+
footerHeight: UITableView.automaticDimension)
210193

211194
// Help & Feedback
212195
let helpAndFeedbackSection: Section = {
213-
let helpAndFeedbackTitle = NSLocalizedString(
214-
"Help & Feedback",
215-
comment: "My Store > Settings > Help and Feedback settings section title"
216-
).uppercased()
217-
218196
let rows: [Row]
219197
if couldShowBetaFeaturesRow {
220198
rows = [.support, .betaFeatures, .sendFeedback]
221199
} else {
222200
rows = [.support, .sendFeedback]
223201
}
224-
return Section(title: helpAndFeedbackTitle,
202+
return Section(title: Localization.helpAndFeedbackTitle,
225203
rows: rows,
226204
footerHeight: UITableView.automaticDimension)
227205
}()
228206

229207
// App Settings
230-
let appSettingsSection: Section = {
231-
let appSettingsTitle = NSLocalizedString(
232-
"App Settings",
233-
comment: "My Store > Settings > App (Application) settings section title"
234-
).uppercased()
235-
return Section(title: appSettingsTitle,
236-
rows: [.privacy],
237-
footerHeight: UITableView.automaticDimension)
238-
}()
208+
let appSettingsSection = Section(title: Localization.appSettingsTitle,
209+
rows: [.privacy],
210+
footerHeight: UITableView.automaticDimension)
239211

240212
// About the App
241213
let aboutTheAppSection: Section = {
242-
let aboutTheAppTitle = NSLocalizedString(
243-
"About the App",
244-
comment: "My Store > Settings > About the App (Application) section title"
245-
).uppercased()
246-
247214
let rows: [Row]
248215
// Show the whats new row only there is a non-nil announcement available.
249216
if announcement != nil {
250217
rows = [.about, .whatsNew, .licenses]
251218
} else {
252219
rows = [.about, .licenses]
253220
}
254-
return Section(title: aboutTheAppTitle,
221+
return Section(title: Localization.aboutTheAppTitle,
255222
rows: rows,
256223
footerHeight: UITableView.automaticDimension)
257224
}()
258225

259226
// Other
260227
let otherSection: Section = {
261-
let otherTitle = NSLocalizedString(
262-
"Other",
263-
comment: "My Store > Settings > Other app section"
264-
).uppercased()
265-
266228
let rows: [Row]
267229
#if DEBUG
268230
rows = [.deviceSettings, .wormholy]
269231
#else
270232
rows = [.deviceSettings]
271233
#endif
272-
return Section(title: otherTitle,
234+
return Section(title: Localization.otherTitle,
273235
rows: rows,
274236
footerHeight: CGFloat.leastNonzeroMagnitude)
275237
}()
@@ -344,3 +306,45 @@ private extension SettingsViewModel {
344306
true
345307
}
346308
}
309+
310+
// MARK: - Localizations
311+
//
312+
private extension SettingsViewModel {
313+
enum Localization {
314+
static let selectedStoreTitle = NSLocalizedString(
315+
"Selected Store",
316+
comment: "My Store > Settings > Selected Store information section. " +
317+
"This is the heading listed above the information row that displays the store website and their username."
318+
).uppercased()
319+
320+
static let pluginsTitle = NSLocalizedString(
321+
"Plugins",
322+
comment: "My Store > Settings > Plugins section title"
323+
).uppercased()
324+
325+
static let storeSettingsTitle = NSLocalizedString(
326+
"Store Settings",
327+
comment: "My Store > Settings > Store Settings section title"
328+
).uppercased()
329+
330+
static let helpAndFeedbackTitle = NSLocalizedString(
331+
"Help & Feedback",
332+
comment: "My Store > Settings > Help and Feedback settings section title"
333+
).uppercased()
334+
335+
static let appSettingsTitle = NSLocalizedString(
336+
"App Settings",
337+
comment: "My Store > Settings > App (Application) settings section title"
338+
).uppercased()
339+
340+
static let aboutTheAppTitle = NSLocalizedString(
341+
"About the App",
342+
comment: "My Store > Settings > About the App (Application) section title"
343+
).uppercased()
344+
345+
static let otherTitle = NSLocalizedString(
346+
"Other",
347+
comment: "My Store > Settings > Other app section"
348+
).uppercased()
349+
}
350+
}

0 commit comments

Comments
 (0)