Skip to content

Instantly share code, notes, and snippets.

@swilliams
Created May 24, 2016 21:56
Show Gist options
  • Save swilliams/099405b597bd17e3515f2574f2a6dc39 to your computer and use it in GitHub Desktop.
Save swilliams/099405b597bd17e3515f2574f2a6dc39 to your computer and use it in GitHub Desktop.
extension String {
var localized: String {
return NSLocalizedString(self, comment: "")
}
}
// Which allows for:
"Hello world".localized
@swilliams
Copy link
Author

[Apologies for the big delay... I don't check GitHub often anymore]

It's been a long time since I used this, but if I recall, I had to manually create them.

@josecostamartins
Copy link

Hey, thank you for the answer!
I'm not sure I follow, what do you mean by manually created them?

@swilliams
Copy link
Author

My memory is really foggy on this, but I remember creating the localizable.strings files myself. I believe Xcode has the capabilities of doing that now. You'd still need to populate those files with strings though. This site has a little more info: https://medium.com/lean-localization/ios-localization-tutorial-938231f9f881

@josecostamartins
Copy link

Thank you very much for your time and your knowledge!

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