Sha256: 1fbb69049db32758170d72284740504c4adc994b97f0d6b53630270d30aa1de4
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
require 'fb-localizer/railtie' if defined? Rails require 'i18n' module FbLocalizer DEFAULT_PRIORITIES = { :en => "en_US", :es => "es_ES", :pt => "pt_PT", :zh => "zh_CN" } mattr_accessor :priorized module FbLocalizerHelpers def get_fb_locale(ruby_locale = nil) ruby_locale = ruby_locale.to_sym if ruby_locale.is_a? String ruby_locale ||= I18n.locale fb_candidate_locales = FbLocalizer::FbLocalizerHelpers::FB_LOCALES.select{ |l| l.match(/^#{ruby_locale}/)} if fb_candidate_locales.any? priorized = FbLocalizer.priorized[ruby_locale] # get priorized locale for that one if priorized && fb_candidate_locales.include?(priorized) # if available, get that one priorized else # if not, just get the first available fb_candidate_locales[0] end else "en_US" # US english by default end end end def self.configure yield self end def self.priorized DEFAULT_PRIORITIES.merge(@@priorized) end end ActionView::Base.send(:include, FbLocalizer::FbLocalizerHelpers)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fb-localizer-0.1.3 | lib/fb-localizer.rb |