Compare commits

..

No commits in common. "0a5d369735c14fce12f7adb418a5c252c84447f1" and "81e4d1681667db56246bf735458bfd56af05a1a0" have entirely different histories.

10 changed files with 115 additions and 5 deletions

View file

@ -50,7 +50,7 @@ class ApplicationController < ActionController::Base
return params[:locale] if valid_locale?(params[:locale]) return params[:locale] if valid_locale?(params[:locale])
return cookies[:locale] if valid_locale?(cookies[:locale]) return cookies[:locale] if valid_locale?(cookies[:locale])
Rails.logger.debug "Preferred languages: #{http_accept_language.user_preferred_languages}" 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 I18n.default_locale
end end
@ -76,7 +76,7 @@ class ApplicationController < ActionController::Base
end end
def valid_locale?(locale) def valid_locale?(locale)
locale && I18n.available_locales.include?(locale.to_sym) locale && I18n.usable_locales.include?(locale.to_sym)
end end
def configure_permitted_parameters def configure_permitted_parameters

View file

@ -161,7 +161,7 @@ module ApplicationHelper
def locale_options def locale_options
current_locale_is_public = false 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 current_locale_is_public = true if I18n.locale == available_locale
# Include fallbacks data on the tag. Right now it's used in blog # Include fallbacks data on the tag. Right now it's used in blog
# localization, but may conceivably be used for something else later. # localization, but may conceivably be used for something else later.

View file

@ -47,8 +47,6 @@ module OpenneoImpressItems
config.time_zone = "Pacific Time (US & Canada)" config.time_zone = "Pacific Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras") # 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 config.i18n.fallbacks = true
Mime::Type.register "image/gif", :gif Mime::Type.register "image/gif", :gif

View 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
View 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
View file

@ -0,0 +1,2 @@
*
!.gitignore

View file

1
vendor/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/bundle

@ -0,0 +1 @@
Subproject commit 796f591d002b5cf47df436dbcbd6f2ab00e869ed

0
vendor/plugins/.gitkeep vendored Normal file
View file