added language codes map
This commit is contained in:
parent
60375422e7
commit
dcbcaefcbe
4 changed files with 15 additions and 3 deletions
|
|
@ -18,6 +18,12 @@ else
|
||||||
AVAILABLE_LANGUAGE_CODES = ['en']
|
AVAILABLE_LANGUAGE_CODES = ['en']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if File.exists?(File.expand_path("./config/langcodes_alias_map.yml"))
|
||||||
|
LANGUAGE_CODES_MAP = YAML::load(File.open(File.expand_path("./config/langcodes_alias_map.yml")))
|
||||||
|
else
|
||||||
|
LANGUAGE_CODES_MAP = {}
|
||||||
|
end
|
||||||
|
|
||||||
# Initialize the rails application
|
# Initialize the rails application
|
||||||
Diaspora::Application.initialize!
|
Diaspora::Application.initialize!
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,10 @@ I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
|
||||||
I18n.default_locale = DEFAULT_LANGUAGE
|
I18n.default_locale = DEFAULT_LANGUAGE
|
||||||
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
|
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
|
||||||
AVAILABLE_LANGUAGE_CODES.each do |c|
|
AVAILABLE_LANGUAGE_CODES.each do |c|
|
||||||
I18n.fallbacks[c.to_sym] = [c.to_sym, DEFAULT_LANGUAGE.to_sym, :en]
|
if LANGUAGE_CODES_MAP.key?(c)
|
||||||
|
I18n.fallbacks[c.to_sym] = LANGUAGE_CODES_MAP[c]
|
||||||
|
I18n.fallbacks[c.to_sym].concat([c.to_sym, DEFAULT_LANGUAGE.to_sym, :en])
|
||||||
|
else
|
||||||
|
I18n.fallbacks[c.to_sym] = [c.to_sym, DEFAULT_LANGUAGE.to_sym, :en]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
2
config/langcodes_alias_map.yml
Normal file
2
config/langcodes_alias_map.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
en: [:en-US, :en-GB]
|
||||||
|
sv: [:sv-SE]
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
en-US.yml
|
|
||||||
Loading…
Reference in a new issue