class SgtnClient::LocaleUtil

Public Class Methods

fallback(locale) click to toggle source
# File lib/sgtn-client/util/locale-util.rb, line 13
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