Remove i18n locale config complexity we don't use anymore

I forget what this was for, I think part of it was for managing item
names in different languages, and the "private" locale thing was
probably for WIP locales? But yeah, not used, delete!
This commit is contained in:
Emi Matchu 2024-09-13 20:55:09 -07:00
parent ebd400369a
commit 0a5d369735
5 changed files with 5 additions and 111 deletions

View file

@ -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.public_locales.map(&:to_s)) ||
http_accept_language.language_region_compatible_from(I18n.available_locales.map(&:to_s)) ||
I18n.default_locale
end
@ -76,7 +76,7 @@ class ApplicationController < ActionController::Base
end
def valid_locale?(locale)
locale && I18n.usable_locales.include?(locale.to_sym)
locale && I18n.available_locales.include?(locale.to_sym)
end
def configure_permitted_parameters

View file

@ -161,7 +161,7 @@ module ApplicationHelper
def locale_options
current_locale_is_public = false
options = I18n.public_locales.map do |available_locale|
options = I18n.available_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.

View file

@ -47,6 +47,8 @@ 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

View file

@ -1,61 +0,0 @@
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

View file

@ -1,47 +0,0 @@
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