19 lines
535 B
Swift
19 lines
535 B
Swift
import Foundation
|
|
|
|
final class LocalizationStore {
|
|
private let bundle: Bundle
|
|
|
|
init(bundle: Bundle = .main) {
|
|
self.bundle = bundle
|
|
}
|
|
|
|
func string(for key: String, locale: String) -> String {
|
|
guard let path = bundle.path(forResource: locale, ofType: "lproj"),
|
|
let localizedBundle = Bundle(path: path) else {
|
|
return bundle.localizedString(forKey: key, value: nil, table: nil)
|
|
}
|
|
|
|
return localizedBundle.localizedString(forKey: key, value: nil, table: nil)
|
|
}
|
|
}
|