Sha256: a0c14ecfc951297476a8867bfbe6359adcab91aacf9710e40af4386dbb88f029

Contents?: true

Size: 1.76 KB

Versions: 21

Compression:

Stored size: 1.76 KB

Contents

#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.

require 'i18n_interpolation_fallbacks'
require "i18n/backend/fallbacks" 

if File.exists?(File.expand_path("./config/locale_settings.yml"))
  locale_settings = YAML::load(File.open(File.expand_path("./config/locale_settings.yml")))
  AVAILABLE_LANGUAGES = (locale_settings['available'].length > 0) ? locale_settings['available'] : { "en" => 'English' }
  AVAILABLE_LANGUAGE_CODES = locale_settings['available'].keys
  OTHER_LANGUAGES = (locale_settings['other'].length > 0) ? locale_settings['other'] : { "en" => 'English' }
  OTHER_LANGUAGE_CODES = locale_settings['other'].keys
  DEFAULT_LANGUAGE = (AVAILABLE_LANGUAGE_CODES.include?(locale_settings['default'].to_s)) ? locale_settings['default'].to_s : "en"
  LANGUAGE_CODES_MAP = locale_settings['fallbacks']
  RTL_LANGUAGES = locale_settings['rtl']
else
  AVAILABLE_LANGUAGES = { "en" => 'English' }
  OTHER_LANGUAGES = { "en" => 'English' }
  OTHER_LANGUAGE_CODES = ['']
  DEFAULT_LANGUAGE = "en"
  AVAILABLE_LANGUAGE_CODES = ["en"]
  LANGUAGE_CODES_MAP = {}
  RTL_LANGUAGES = []
end

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
I18n.default_locale = DEFAULT_LANGUAGE

I18n::Backend::Simple.send(:include, I18n::Backend::InterpolationFallbacks)
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)

(AVAILABLE_LANGUAGE_CODES + OTHER_LANGUAGE_CODES).flatten.each do |c|
  I18n.fallbacks[c] = [c] 
  
  if LANGUAGE_CODES_MAP.key?(c)
    I18n.fallbacks[c].concat(LANGUAGE_CODES_MAP[c])
  end
  
  I18n.fallbacks[c].concat([DEFAULT_LANGUAGE, "en"])
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
voluntary-0.7.1 config/initializers/locale_settings.rb
voluntary-0.7.0 config/initializers/locale_settings.rb
voluntary-0.6.0 config/initializers/locale_settings.rb
voluntary-0.5.2 config/initializers/locale_settings.rb
voluntary-0.5.1 config/initializers/locale_settings.rb
voluntary-0.5.0 config/initializers/locale_settings.rb
voluntary-0.4.0 config/initializers/locale_settings.rb
voluntary-0.3.0 config/initializers/locale_settings.rb
voluntary-0.2.4 config/initializers/locale_settings.rb
voluntary-0.2.3 config/initializers/locale_settings.rb
voluntary-0.2.2 config/initializers/locale_settings.rb
voluntary-0.2.1 config/initializers/locale_settings.rb
voluntary-0.2.0 config/initializers/locale_settings.rb
voluntary-0.1.0 config/initializers/locale_settings.rb
voluntary-0.1.0.rc4 config/initializers/locale_settings.rb
voluntary-0.1.0.rc3 config/initializers/locale_settings.rb
voluntary-0.1.0.rc2 config/initializers/locale_settings.rb
voluntary-0.1.0.rc1 config/initializers/locale_settings.rb
voluntary-0.0.3 config/initializers/locale_settings.rb
voluntary-0.0.2 config/initializers/locale_settings.rb