Sha256: 7a42200c7fa73881ad856f920672889a104e979340a57742fabff76bd39cbe26
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
require 'rails' require 'fb-localizer' require 'xml' require "open-uri" require "timeout" module FbLocalizer class Railtie < Rails::Railtie initializer "fb-localizer.configure_rails_initialization" do def load_defaults FbLocalizer::FbLocalizerHelpers.const_set(:FB_LOCALES, ["en_US","es_ES","ca_ES"]) end if FbLocalizer.skip_loading puts "FB-Localizer => Skipped, using defaults instead" load_defaults else begin Timeout::timeout(5) do url = "http://www.facebook.com/translations/FacebookLocales.xml" open(url){ |f| xml = f.readlines.join("\n") fb_locales = XML::Parser.string(xml).parse FbLocalizer::FbLocalizerHelpers::FB_LOCALES = [] fb_locales.find('//locales/locale/codes/code/standard/representation').each do |node| FbLocalizer::FbLocalizerHelpers::FB_LOCALES << node.content end puts "FB-Localizer => Locales read successfully from <http://www.facebook.com/translations/FacebookLocales.xml>" } end rescue Exception => e puts "FB-Localizer => Exception '#{e}', using defaults instead" load_defaults end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fb-localizer-0.2.0 | lib/fb-localizer/railtie.rb |