i18n-js 3.0.0.rc5 → 3.0.0.rc6

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/spec/js/specs.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <script type="text/javascript" src="jasmine/jasmine-html.js"></script>
13
13
 
14
14
  <!-- load your javascript files -->
15
- <script type="text/javascript" src="../../lib/i18n.js"></script>
15
+ <script type="text/javascript" src="../../app/assets/javascripts/i18n.js"></script>
16
16
  <script type="text/javascript">
17
17
  function require(path) {
18
18
  if (path.match(/i18n/)) {
@@ -82,6 +82,44 @@ describe("Translate", function(){
82
82
  expect(I18n.t("hello")).toEqual("Hei Verden!");
83
83
  });
84
84
 
85
+ describe("when provided default valutes", function() {
86
+ it("uses scope provided in defaults if scope doesn't exist", function() {
87
+ actual = I18n.t("Hello!", {defaults: [{scope: "greetings.stranger"}]});
88
+ expect(actual).toEqual("Hello stranger!");
89
+ });
90
+
91
+ it("continues to fallback until a scope is found", function() {
92
+ var defaults = [{scope: "foo"}, {scope: "hello"}];
93
+
94
+ actual = I18n.t("foo", {defaults: defaults});
95
+ expect(actual).toEqual("Hello World!");
96
+ });
97
+
98
+ it("uses message if specified as a default", function() {
99
+ var defaults = [{message: "Hello all!"}];
100
+ actual = I18n.t("foo", {defaults: defaults});
101
+ expect(actual).toEqual("Hello all!");
102
+ });
103
+
104
+ it("uses the first message if no scopes are found", function() {
105
+ var defaults = [
106
+ {scope: "bar"}
107
+ , {message: "Hello all!"}
108
+ , {scope: "hello"}];
109
+ actual = I18n.t("foo", {defaults: defaults});
110
+ expect(actual).toEqual("Hello all!");
111
+ });
112
+
113
+ it("uses default value if no scope is found", function() {
114
+ var options = {
115
+ defaults: [{scope: "bar"}]
116
+ , defaultValue: "Hello all!"
117
+ };
118
+ actual = I18n.t("foo", options);
119
+ expect(actual).toEqual("Hello all!");
120
+ });
121
+ });
122
+
85
123
  it("uses default value for simple translation", function(){
86
124
  actual = I18n.t("warning", {defaultValue: "Warning!"});
87
125
  expect(actual).toEqual("Warning!");
@@ -117,4 +155,24 @@ describe("Translate", function(){
117
155
  expect(I18n.t("booleans.yes")).toEqual(true);
118
156
  expect(I18n.t("booleans.no")).toEqual(false);
119
157
  });
158
+
159
+ it("escapes $ when doing substitution (IE)", function(){
160
+ I18n.locale = "en";
161
+
162
+ expect(I18n.t("paid", {price: "$0.12"})).toEqual("You were paid $0.12");
163
+ expect(I18n.t("paid", {price: "$1.35"})).toEqual("You were paid $1.35");
164
+ });
165
+
166
+ it("sets default scope", function(){
167
+ var options = {scope: "greetings"};
168
+ expect(I18n.t("stranger", options)).toEqual("Hello stranger!");
169
+ });
170
+
171
+ it("accepts the scope as an array", function(){
172
+ expect(I18n.t(["greetings", "stranger"])).toEqual("Hello stranger!");
173
+ });
174
+
175
+ it("accepts the scope as an array using a base scope", function(){
176
+ expect(I18n.t(["stranger"], {scope: "greetings"})).toEqual("Hello stranger!");
177
+ });
120
178
  });
@@ -1,9 +1,12 @@
1
+ var DEBUG = false;
2
+
1
3
  ;(function(){
2
4
  var generator = function() {
3
5
  var Translations = {};
4
6
 
5
7
  Translations.en = {
6
8
  hello: "Hello World!"
9
+ , paid: "You were paid %{price}"
7
10
 
8
11
  , booleans: {
9
12
  yes: true,
@@ -102,7 +105,15 @@
102
105
  };
103
106
 
104
107
  Translations["de"] = {
105
- hello: "Hallo Welt!"
108
+ hello: "Hallo Welt!"
109
+ , date: {
110
+ day_names: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"]
111
+ }
112
+
113
+ , time: {
114
+ am: "de:AM"
115
+ , pm: "de:PM"
116
+ }
106
117
  };
107
118
 
108
119
  Translations["nb"] = {
data/spec/spec_helper.rb CHANGED
@@ -7,8 +7,8 @@ require "i18n/js"
7
7
  module Helpers
8
8
  # Set the configuration as the current one
9
9
  def set_config(path)
10
- config = HashWithIndifferentAccess.new(YAML.load_file(File.dirname(__FILE__) + "/fixtures/#{path}"))
11
- I18n::JS.stub(:config? => true, :config => config)
10
+ config_file = File.dirname(__FILE__) + "/fixtures/#{path}"
11
+ I18n::JS.stub(:config? => true, :config_file => config_file)
12
12
  end
13
13
 
14
14
  # Shortcut to I18n::JS.translations
@@ -37,5 +37,13 @@ RSpec.configure do |config|
37
37
  end
38
38
 
39
39
  config.include Helpers
40
+
41
+ # Remove deprecation warnings
42
+ config.expect_with :rspec do |c|
43
+ c.syntax = [:should, :expect]
44
+ end
45
+ config.mock_with :rspec do |c|
46
+ c.syntax = [:should, :expect]
47
+ end
40
48
  end
41
49
 
metadata CHANGED
@@ -1,57 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-js
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc5
4
+ version: 3.0.0.rc6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-08 00:00:00.000000000 Z
11
+ date: 2014-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: appraisal
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: activesupport
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - '>='
32
46
  - !ruby/object:Gem::Version
33
- version: '0'
47
+ version: '3'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - '>='
39
53
  - !ruby/object:Gem::Version
40
- version: '0'
54
+ version: '3'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - '>='
59
+ - - ~>
46
60
  - !ruby/object:Gem::Version
47
- version: '0'
61
+ version: '3.0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ~>
53
67
  - !ruby/object:Gem::Version
54
- version: '0'
68
+ version: '3.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +94,20 @@ dependencies:
80
94
  - - '>='
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: gem-release
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0.7'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0.7'
83
111
  description: It's a small library to provide the Rails I18n translations on the Javascript.
84
112
  email:
85
113
  - fnando.vieira@gmail.com
@@ -88,25 +116,35 @@ extensions: []
88
116
  extra_rdoc_files: []
89
117
  files:
90
118
  - .gitignore
119
+ - .travis.yml
120
+ - Appraisals
121
+ - CHANGELOG.md
91
122
  - Gemfile
92
- - Gemfile.lock
93
123
  - README.md
94
124
  - Rakefile
95
125
  - app/assets/javascripts/i18n.js
126
+ - app/assets/javascripts/i18n/filtered.js.erb
96
127
  - app/assets/javascripts/i18n/shims.js
97
- - app/assets/javascripts/i18n/translations.js.erb
128
+ - app/assets/javascripts/i18n/translations.js
129
+ - gemfiles/i18n_0_6.gemfile
98
130
  - i18n-js.gemspec
99
131
  - lib/i18n-js.rb
100
132
  - lib/i18n/js.rb
133
+ - lib/i18n/js/dependencies.rb
101
134
  - lib/i18n/js/engine.rb
102
135
  - lib/i18n/js/middleware.rb
103
136
  - lib/i18n/js/version.rb
137
+ - lib/rails/generators/i18n/js/config/config_generator.rb
138
+ - lib/rails/generators/i18n/js/config/templates/i18n-js.yml
139
+ - lib/tasks/export.rake
104
140
  - package.json
105
141
  - spec/fixtures/custom_path.yml
106
142
  - spec/fixtures/default.yml
143
+ - spec/fixtures/erb.yml
107
144
  - spec/fixtures/js_file_per_locale.yml
108
145
  - spec/fixtures/locales.yml
109
146
  - spec/fixtures/multiple_conditions.yml
147
+ - spec/fixtures/multiple_conditions_per_locale.yml
110
148
  - spec/fixtures/multiple_files.yml
111
149
  - spec/fixtures/no_config.yml
112
150
  - spec/fixtures/no_scope.yml
@@ -150,8 +188,40 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
188
  version: 1.3.1
151
189
  requirements: []
152
190
  rubyforge_project:
153
- rubygems_version: 2.0.2
191
+ rubygems_version: 2.2.2
154
192
  signing_key:
155
193
  specification_version: 4
156
194
  summary: It's a small library to provide the Rails I18n translations on the Javascript.
157
- test_files: []
195
+ test_files:
196
+ - spec/fixtures/custom_path.yml
197
+ - spec/fixtures/default.yml
198
+ - spec/fixtures/erb.yml
199
+ - spec/fixtures/js_file_per_locale.yml
200
+ - spec/fixtures/locales.yml
201
+ - spec/fixtures/multiple_conditions.yml
202
+ - spec/fixtures/multiple_conditions_per_locale.yml
203
+ - spec/fixtures/multiple_files.yml
204
+ - spec/fixtures/no_config.yml
205
+ - spec/fixtures/no_scope.yml
206
+ - spec/fixtures/simple_scope.yml
207
+ - spec/i18n_js_spec.rb
208
+ - spec/js/currency.spec.js
209
+ - spec/js/current_locale.spec.js
210
+ - spec/js/dates.spec.js
211
+ - spec/js/defaults.spec.js
212
+ - spec/js/interpolation.spec.js
213
+ - spec/js/jasmine/MIT.LICENSE
214
+ - spec/js/jasmine/jasmine-html.js
215
+ - spec/js/jasmine/jasmine.css
216
+ - spec/js/jasmine/jasmine.js
217
+ - spec/js/jasmine/jasmine_favicon.png
218
+ - spec/js/localization.spec.js
219
+ - spec/js/numbers.spec.js
220
+ - spec/js/placeholder.spec.js
221
+ - spec/js/pluralization.spec.js
222
+ - spec/js/prepare_options.spec.js
223
+ - spec/js/specs.html
224
+ - spec/js/translate.spec.js
225
+ - spec/js/translations.js
226
+ - spec/spec_helper.rb
227
+ has_rdoc:
data/Gemfile.lock DELETED
@@ -1,52 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- i18n-js (3.0.0.rc5)
5
- i18n
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activesupport (3.2.12)
11
- i18n (~> 0.6)
12
- multi_json (~> 1.0)
13
- awesome_print (1.1.0)
14
- coderay (1.0.9)
15
- diff-lcs (1.2.1)
16
- i18n (0.6.4)
17
- method_source (0.8.1)
18
- multi_json (1.6.1)
19
- pry (0.9.12)
20
- coderay (~> 1.0.5)
21
- method_source (~> 0.8)
22
- slop (~> 3.4)
23
- pry-meta (0.0.5)
24
- awesome_print
25
- pry
26
- pry-nav
27
- pry-remote
28
- pry-nav (0.2.3)
29
- pry (~> 0.9.10)
30
- pry-remote (0.1.7)
31
- pry (~> 0.9)
32
- slop (~> 3.0)
33
- rake (10.0.3)
34
- rspec (2.13.0)
35
- rspec-core (~> 2.13.0)
36
- rspec-expectations (~> 2.13.0)
37
- rspec-mocks (~> 2.13.0)
38
- rspec-core (2.13.0)
39
- rspec-expectations (2.13.0)
40
- diff-lcs (>= 1.1.3, < 2.0)
41
- rspec-mocks (2.13.0)
42
- slop (3.4.3)
43
-
44
- PLATFORMS
45
- ruby
46
-
47
- DEPENDENCIES
48
- activesupport
49
- i18n-js!
50
- pry-meta
51
- rake
52
- rspec