forked from OpenNeo/impress
translate species/color
This commit is contained in:
parent
361b5df256
commit
9c37e894f7
4 changed files with 40 additions and 12 deletions
2
Gemfile
2
Gemfile
|
@ -57,6 +57,8 @@ gem "globalize3"
|
||||||
gem "flex", :require => "flex/rails", :git => "git@github.com:matchu/flex.git"
|
gem "flex", :require => "flex/rails", :git => "git@github.com:matchu/flex.git"
|
||||||
gem "patron", "~> 0.4.18"
|
gem "patron", "~> 0.4.18"
|
||||||
|
|
||||||
|
gem "rest-client", "~> 1.6.7"
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem "bullet", "~> 4.1.5"
|
gem "bullet", "~> 4.1.5"
|
||||||
end
|
end
|
||||||
|
|
|
@ -220,6 +220,8 @@ GEM
|
||||||
redis (>= 2.0.1)
|
redis (>= 2.0.1)
|
||||||
resque (>= 1.15.0)
|
resque (>= 1.15.0)
|
||||||
rufus-scheduler
|
rufus-scheduler
|
||||||
|
rest-client (1.6.7)
|
||||||
|
mime-types (>= 1.16)
|
||||||
right_aws (2.1.0)
|
right_aws (2.1.0)
|
||||||
right_http_connection (>= 1.2.5)
|
right_http_connection (>= 1.2.5)
|
||||||
right_http_connection (1.3.0)
|
right_http_connection (1.3.0)
|
||||||
|
@ -304,6 +306,7 @@ DEPENDENCIES
|
||||||
resque (~> 1.15.0)
|
resque (~> 1.15.0)
|
||||||
resque-retry (~> 0.1.0)
|
resque-retry (~> 0.1.0)
|
||||||
resque-scheduler (~> 2.0.0.d)
|
resque-scheduler (~> 2.0.0.d)
|
||||||
|
rest-client (~> 1.6.7)
|
||||||
right_aws (~> 2.1.0)
|
right_aws (~> 2.1.0)
|
||||||
rspec-rails (~> 2.0.0.beta.22)
|
rspec-rails (~> 2.0.0.beta.22)
|
||||||
sanitize (~> 2.0.3)
|
sanitize (~> 2.0.3)
|
||||||
|
|
|
@ -1,17 +1,6 @@
|
||||||
require 'rocketamf/remote_gateway'
|
require 'rocketamf/remote_gateway'
|
||||||
|
|
||||||
namespace :translate do
|
namespace :translate do
|
||||||
def with_given_locale
|
|
||||||
I18n.with_locale(ENV['LOCALE']) do
|
|
||||||
language_code = I18n.neopets_language_code_for(I18n.locale)
|
|
||||||
unless language_code
|
|
||||||
raise "Locale #{I18n.locale.inspect} has no neopets language code"
|
|
||||||
end
|
|
||||||
|
|
||||||
yield(language_code)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Download the Neopets zone data for the given locale"
|
desc "Download the Neopets zone data for the given locale"
|
||||||
task :zones => :environment do
|
task :zones => :environment do
|
||||||
with_given_locale do |neopets_language_code|
|
with_given_locale do |neopets_language_code|
|
||||||
|
@ -24,7 +13,7 @@ namespace :translate do
|
||||||
)
|
)
|
||||||
application_data = envelope.messages[0].data.body
|
application_data = envelope.messages[0].data.body
|
||||||
|
|
||||||
zones_by_id = Zone.all.inject({}) { |h, z| h[z.id] = z ; h}
|
zones_by_id = Zone.all.inject({}) { |h, z| h[z.id] = z ; h }
|
||||||
application_data[:zones].each do |zone_data|
|
application_data[:zones].each do |zone_data|
|
||||||
zone = zones_by_id[zone_data[:id].to_i]
|
zone = zones_by_id[zone_data[:id].to_i]
|
||||||
zone.label = zone_data[:label]
|
zone.label = zone_data[:label]
|
||||||
|
@ -33,4 +22,38 @@ namespace :translate do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "Download the Rainbow Pool data for the given locale"
|
||||||
|
task :pet_attributes => :environment do
|
||||||
|
with_given_locale do |neopets_language_code|
|
||||||
|
pool_url = "http://www.neopets.com/pool/all_pb.phtml"
|
||||||
|
pool_options = {
|
||||||
|
:cookies => {:neologin => URI.encode(ENV['NEOLOGIN'])},
|
||||||
|
:params => {:lang => neopets_language_code}
|
||||||
|
}
|
||||||
|
pool_response = RestClient.get(pool_url, pool_options)
|
||||||
|
pool_doc = Nokogiri::HTML(pool_response)
|
||||||
|
|
||||||
|
[Species, Color].each do |klass|
|
||||||
|
klass_name = klass.name.underscore
|
||||||
|
records_by_id = klass.all.inject({}) { |h, r| h[r.id] = r; h }
|
||||||
|
pool_doc.css("select[name=f_#{klass_name}_id] option").each do |option|
|
||||||
|
record = records_by_id[option['value'].to_i]
|
||||||
|
record.name = option.text.downcase
|
||||||
|
record.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def with_given_locale
|
||||||
|
I18n.with_locale(ENV['LOCALE']) do
|
||||||
|
language_code = I18n.neopets_language_code_for(I18n.locale)
|
||||||
|
unless language_code
|
||||||
|
raise "Locale #{I18n.locale.inspect} has no neopets language code"
|
||||||
|
end
|
||||||
|
|
||||||
|
yield(language_code)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
BIN
vendor/cache/rest-client-1.6.7.gem
vendored
Normal file
BIN
vendor/cache/rest-client-1.6.7.gem
vendored
Normal file
Binary file not shown.
Loading…
Reference in a new issue