Sha256: a36acdd97fa4f3893025ea8769e845a1183776b228acd17ce230185383ebcd82
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 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 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" FbLocalizer::FbLocalizerHelpers::FB_LOCALES = ["en_US","es_ES","ca_ES"] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fb-localizer-0.1.3 | lib/fb-localizer/railtie.rb |
fb-localizer-0.1.2 | lib/fb-localizer/railtie.rb |
fb-localizer-0.1.1 | lib/fb-localizer/railtie.rb |