From 8f6998faf4d06864f8eb88a4ef0e4d3e566d3bd3 Mon Sep 17 00:00:00 2001 From: pablofullana Date: Sun, 28 May 2017 10:10:05 -0300 Subject: [PATCH 1/5] Add i18n --- goby.gemspec | 2 ++ lib/goby.rb | 3 +++ lib/goby/config/locales/en.yml | 6 ++++++ lib/goby/entity/entity.rb | 6 +++--- 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 lib/goby/config/locales/en.yml diff --git a/goby.gemspec b/goby.gemspec index 2aaa5ee..0bf2f82 100644 --- a/goby.gemspec +++ b/goby.gemspec @@ -18,6 +18,8 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] + spec.add_dependency "i18n", "~> 0.8" + spec.add_development_dependency "bundler", "~> 1.14" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rspec", "~> 3.0" diff --git a/lib/goby.rb b/lib/goby.rb index 47fb058..15bbb2e 100644 --- a/lib/goby.rb +++ b/lib/goby.rb @@ -6,6 +6,9 @@ module Goby # Import order matters. +require 'i18n' +I18n.load_path = Dir["#{File.expand_path(File.dirname(__FILE__))}/goby/config/locales/*.yml"] + require 'goby/extension' require 'goby/util' require 'goby/world_command' diff --git a/lib/goby/config/locales/en.yml b/lib/goby/config/locales/en.yml new file mode 100644 index 0000000..62bd2d8 --- /dev/null +++ b/lib/goby/config/locales/en.yml @@ -0,0 +1,6 @@ +en: + goby: + entity: + errors: + no_such_item: "What?! You don't have THAT!" + item_not_equipped: "You are not equipping THAT!" diff --git a/lib/goby/entity/entity.rb b/lib/goby/entity/entity.rb index 4d1b3c1..3494382 100644 --- a/lib/goby/entity/entity.rb +++ b/lib/goby/entity/entity.rb @@ -7,9 +7,9 @@ module Goby class Entity # Error when the entity specifies a non-existent item. - NO_SUCH_ITEM_ERROR = "What?! You don't have THAT!\n\n" + NO_SUCH_ITEM_ERROR = I18n.t('goby.entity.errors.no_such_item') # Error when the entity specifies an item not equipped. - NOT_EQUIPPED_ERROR = "You are not equipping THAT!\n\n" + NOT_EQUIPPED_ERROR = I18n.t('goby.entity.errors.item_not_equipped') # @param [String] name the name. # @param [Hash] stats hash of stats @@ -365,4 +365,4 @@ def check_and_set_gold end -end \ No newline at end of file +end From 42541bd64004ed301187d38b7bbcf82cc489d0b3 Mon Sep 17 00:00:00 2001 From: pablofullana Date: Sun, 28 May 2017 11:54:02 -0300 Subject: [PATCH 2/5] Add es.yml locale file --- lib/goby/config/locales/es.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 lib/goby/config/locales/es.yml diff --git a/lib/goby/config/locales/es.yml b/lib/goby/config/locales/es.yml new file mode 100644 index 0000000..aa576d2 --- /dev/null +++ b/lib/goby/config/locales/es.yml @@ -0,0 +1,6 @@ +en: + goby: + entity: + errors: + no_such_item: "¿Qué? ¡No tienes eso!" + item_not_equipped: "¡No estás equipando eso!" From c98ecfdaefc5da399e0a22ad47fedb5a9114ecc2 Mon Sep 17 00:00:00 2001 From: pablofullana Date: Sun, 28 May 2017 12:04:31 -0300 Subject: [PATCH 3/5] Require i18n --- goby.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/goby.gemspec b/goby.gemspec index 0bf2f82..87f63d7 100644 --- a/goby.gemspec +++ b/goby.gemspec @@ -2,6 +2,7 @@ lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'goby' +require 'i18n' Gem::Specification.new do |spec| spec.name = "goby" From 192eb2492bf9982d322274cd424fb8295dd4eeb1 Mon Sep 17 00:00:00 2001 From: pablofullana Date: Sun, 28 May 2017 12:13:30 -0300 Subject: [PATCH 4/5] Do not require goby in gemspec --- goby.gemspec | 2 -- 1 file changed, 2 deletions(-) diff --git a/goby.gemspec b/goby.gemspec index 87f63d7..68ef6e1 100644 --- a/goby.gemspec +++ b/goby.gemspec @@ -1,8 +1,6 @@ # coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'goby' -require 'i18n' Gem::Specification.new do |spec| spec.name = "goby" From dfc732bc07150e4816b01d58c9a698cb5f7e7337 Mon Sep 17 00:00:00 2001 From: pablofullana Date: Sun, 28 May 2017 12:33:17 -0300 Subject: [PATCH 5/5] Move version to version.rb file --- goby.gemspec | 3 ++- lib/goby.rb | 5 ----- lib/goby/version.rb | 4 ++++ 3 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 lib/goby/version.rb diff --git a/goby.gemspec b/goby.gemspec index 68ef6e1..a4b2f10 100644 --- a/goby.gemspec +++ b/goby.gemspec @@ -1,10 +1,11 @@ # coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'goby/version' Gem::Specification.new do |spec| spec.name = "goby" - spec.version = Goby::VERSION + spec.version = Goby::VERSION.dup spec.authors = ["Nicholas Skinsacos"] spec.email = ["nskins@umich.edu"] diff --git a/lib/goby.rb b/lib/goby.rb index 15bbb2e..bd790d3 100644 --- a/lib/goby.rb +++ b/lib/goby.rb @@ -1,9 +1,4 @@ # Main module of the framework. -module Goby - # Version of the framework. - VERSION = "0.1.0" -end - # Import order matters. require 'i18n' diff --git a/lib/goby/version.rb b/lib/goby/version.rb new file mode 100644 index 0000000..d80716b --- /dev/null +++ b/lib/goby/version.rb @@ -0,0 +1,4 @@ +module Goby + # Version of the framework. + VERSION = "0.1.0".freeze +end