From 6c3ff09f5d1a6b21b4eae9983d3b6433f5aa21cd Mon Sep 17 00:00:00 2001 From: Matchu Date: Sun, 27 Jan 2013 20:43:08 -0600 Subject: [PATCH] make en-MEEP translatable - because sorting by translations doesnt work well with fallbacks --- app/models/pet.rb | 2 +- config/initializers/locale_meta.rb | 5 +++-- lib/tasks/translate.rake | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/pet.rb b/app/models/pet.rb index 394a35ac..91e0e376 100644 --- a/app/models/pet.rb +++ b/app/models/pet.rb @@ -23,7 +23,7 @@ class Pet < ActiveRecord::Base I18n.with_locale(options[:locale]) do require 'ostruct' begin - neopets_language_code = I18n.neopets_language_code_for(options[:locale]) + neopets_language_code = I18n.compatible_neopets_language_code_for(options[:locale]) envelope = PET_VIEWER.request([name, 0]).post( :timeout => 2, :headers => { diff --git a/config/initializers/locale_meta.rb b/config/initializers/locale_meta.rb index 3bc96f0d..6cda4cf0 100644 --- a/config/initializers/locale_meta.rb +++ b/config/initializers/locale_meta.rb @@ -52,7 +52,8 @@ module I18n LocaleMeta::USABLE_LOCALES_WITH_NEOPETS_LANGUAGE_CODE end - def self.neopets_language_code_for(locale) - LocaleMeta::NEOPETS_LANGUAGE_CODES_BY_LOCALE[locale] + 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 diff --git a/lib/tasks/translate.rake b/lib/tasks/translate.rake index a9965db0..3426305b 100644 --- a/lib/tasks/translate.rake +++ b/lib/tasks/translate.rake @@ -48,7 +48,7 @@ namespace :translate do def with_given_locale I18n.with_locale(ENV['LOCALE']) do - language_code = I18n.neopets_language_code_for(I18n.locale) + language_code = I18n.compatible_neopets_language_code_for(I18n.locale) unless language_code raise "Locale #{I18n.locale.inspect} has no neopets language code" end