Support providing localized string for country and currency code#70
Open
abuobaida wants to merge 2 commits intomarmelroy:masterfrom
Open
Support providing localized string for country and currency code#70abuobaida wants to merge 2 commits intomarmelroy:masterfrom
abuobaida wants to merge 2 commits intomarmelroy:masterfrom
Conversation
Contributor
|
@abuobaida I think those funcs should be in Localize class, not String. extension Localize {
/// Returns current locale.
///
/// - Returns: current locale.
final class func currentLocale() -> Locale {
return Locale(identifier: Localize.currentLanguage())
}
/// Returns a localized string for a specified ISO 4217 currency code.
///
/// - Parameter currencyCode: ISO 4217 currency code the currency whose name you want.
/// - Returns: Localized string for a specified ISO 4217 currency code.
final class func localizedCurrency(_ currencyCode: String) -> String {
return currentLocale()
.localizedString(forCurrencyCode: currencyCode) ?? currencyCode
}
/// Returns the localized string for the specified country code.
///
/// - Parameter countryCode: The country code indicating the country whose name you want.
/// - Returns: Localized string for the specified country code.
final class func localizedCountry(_ countryCode: String) -> String {
return (currentLocale() as NSLocale)
.localizedString(forCountryCode: countryCode) ?? countryCode
}
} |
Author
|
Thanks @nekrich, branch updated. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.