Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add i18n support #106

Open
wants to merge 6 commits into
base: i18n
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion goby.gemspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# 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 = "0.1.0"
spec.version = Goby::VERSION.dup
spec.authors = ["Nicholas Skinsacos"]
spec.email = ["[email protected]"]

spec.summary = %q{Framework for creating text RPGs.}
spec.homepage = "https://github.com/nskins/goby"
spec.license = "MIT"

spec.files = Dir["{lib}/**/*", "LICENSE", "README.md" ]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is redundant, it's re-specified next line down.

spec.files = Dir["{exe}/**/*", "{lib}/**/*", "{res}/**/*", "LICENSE", "README.md" ]
spec.bindir = "exe"
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"
Expand Down
6 changes: 6 additions & 0 deletions lib/goby.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Main module of the framework.
# Import order matters.

require 'i18n'
I18n.load_path = Dir["#{File.expand_path(File.dirname(__FILE__))}/goby/config/locales/*.yml"]

# Import order matters.

require 'goby/scaffold'
Expand Down
6 changes: 6 additions & 0 deletions lib/goby/config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -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!"
6 changes: 6 additions & 0 deletions lib/goby/config/locales/es.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
en:
goby:
entity:
errors:
no_such_item: "¿Qué? ¡No tienes eso!"
item_not_equipped: "¡No estás equipando eso!"
6 changes: 3 additions & 3 deletions lib/goby/entity/entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -372,4 +372,4 @@ def check_and_set_gold

end

end
end
4 changes: 4 additions & 0 deletions lib/goby/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Goby
# Version of the framework.
VERSION = "0.1.0".freeze
end