class SgtnClient::LocaleUtil
Public Class Methods
fallback(locale)
click to toggle source
# File lib/sgtn-client/util/locale-util.rb, line 23 def self.fallback(locale) found = SgtnClient::DEFAULT_LOCALES.select {|e| e == locale} if !found.empty? return found[0] end if SgtnClient::MAP_LOCALES.key?(locale) return SgtnClient::MAP_LOCALES[locale] end parts = locale.split("-") if parts.size > 1 f = SgtnClient::DEFAULT_LOCALES.select {|e| e == parts[0]} if !f.empty? return f[0] end end return locale end
get_best_locale(locale)
click to toggle source
# File lib/sgtn-client/util/locale-util.rb, line 16 def self.get_best_locale(locale) fallback(process_locale(locale)) end
get_source_locale()
click to toggle source
# File lib/sgtn-client/util/locale-util.rb, line 40 def self.get_source_locale env = SgtnClient::Config.default_environment source_locale = SgtnClient::Config.configurations[env]["default_language"] source_locale || 'en' end
process_locale(locale=nil)
click to toggle source
# File lib/sgtn-client/util/locale-util.rb, line 19 def self.process_locale(locale=nil) locale ||= SgtnClient::Config.configurations.default locale.to_s end