Compare commits
No commits in common. "0a5d369735c14fce12f7adb418a5c252c84447f1" and "81e4d1681667db56246bf735458bfd56af05a1a0" have entirely different histories.
0a5d369735
...
81e4d16816
10 changed files with 115 additions and 5 deletions
|
@ -50,7 +50,7 @@ class ApplicationController < ActionController::Base
|
|||
return params[:locale] if valid_locale?(params[:locale])
|
||||
return cookies[:locale] if valid_locale?(cookies[:locale])
|
||||
Rails.logger.debug "Preferred languages: #{http_accept_language.user_preferred_languages}"
|
||||
http_accept_language.language_region_compatible_from(I18n.available_locales.map(&:to_s)) ||
|
||||
http_accept_language.language_region_compatible_from(I18n.public_locales.map(&:to_s)) ||
|
||||
I18n.default_locale
|
||||
end
|
||||
|
||||
|
@ -76,7 +76,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def valid_locale?(locale)
|
||||
locale && I18n.available_locales.include?(locale.to_sym)
|
||||
locale && I18n.usable_locales.include?(locale.to_sym)
|
||||
end
|
||||
|
||||
def configure_permitted_parameters
|
||||
|
|
|
@ -161,7 +161,7 @@ module ApplicationHelper
|
|||
|
||||
def locale_options
|
||||
current_locale_is_public = false
|
||||
options = I18n.available_locales.map do |available_locale|
|
||||
options = I18n.public_locales.map do |available_locale|
|
||||
current_locale_is_public = true if I18n.locale == available_locale
|
||||
# Include fallbacks data on the tag. Right now it's used in blog
|
||||
# localization, but may conceivably be used for something else later.
|
||||
|
|
|
@ -47,8 +47,6 @@ module OpenneoImpressItems
|
|||
config.time_zone = "Pacific Time (US & Canada)"
|
||||
# config.eager_load_paths << Rails.root.join("extras")
|
||||
|
||||
config.i18n.available_locales = [:en, :es, :pt, :"en-MEEP"]
|
||||
config.i18n.default_locale = :en
|
||||
config.i18n.fallbacks = true
|
||||
|
||||
Mime::Type.register "image/gif", :gif
|
||||
|
|
61
config/initializers/locale_meta.rb
Normal file
61
config/initializers/locale_meta.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
module LocaleMeta
|
||||
PUBLIC_LOCALES = []
|
||||
USABLE_LOCALES = []
|
||||
NEOPETS_LANGUAGE_CODES_BY_LOCALE = {}
|
||||
LOCALES_WITH_NEOPETS_LANGUAGE_CODE = []
|
||||
COMPATIBLE_LOCALES = {}
|
||||
end
|
||||
|
||||
config = YAML.load_file(Rails.root.join('config', 'locale_meta.yml'))
|
||||
|
||||
config.each do |locale_str, locale_meta|
|
||||
locale = locale_str.to_sym
|
||||
|
||||
visibility = locale_meta['visibility']
|
||||
if visibility == 'public'
|
||||
LocaleMeta::PUBLIC_LOCALES << locale
|
||||
LocaleMeta::USABLE_LOCALES << locale
|
||||
elsif visibility == 'private'
|
||||
LocaleMeta::USABLE_LOCALES << locale
|
||||
end
|
||||
|
||||
if locale_meta.has_key?('neopets_language_code')
|
||||
neopets_language_code = locale_meta['neopets_language_code']
|
||||
LocaleMeta::NEOPETS_LANGUAGE_CODES_BY_LOCALE[locale] = neopets_language_code
|
||||
LocaleMeta::LOCALES_WITH_NEOPETS_LANGUAGE_CODE << locale
|
||||
elsif locale_meta.has_key?('compatible_with')
|
||||
compatible_locale = locale_meta['compatible_with'].to_sym
|
||||
LocaleMeta::COMPATIBLE_LOCALES[locale] = compatible_locale
|
||||
else
|
||||
raise "locale #{locale} must either have a neopets_language_code or " +
|
||||
"be compatible_with a locale that does"
|
||||
end
|
||||
end
|
||||
|
||||
LocaleMeta::USABLE_LOCALES_WITH_NEOPETS_LANGUAGE_CODE = LocaleMeta::USABLE_LOCALES &
|
||||
LocaleMeta::LOCALES_WITH_NEOPETS_LANGUAGE_CODE
|
||||
|
||||
module I18n
|
||||
def self.public_locales
|
||||
LocaleMeta::PUBLIC_LOCALES
|
||||
end
|
||||
|
||||
def self.usable_locales
|
||||
LocaleMeta::USABLE_LOCALES
|
||||
end
|
||||
|
||||
def self.locales_with_neopets_language_code
|
||||
LocaleMeta::LOCALES_WITH_NEOPETS_LANGUAGE_CODE
|
||||
end
|
||||
|
||||
def self.usable_locales_with_neopets_language_code
|
||||
LocaleMeta::USABLE_LOCALES_WITH_NEOPETS_LANGUAGE_CODE
|
||||
end
|
||||
|
||||
def self.compatible_neopets_language_code_for(locale)
|
||||
LocaleMeta::NEOPETS_LANGUAGE_CODES_BY_LOCALE[locale] ||
|
||||
LocaleMeta::NEOPETS_LANGUAGE_CODES_BY_LOCALE[LocaleMeta::COMPATIBLE_LOCALES[locale]]
|
||||
end
|
||||
end
|
||||
|
||||
Rails.configuration.i18n.available_locales = I18n.usable_locales
|
47
config/locale_meta.yml
Normal file
47
config/locale_meta.yml
Normal file
|
@ -0,0 +1,47 @@
|
|||
en:
|
||||
visibility: public
|
||||
neopets_language_code: en
|
||||
|
||||
en-MEEP:
|
||||
visibility: public
|
||||
compatible_with: en
|
||||
|
||||
pt:
|
||||
visibility: public
|
||||
neopets_language_code: pt
|
||||
|
||||
es:
|
||||
visibility: public
|
||||
neopets_language_code: es
|
||||
|
||||
nl:
|
||||
visibility: none
|
||||
neopets_language_code: nl
|
||||
|
||||
de:
|
||||
visibility: none
|
||||
neopets_language_code: de
|
||||
|
||||
fr:
|
||||
visibility: none
|
||||
neopets_language_code: fr
|
||||
|
||||
it:
|
||||
visibility: none
|
||||
neopets_language_code: it
|
||||
|
||||
zh-CN:
|
||||
visibility: none
|
||||
neopets_language_code: ch
|
||||
|
||||
zh-TW:
|
||||
visibility: none
|
||||
neopets_language_code: zh
|
||||
|
||||
ja:
|
||||
visibility: none
|
||||
neopets_language_code: ja
|
||||
|
||||
ko:
|
||||
visibility: none
|
||||
neopets_language_code: ko
|
2
public/outfits/.gitignore
vendored
Normal file
2
public/outfits/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
0
public/stylesheets/.gitkeep
Normal file
0
public/stylesheets/.gitkeep
Normal file
1
vendor/.gitignore
vendored
Normal file
1
vendor/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/bundle
|
1
vendor/bundle/ruby/3.1.0/bundler/gems/rocketamf-796f591d002b
vendored
Submodule
1
vendor/bundle/ruby/3.1.0/bundler/gems/rocketamf-796f591d002b
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 796f591d002b5cf47df436dbcbd6f2ab00e869ed
|
0
vendor/plugins/.gitkeep
vendored
Normal file
0
vendor/plugins/.gitkeep
vendored
Normal file
Loading…
Reference in a new issue