g11n 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -74,14 +74,35 @@ G11n.t.home.land # => "Российская Федер
74
74
 
75
75
  Also, the `G11n::DSL` module can be included in any object of class you want to use the `#t` method more confortably.
76
76
 
77
- > **Note**: g11n is planned to soon be made a Sinatra extension
77
+ ## Use it in Sinatra
78
+ The G11n DSL (the `#t` and `#translate` methods) are available as a module unimaginatively called `G11n::DSL`. You can of course include it into your helpers as easy as:
79
+
80
+ ```ruby
81
+ # .app.rb
82
+ require 'sinatra'
83
+ require 'g11n'
84
+
85
+ helpers G11n::DSL
86
+
87
+ G11n.locale :es
88
+
89
+ get '/' do
90
+ t.welcome # => "¡Bienvenido, amigo!"
91
+ # as described in es.yaml
92
+ end
93
+ ```
94
+
95
+ ```yaml
96
+ # .translations/es.yaml
97
+ welcome: ¡Bienvenido, amigo!
98
+ ```
99
+
100
+ It works in modular style too.
78
101
 
79
102
  ## Testing
80
103
 
81
104
  Cucumber features and RSpec specs are provided to check functionality.
82
105
 
83
- An exception is the G11n::Dictionary class, which is just a subclass of SymbolTable that recursively converts all hashes passed as argument to the initializer into Dictionaries. This is really handy.
84
-
85
106
  ## License
86
107
 
87
108
  Copyright (C) 2012 Fetcher
@@ -16,3 +16,5 @@ Scenario: Setup the translations path, the locale and get a translation
16
16
  Then I should see "Mate"
17
17
  When I send :locale to the configuration DSL
18
18
  Then I should see :uy
19
+ When I send :path to the configuration DSL
20
+ Then I should see "i18n/"
@@ -24,7 +24,7 @@ end
24
24
  And /^I run "(.*?)" on the :(\w+) method$/ do |argument, message|
25
25
  o = Object.new
26
26
  o.extend G11n::DSL
27
- @the_translation = eval "o.#{message}.#{argument}"
27
+ @result = eval "o.#{message}.#{argument}"
28
28
  end
29
29
 
30
30
  When /^I send :(\w+) to the configuration DSL$/ do |message|
@@ -16,9 +16,9 @@ When /^I have the locale setted as "(.*?)"$/ do |locale|
16
16
  end
17
17
 
18
18
  And /^I write "(.*?)" in the translation engine$/ do |identifier|
19
- @the_translation = eval "G11n::Translator.instance.translate.#{identifier}"
19
+ @result = eval "G11n::Translator.instance.translate.#{identifier}"
20
20
  end
21
21
 
22
22
  Then /^I should see "(.*?)"$/ do |text|
23
- @the_translation.should == text
23
+ @result.should == text
24
24
  end
@@ -2,8 +2,9 @@ module G11n
2
2
  # DSL for the configuration of G11n
3
3
  module Configuration
4
4
  # Sets the translations path
5
- def path the_path
6
- Translator.instance.translations_path = the_path + "/"
5
+ def path the_path = nil
6
+ Translator.instance.translations_path = the_path + "/" if the_path
7
+ Translator.instance.translations_path
7
8
  end
8
9
 
9
10
  # Sets or get the locale
@@ -24,6 +24,11 @@ module G11n
24
24
  def translations_path= the_path
25
25
  @translations_path = the_path
26
26
  end
27
+
28
+ # @return [String] the current path to translations
29
+ def translations_path
30
+ @translations_path
31
+ end
27
32
 
28
33
  # Forwards the method call to the right "dictionary" (a SymbolTable object)
29
34
  # http://mjijackson.com/2010/04/config-revisited
@@ -1,3 +1,3 @@
1
1
  module G11n
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -62,6 +62,12 @@ describe G11n::Translator do
62
62
  end
63
63
  end
64
64
 
65
+ describe "#translations_path" do
66
+ it "should return the translations path" do
67
+ G11n::Translator.instance.translations_path.should == "translations/"
68
+ end
69
+ end
70
+
65
71
  describe "#dictionary_for" do
66
72
  context "there is in fact a dictionary for the locale" do
67
73
  before do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: g11n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-29 00:00:00.000000000 Z
12
+ date: 2012-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: symbolmatrix
@@ -130,21 +130,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
130
  - - ! '>='
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
- segments:
134
- - 0
135
- hash: 686192047
136
133
  required_rubygems_version: !ruby/object:Gem::Requirement
137
134
  none: false
138
135
  requirements:
139
136
  - - ! '>='
140
137
  - !ruby/object:Gem::Version
141
138
  version: '0'
142
- segments:
143
- - 0
144
- hash: 686192047
145
139
  requirements: []
146
140
  rubyforge_project:
147
- rubygems_version: 1.8.24
141
+ rubygems_version: 1.8.21
148
142
  signing_key:
149
143
  specification_version: 3
150
144
  summary: Internationalization library focused in simplicity of implementation
@@ -156,3 +150,4 @@ test_files:
156
150
  - features/support/env.rb
157
151
  - features/support/hooks.rb
158
152
  - spec/g11n/translator_spec.rb
153
+ has_rdoc: