-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
BCP 47 defines Tags for Identifying Languages.
Given the following JSON:
{
"language": "en",
"foo": true
}j2s will currently output the following Swift code:
public struct Root {
let foo: Bool
let language: String
init?(_ dictionary: [String: Any]) {
if let foo = dictionary["foo"] as? Bool {
self.foo = foo
} else {
return nil
}
if let language = dictionary["language"] as? String {
self.language = language
} else {
return nil
}
}
}but it might be useful if could identify BCP 47 identifiers and instead output code using Locales, such as:
public struct Root {
let foo: Bool
let language: String
init?(_ dictionary: [String: Any]) {
if let foo = dictionary["foo"] as? Bool {
self.foo = foo
} else {
return nil
}
if let language = dictionary["language"] as? String {
Locale(localeIdentifier: language)
} else {
return nil
}
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels