Skip to content

Instantly share code, notes, and snippets.

@Gernot
Created March 12, 2019 19:15
Show Gist options
  • Save Gernot/3ad5396053fc26b29b9cac4ae45f59ef to your computer and use it in GitHub Desktop.
Save Gernot/3ad5396053fc26b29b9cac4ae45f59ef to your computer and use it in GitHub Desktop.
A proposal to have much nicer, backwards compatible localizable strings in Swift
/* Here is what I want to write, and what Xcode sees. */
struct Loc {
struct someDomain {
/// Here is some description of what this string is doing. It's readable in the AutoComplete Description!
static let myStringName = "Woah, woah, this is the actual content of the String!"
}
}
/* And now some Parser/Code Generator comes in and generates this out of it*/
/* This is what the localization tools and the compiler see, when the App actually gets compiled */
struct Loc {
struct someDomain {
static let myStringName = NSLocalizedString(
"SomeDomain.MyStringName",
value:"Woah, woah, this is the actual content of the String!",
comment: "Here is some description of what this string is doing. It's readable in the AutoComplete Description!")
}
}
/* Is this possible? Does this exist? Does anybody what to build this with me? */
@rist
Copy link

rist commented Mar 13, 2019

as we create the R files at each build we can be sure that there is a string behind R.string.localizable.myStringName

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment