Last active
November 23, 2022 08:23
-
-
Save NikolajMosbaek/dcfaed4566ec8fee40ec97b061b2f335 to your computer and use it in GitHub Desktop.
An extension which adds syntactic sugar when using localized strings. You can write: 'let loginTitle = "login_title_key"'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
var localized: String { | |
let local = NSLocalizedString(self, comment: "") | |
guard !local.isEmpty else { | |
return self | |
} | |
return local | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment