Sha256: 04c60c30343109c905f9c1afebdc6273c1ed3c57c47bcccf18f81a50592652f7

Contents?: true

Size: 662 Bytes

Versions: 1

Compression:

Stored size: 662 Bytes

Contents

require 'rails'
require 'fb-localizer'
require 'xml'

module FbLocalizer
  class Railtie < Rails::Railtie
    initializer "fb-localizer.configure_rails_initialization" do
      # Get locales
      url = "www.facebook.com/translations/FacebookLocales.xml"
      `wget -qO- #{url} >> tmp.xml`

      # Navigate and get locales
      FbLocalizer::FbLocalizerHelpers::FB_LOCALES = []
      fb_locales = XML::Document.file("tmp.xml")
      fb_locales.find('//locales/locale/codes/code/standard/representation').each do |node|
        FbLocalizer::FbLocalizerHelpers::FB_LOCALES << node.content
      end

      # Remove tmp file
      `rm tmp.xml`
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fb-localizer-0.1.0 lib/fb-localizer/railtie.rb