Skip to content

Commit

Permalink
Merge pull request #1631 from planetary-social/bdm/perf-strings
Browse files Browse the repository at this point in the history
remove usage of xcstringstool-generated strings to improve performance #1458
  • Loading branch information
joshuatbrown authored Oct 18, 2024
2 parents 5af758a + 0aef48b commit fb3bc0f
Show file tree
Hide file tree
Showing 87 changed files with 857 additions and 521 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added a tip to the Feed to welcome first-time users and explain how the Feed works. [#1602](https://github.com/planetary-social/nos/issues/1602)
- Added a tag to published contact lists to help us detect the source of lost contact lists. [cleanstr#51](https://github.com/planetary-social/cleanstr/issues/51)
- Removed integration with Universal Name Space [#1636](https://github.com/planetary-social/nos/issues/1636)
- Remove most usage of xcstringstool-generated strings to improve performance. [#1458](https://github.com/planetary-social/nos/issues/1458)

### Internal Changes
- Migrate ObservableObject to @Observable where possible [#1458](https://github.com/planetary-social/nos/issues/1458)
Expand Down
4 changes: 2 additions & 2 deletions Nos/Controller/ContentWarningController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum ContentWarningType {

/// The name of the first author in the list of reports
private var firstAuthorSafeName: String {
authorNames.first ?? String(localized: .localizable.unknownAuthor)
authorNames.first ?? String(localized: "unknownAuthor")
}

/// The string explaining the reason(s) for the reports.
Expand All @@ -57,7 +57,7 @@ enum ContentWarningType {
.sorted()
.joined(separator: ", ")
if reasons.isEmpty {
return String(localized: .localizable.error)
return String(localized: "error")
} else {
return reasons
}
Expand Down
2 changes: 1 addition & 1 deletion Nos/Controller/RawEventController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protocol RawEventViewModel {
}

private func loadRawMessage() {
loadingMessage = String(localized: .localizable.loading)
loadingMessage = String(localized: "loading")

let rawMessage: String
do {
Expand Down
2 changes: 1 addition & 1 deletion Nos/Extensions/Date+Elapsed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ extension Date {
return formattedDate
}
} else {
return String(localized: .localizable.now)
return String(localized: "now")
}
}

Expand Down
10 changes: 5 additions & 5 deletions Nos/Models/AppDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ enum AppDestination: Hashable, Equatable {
var destinationString: String {
switch self {
case .home:
return String(localized: .localizable.homeFeed)
return String(localized: "homeFeed")
case .discover:
return String(localized: .localizable.discover)
return String(localized: "discover")
case .notifications:
return String(localized: .localizable.notifications)
return String(localized: "notifications")
case .noteComposer:
return String(localized: .localizable.newNote)
return String(localized: "newNote")
case .profile:
return String(localized: .localizable.profileTitle)
return String(localized: "profileTitle")
}
}

Expand Down
8 changes: 4 additions & 4 deletions Nos/Models/ExpirationTimeOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ enum ExpirationTimeOption: Double, Identifiable, CaseIterable {
var unit: String {
switch self {
case .oneHour:
return String(localized: .localizable.hourAbbreviated)
return String(localized: "hourAbbreviated")
case .oneDay:
return String(localized: .localizable.hoursAbbreviated)
return String(localized: "hoursAbbreviated")
case .sevenDays:
return String(localized: .localizable.daysAbbreviated)
return String(localized: "daysAbbreviated")
case .oneYear:
return String(localized: .localizable.daysAbbreviated)
return String(localized: "daysAbbreviated")
}
}

Expand Down
48 changes: 24 additions & 24 deletions Nos/Models/FlagOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ struct FlagOption: Identifiable, Equatable {
/// `FlagOption` instances representing different categories of how a content can can be flagged.
static let flagContentSendOptions: [FlagOption] = [
FlagOption(
title: String(localized: .localizable.flagSendToNosTitle),
description: String(localized: .localizable.flagSendToNosDescription),
title: String(localized: "flagSendToNosTitle"),
description: String(localized: "flagSendToNosDescription"),
info: { selectedTitle in
guard let selectedTitle = selectedTitle else { return nil }
return String(localized: .localizable.flagUserSendToNosInfo(selectedTitle))
return String.localizedStringWithFormat(String(localized: "flagUserSendToNosInfo"), selectedTitle)
},
category: .privacy(.sendToNos)
),
FlagOption(
title: String(localized: .localizable.flagPubliclyTitle),
description: String(localized: .localizable.flagPubliclyDescription),
title: String(localized: "flagPubliclyTitle"),
description: String(localized: "flagPubliclyDescription"),
info: nil,
category: .privacy(.publicly)
)
Expand All @@ -56,17 +56,17 @@ struct FlagOption: Identifiable, Equatable {
/// `FlagOption` instances representing different categories of how a user can be flagged.
static let flagUserSendOptions: [FlagOption] = [
FlagOption(
title: String(localized: .localizable.flagSendToNosTitle),
description: String(localized: .localizable.flagSendToNosDescription),
title: String(localized: "flagSendToNosTitle"),
description: String(localized: "flagSendToNosDescription"),
info: { selectedTitle in
guard let selectedTitle = selectedTitle else { return nil }
return String(localized: .localizable.flagUserSendToNosInfo(selectedTitle))
return String.localizedStringWithFormat(String(localized: "flagUserSendToNosInfo"), selectedTitle)
},
category: .privacy(.sendToNos)
),
FlagOption(
title: String(localized: .localizable.flagPubliclyTitle),
description: String(localized: .localizable.flagPubliclyDescription),
title: String(localized: "flagPubliclyTitle"),
description: String(localized: "flagPubliclyDescription"),
info: nil,
category: .privacy(.publicly)
)
Expand All @@ -75,14 +75,14 @@ struct FlagOption: Identifiable, Equatable {
/// `FlagOption` instances representing different categories of the visibility of a flagged user.
static let flagUserVisibilityOptions: [FlagOption] = [
FlagOption(
title: String(localized: .localizable.flagUserMuteTitle),
description: String(localized: .localizable.flagUserMuteDescription),
title: String(localized: "flagUserMuteTitle"),
description: String(localized: "flagUserMuteDescription"),
info: nil,
category: .visibility(.mute)
),
FlagOption(
title: String(localized: .localizable.flagUserDontMuteTitle),
description: String(localized: .localizable.flagUserDontMuteDescription),
title: String(localized: "flagUserDontMuteTitle"),
description: String(localized: "flagUserDontMuteDescription"),
info: nil,
category: .visibility(.dontMute)
)
Expand All @@ -95,43 +95,43 @@ struct FlagOption: Identifiable, Equatable {

extension FlagOption {
static let spam = FlagOption(
title: String(localized: .localizable.flagContentSpamTitle),
title: String(localized: "flagContentSpamTitle"),
description: nil,
info: nil,
category: .report(ReportCategory.spam)
)

static let harassment = FlagOption(
title: String(localized: .localizable.flagContentHarassmentTitle),
description: String(localized: .localizable.flagContentHarassmentDescription),
title: String(localized: "flagContentHarassmentTitle"),
description: String(localized: "flagContentHarassmentDescription"),
info: nil,
category: .report(ReportCategory.harassment)
)

static let nsfw = FlagOption(
title: "NSFW",
description: String(localized: .localizable.flagContentNudityDescription),
description: String(localized: "flagContentNudityDescription"),
info: nil,
category: .report(ReportCategory.nsfw)
)

static let illegal = FlagOption(
title: String(localized: .localizable.flagContentIllegalTitle),
description: String(localized: .localizable.flagContentIllegalDescription),
title: String(localized: "flagContentIllegalTitle"),
description: String(localized: "flagContentIllegalDescription"),
info: nil,
category: .report(ReportCategory.illegal)
)

static let impersonation = FlagOption(
title: String(localized: .localizable.flagUserImpersonationTitle),
description: String(localized: .localizable.flagUserImpersonationDescription),
title: String(localized: "flagUserImpersonationTitle"),
description: String(localized: "flagUserImpersonationDescription"),
info: nil,
category: .report(ReportCategory.other)
)

static let other = FlagOption(
title: String(localized: .localizable.flagContentOtherTitle),
description: String(localized: .localizable.flagContentOtherDescription),
title: String(localized: "flagContentOtherTitle"),
description: String(localized: "flagContentOtherDescription"),
info: nil,
category: .report(ReportCategory.other)
)
Expand Down
Loading

0 comments on commit fb3bc0f

Please sign in to comment.