Skip to content

Commit

Permalink
Fix: Instantiate bundle from resouce_bundle to access localizable str…
Browse files Browse the repository at this point in the history
…ings

Signed-off-by: George J Padayatti <[email protected]>
  • Loading branch information
georgepadayatti committed Apr 4, 2024
1 parent 123af2e commit 19be388
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion PrivacyDashboardiOS/Classes/Extension/ExtensionMethods.swift
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,12 @@ extension String {
if let bundle = Bundle(url: Bundle.main.bundleURL.appendingPathComponent("Frameworks").appendingPathComponent("PrivacyDashboardiOS.framework").appendingPathComponent("/\(languageCode).lproj")) {
return NSLocalizedString(self, tableName: nil, bundle: bundle, value: "", comment: "")
} else {
let bundle = Bundle(url: Bundle.main.bundleURL.appendingPathComponent("PrivacyDashboardiOS.bundle").appendingPathComponent("\(languageCode).lproj")) ?? Bundle.main
/// Cocoapods will copy localization string files to the receiver project
/// and generate a new bundle to prevent name collisions. This bundle is
/// specified in PrivacyDashboardiOS.podspec as resource_bundle.
/// Reference: https://medium.com/@shenghuawu/localization-cocoapods-5d1e9f34f6e6
let path = Bundle(for: PrivacyDashboard.self).path(forResource: "PrivacyDashboardiOS",ofType: "bundle")!
let bundle = Bundle(path: path) ?? Bundle.main
return NSLocalizedString(self, tableName: nil, bundle: bundle, value: "", comment: "")
}
}
Expand Down

0 comments on commit 19be388

Please sign in to comment.