From 5985e234da97797cdcf28ddd7c42c4634f4dfb47 Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 31 Jan 2013 19:11:15 -0600 Subject: [PATCH] pet states know their localized description --- Gemfile | 2 +- Gemfile.lock | 6 +++--- app/models/pet_state.rb | 21 +++++++++++++++++++++ config/locales/en.yml | 12 ++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index f259ee18..1234622a 100644 --- a/Gemfile +++ b/Gemfile @@ -39,7 +39,7 @@ gem 'sanitize', '~> 2.0.3' gem 'newrelic_rpm' -gem 'neopets', :git => 'git://github.com/matchu/neopets.git' +gem 'neopets', '~> 0.2.0', :git => 'git://github.com/matchu/neopets.git' gem "mini_magick", "~> 3.4" diff --git a/Gemfile.lock b/Gemfile.lock index 2f9e2aca..e0067554 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,9 +55,9 @@ GIT GIT remote: git://github.com/matchu/neopets.git - revision: d33aaf63d4617d9236ef0d99452b3bdc577cbc8e + revision: 5d13a720b616ba57fbbd54541f3e5daf02b3fedc specs: - neopets (0.1.0) + neopets (0.2.0) nokogiri (~> 1.5.2) GIT @@ -301,7 +301,7 @@ DEPENDENCIES msgpack (~> 0.4.3) mysql2 (< 0.3) mysqlplus! - neopets! + neopets (~> 0.2.0)! newrelic_rpm nokogiri (~> 1.5.2) openneo-auth-signatory (~> 0.1.0) diff --git a/app/models/pet_state.rb b/app/models/pet_state.rb index 33b95d28..292e1775 100644 --- a/app/models/pet_state.rb +++ b/app/models/pet_state.rb @@ -103,6 +103,27 @@ class PetState < ActiveRecord::Base def mood Neopets::Pet::Mood.find(self.mood_id) end + + def gender_name + if female? + I18n.translate("pet_states.description.gender.female") + else + I18n.translate("pet_states.description.gender.male") + end + end + + def mood_name + I18n.translate("pet_states.description.mood.#{mood.name}") + end + + def gender_mood_description + if labeled? + I18n.translate('pet_states.description.main', :gender => gender_name, + :mood => mood_name) + else + I18n.translate('pet_states.description.unlabeled') + end + end def self.from_pet_type_and_biology_info(pet_type, info) swf_asset_ids = [] diff --git a/config/locales/en.yml b/config/locales/en.yml index e3079aa1..5d35bfab 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -706,6 +706,18 @@ en: clone: Edit a copy creation_summary_html: Created by %{user_link}, %{created_at_ago} ago + pet_states: + description: + main: "%{mood} %{gender}" + gender: + female: Female + male: Male + mood: + happy: Happy + sad: Sad + sick: Sick + unlabeled: Unlabeled + pets: bulk: needed_items: