Skip to content

Commit 2b5fc5e

Browse files
committed
Merge pull request #218 from mac-cain13/feature/localization-fixed
Feature/localization fixed
2 parents cfbce24 + 238ff51 commit 2b5fc5e

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

R.swift/Generators/ResourceGenerator.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ func generateResourceStructsWithResources(resources: Resources, bundleIdentifier
5353
implements: [],
5454
typealiasses: [],
5555
properties: [
56-
Let(isStatic: true, name: "hostingBundle", typeDefinition: .Inferred(Type._NSBundle), value: "NSBundle(identifier: \"\(bundleIdentifier)\") ?? NSBundle.mainBundle()")
56+
Let(isStatic: true, name: "hostingBundle", typeDefinition: .Inferred(Type._NSBundle), value: "NSBundle(identifier: \"\(bundleIdentifier)\") ?? NSBundle.mainBundle()"),
57+
Let(isStatic: true, name: "applicationLocale", typeDefinition: .Inferred(Type._NSLocale), value: "hostingBundle.preferredLocalizations.first.flatMap(NSLocale.init) ?? NSLocale.currentLocale()")
5758
],
5859
functions: [],
5960
structs: generatorResults.internalStructs

R.swift/Generators/StringsGenerator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ struct StringsGenerator: Generator {
245245
parameters: params,
246246
doesThrow: false,
247247
returnType: Type._String,
248-
body: "return String(format: \(values.localizedString), locale: NSLocale.currentLocale(), \(args))"
248+
body: "return String(format: \(values.localizedString), locale: _R.applicationLocale, \(args))"
249249
)
250250
}
251251

R.swift/SwiftTypes/Type.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct Type: UsedTypesProvider, CustomStringConvertible, Hashable {
3232
static let _UIView = Type(module: "UIKit", name: "UIView")
3333
static let _UIImage = Type(module: "UIKit", name: "UIImage")
3434
static let _NSBundle = Type(module: "Foundation", name: "NSBundle")
35+
static let _NSLocale = Type(module: "Foundation", name: "NSLocale")
3536
static let _UIStoryboard = Type(module: "UIKit", name: "UIStoryboard")
3637
static let _UITableViewCell = Type(module: "UIKit", name: "UITableViewCell")
3738
static let _UICollectionViewCell = Type(module: "UIKit", name: "UICollectionViewCell")

0 commit comments

Comments
 (0)