class SgtnClient::LocaleUtil
Public Class Methods
get_best_locale(locale)
click to toggle source
# File lib/sgtn-client/util/locale-util.rb, line 16 def self.get_best_locale(locale) return get_default_locale if locale.nil? locale = locale.to_s return get_default_locale if locale.empty? get_best_match(locale) end
get_default_locale()
click to toggle source
# File lib/sgtn-client/util/locale-util.rb, line 41 def self.get_default_locale env = SgtnClient::Config.default_environment SgtnClient::Config.configurations[env]['default_language'] || 'en' end
get_source_locale()
click to toggle source
# File lib/sgtn-client/util/locale-util.rb, line 37 def self.get_source_locale 'en' end
is_source_locale(locale = nil)
click to toggle source
# File lib/sgtn-client/util/locale-util.rb, line 25 def self.is_source_locale(locale = nil) locale == get_source_locale end
Private Class Methods
get_best_match(locale)
click to toggle source
# File lib/sgtn-client/util/locale-util.rb, line 29 def self.get_best_match(locale) locale = locale.gsub('_', '-') locale = SgtnClient::MAP_LOCALES[locale] if SgtnClient::MAP_LOCALES.key?(locale) return locale if SUPPORTED_LOCALES.include?(locale) return LocaleUtil.get_source_locale if locale.index('-').nil? get_best_match(locale.slice(0..(locale.rindex('-')-1)) ) end