Compare commits
No commits in common. "c8e53165c7a1e21acc4fca6464e7f570c204854a" and "b7296d6a7568d53373aa1d09f772c12627ba9631" have entirely different histories.
c8e53165c7
...
b7296d6a75
7 changed files with 48 additions and 18 deletions
1
Gemfile
1
Gemfile
|
|
@ -31,6 +31,7 @@ gem 'will_paginate', '~> 4.0'
|
|||
# For translation, both for the site UI and for Neopets data.
|
||||
gem 'rails-i18n', '~> 7.0', '>= 7.0.7'
|
||||
gem 'http_accept_language', '~> 2.1', '>= 2.1.1'
|
||||
gem 'globalize', '~> 6.2', '>= 6.2.1'
|
||||
|
||||
# For reading and parsing HTML from Neopets.com, like importing Closet pages.
|
||||
gem 'nokogiri', '~> 1.15', '>= 1.15.3'
|
||||
|
|
|
|||
|
|
@ -157,6 +157,10 @@ GEM
|
|||
fiber-local (1.0.0)
|
||||
globalid (1.2.1)
|
||||
activesupport (>= 6.1)
|
||||
globalize (6.3.0)
|
||||
activemodel (>= 4.2, < 7.2)
|
||||
activerecord (>= 4.2, < 7.2)
|
||||
request_store (~> 1.0)
|
||||
haml (6.1.1)
|
||||
temple (>= 0.8.2)
|
||||
thor
|
||||
|
|
@ -288,6 +292,8 @@ GEM
|
|||
actionview (>= 5)
|
||||
reline (0.3.9)
|
||||
io-console (~> 0.5)
|
||||
request_store (1.5.1)
|
||||
rack (>= 1.4)
|
||||
responders (3.1.1)
|
||||
actionpack (>= 5.2)
|
||||
railties (>= 5.2)
|
||||
|
|
@ -362,6 +368,7 @@ DEPENDENCIES
|
|||
devise-encryptable (~> 0.2.0)
|
||||
dotenv-rails (~> 2.8, >= 2.8.1)
|
||||
falcon (~> 0.42.3)
|
||||
globalize (~> 6.2, >= 6.2.1)
|
||||
haml (~> 6.1, >= 6.1.1)
|
||||
http_accept_language (~> 2.1, >= 2.1.1)
|
||||
httparty (~> 0.21.0)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,13 @@ class Item < ApplicationRecord
|
|||
self.inheritance_column = nil
|
||||
|
||||
SwfAssetType = 'object'
|
||||
|
||||
# Keep the reference to the deprecated `Item::Translation` record, but don't
|
||||
# bind it directly to any attributes anymore. We have some temporary writers
|
||||
# that hack around the API to keep the attributes synced, while no longer
|
||||
# reading *from* them by default.
|
||||
# TODO: Remove once we're all done with translations, both here and in 2020!
|
||||
translates
|
||||
|
||||
has_many :closet_hangers
|
||||
has_one :contribution, :as => :contributed, :inverse_of => :contributed
|
||||
|
|
@ -105,6 +112,24 @@ class Item < ApplicationRecord
|
|||
distinct
|
||||
}
|
||||
|
||||
# Temporary writers to keep the English translation record updated, while
|
||||
# primarily using the attributes on the model itself.
|
||||
#
|
||||
# Once this app and DTI 2020 are both comfortably off the translation system,
|
||||
# we can remove this!
|
||||
def name=(new_name)
|
||||
globalize.write(:en, :name, new_name)
|
||||
write_attribute(:name, new_name)
|
||||
end
|
||||
def description=(new_description)
|
||||
globalize.write(:en, :description, new_description)
|
||||
write_attribute(:description, new_description)
|
||||
end
|
||||
def rarity=(new_rarity)
|
||||
globalize.write(:en, :rarity, new_rarity)
|
||||
write_attribute(:rarity, new_rarity)
|
||||
end
|
||||
|
||||
def nc_trade_value
|
||||
return nil unless nc?
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
class DropItemTranslations < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
drop_table "item_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.integer "item_id"
|
||||
t.string "locale"
|
||||
t.string "name"
|
||||
t.text "description"
|
||||
t.string "rarity"
|
||||
t.datetime "created_at", precision: nil
|
||||
t.datetime "updated_at", precision: nil
|
||||
t.index ["item_id", "locale"], name: "index_item_translations_on_item_id_and_locale"
|
||||
t.index ["item_id"], name: "index_item_translations_on_item_id"
|
||||
t.index ["locale"], name: "index_item_translations_on_locale"
|
||||
t.index ["name"], name: "index_item_translations_name"
|
||||
end
|
||||
end
|
||||
end
|
||||
16
db/schema.rb
16
db/schema.rb
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_02_21_005949) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_02_21_004332) do
|
||||
create_table "alt_styles", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
|
||||
t.integer "species_id", null: false
|
||||
t.integer "color_id", null: false
|
||||
|
|
@ -115,6 +115,20 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_21_005949) do
|
|||
t.index ["outfit_id", "is_worn"], name: "index_item_outfit_relationships_on_outfit_id_and_is_worn"
|
||||
end
|
||||
|
||||
create_table "item_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.integer "item_id"
|
||||
t.string "locale"
|
||||
t.string "name"
|
||||
t.text "description"
|
||||
t.string "rarity"
|
||||
t.datetime "created_at", precision: nil
|
||||
t.datetime "updated_at", precision: nil
|
||||
t.index ["item_id", "locale"], name: "index_item_translations_on_item_id_and_locale"
|
||||
t.index ["item_id"], name: "index_item_translations_on_item_id"
|
||||
t.index ["locale"], name: "index_item_translations_on_locale"
|
||||
t.index ["name"], name: "index_item_translations_name"
|
||||
end
|
||||
|
||||
create_table "items", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
|
||||
t.text "zones_restrict", null: false
|
||||
t.text "thumbnail_url", size: :medium, null: false
|
||||
|
|
|
|||
BIN
vendor/cache/globalize-6.3.0.gem
vendored
Normal file
BIN
vendor/cache/globalize-6.3.0.gem
vendored
Normal file
Binary file not shown.
BIN
vendor/cache/request_store-1.5.1.gem
vendored
Normal file
BIN
vendor/cache/request_store-1.5.1.gem
vendored
Normal file
Binary file not shown.
Loading…
Reference in a new issue