i18n-js 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- i18n-js (2.0.0)
4
+ i18n-js (2.0.1)
5
5
  i18n
6
6
 
7
7
  GEM
@@ -45,7 +45,7 @@ DEPENDENCIES
45
45
  activesupport (>= 3.0.0)
46
46
  fakeweb
47
47
  i18n-js!
48
- rake (= 0.8.7)
48
+ rake
49
49
  rspec (~> 2.6)
50
50
  ruby-debug19
51
51
  spec-js (~> 0.1.0.beta.0)
data/i18n-js.gemspec CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency "rspec", "~> 2.6"
24
24
  s.add_development_dependency "ruby-debug19"
25
25
  s.add_development_dependency "spec-js", "~> 0.1.0.beta.0"
26
- s.add_development_dependency "rake", "0.8.7"
26
+ s.add_development_dependency "rake"
27
27
  s.add_development_dependency "ruby-debug19"
28
28
  end
data/lib/i18n-js.rb CHANGED
@@ -32,13 +32,19 @@ module SimplesIdeias
32
32
  def export!
33
33
  if config?
34
34
  for options in config[:translations]
35
- options.reverse_merge!(:only => "*")
36
-
37
- if options[:only] == "*"
38
- save translations, options[:file]
35
+ if options[:file] =~ ::I18n::INTERPOLATION_PATTERN
36
+ ::I18n.available_locales.each do |locale|
37
+ result = scoped_translations("#{locale}.#{options[:only]}")
38
+ save result, ::I18n.interpolate(options[:file],{:locale => locale}) unless result.empty?
39
+ end
39
40
  else
40
- result = scoped_translations(options[:only])
41
- save result, options[:file] unless result.empty?
41
+ options.reverse_merge!(:only => "*")
42
+ if options[:only] == "*"
43
+ save translations, options[:file]
44
+ else
45
+ result = scoped_translations(options[:only])
46
+ save result, options[:file] unless result.empty?
47
+ end
42
48
  end
43
49
  end
44
50
  else
@@ -3,7 +3,7 @@ module SimplesIdeias
3
3
  module Version
4
4
  MAJOR = 2
5
5
  MINOR = 0
6
- PATCH = 0
6
+ PATCH = 1
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
9
9
  end
data/spec/i18n_spec.rb CHANGED
@@ -88,6 +88,13 @@ describe SimplesIdeias::I18n do
88
88
  File.should be_file(Rails.root.join("public/javascripts/tudo.js"))
89
89
  end
90
90
 
91
+ it "exports to a JS file per available locale" do
92
+ set_config "js_file_per_locale.yml"
93
+ SimplesIdeias::I18n.export!
94
+
95
+ File.should be_file(Rails.root.join("public/javascripts/i18n/en.js"))
96
+ end
97
+
91
98
  it "exports with multiple conditions" do
92
99
  set_config "multiple_conditions.yml"
93
100
  SimplesIdeias::I18n.export!
@@ -0,0 +1,3 @@
1
+ translations:
2
+ - file: "public/javascripts/i18n/%{locale}.js"
3
+ only: '*'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-js
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-24 00:00:00.000000000Z
12
+ date: 2011-09-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
16
- requirement: &70302525717000 !ruby/object:Gem::Requirement
16
+ requirement: &70095310296720 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70302525717000
24
+ version_requirements: *70095310296720
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: fakeweb
27
- requirement: &70302525716240 !ruby/object:Gem::Requirement
27
+ requirement: &70095310295900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70302525716240
35
+ version_requirements: *70095310295900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
38
- requirement: &70302525715340 !ruby/object:Gem::Requirement
38
+ requirement: &70095310294720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 3.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70302525715340
46
+ version_requirements: *70095310294720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70302525708020 !ruby/object:Gem::Requirement
49
+ requirement: &70095310293520 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '2.6'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70302525708020
57
+ version_requirements: *70095310293520
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: ruby-debug19
60
- requirement: &70302525707340 !ruby/object:Gem::Requirement
60
+ requirement: &70095310293060 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70302525707340
68
+ version_requirements: *70095310293060
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: spec-js
71
- requirement: &70302525706180 !ruby/object:Gem::Requirement
71
+ requirement: &70095310292000 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,21 +76,21 @@ dependencies:
76
76
  version: 0.1.0.beta.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70302525706180
79
+ version_requirements: *70095310292000
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rake
82
- requirement: &70302525705440 !ruby/object:Gem::Requirement
82
+ requirement: &70095310290820 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
- - - =
85
+ - - ! '>='
86
86
  - !ruby/object:Gem::Version
87
- version: 0.8.7
87
+ version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70302525705440
90
+ version_requirements: *70095310290820
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: ruby-debug19
93
- requirement: &70302525704920 !ruby/object:Gem::Requirement
93
+ requirement: &70095310288840 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70302525704920
101
+ version_requirements: *70095310288840
102
102
  description: It's a small library to provide the Rails I18n translations on the Javascript.
103
103
  email:
104
104
  - fnando.vieira@gmail.com
@@ -124,6 +124,7 @@ files:
124
124
  - spec/i18n_spec.rb
125
125
  - spec/resources/custom_path.yml
126
126
  - spec/resources/default.yml
127
+ - spec/resources/js_file_per_locale.yml
127
128
  - spec/resources/locales.yml
128
129
  - spec/resources/multiple_conditions.yml
129
130
  - spec/resources/multiple_files.yml
@@ -145,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
146
  version: '0'
146
147
  segments:
147
148
  - 0
148
- hash: 2319593298030607948
149
+ hash: 3561709874973960636
149
150
  required_rubygems_version: !ruby/object:Gem::Requirement
150
151
  none: false
151
152
  requirements:
@@ -154,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
155
  version: '0'
155
156
  segments:
156
157
  - 0
157
- hash: 2319593298030607948
158
+ hash: 3561709874973960636
158
159
  requirements: []
159
160
  rubyforge_project:
160
161
  rubygems_version: 1.8.10
@@ -166,6 +167,7 @@ test_files:
166
167
  - spec/i18n_spec.rb
167
168
  - spec/resources/custom_path.yml
168
169
  - spec/resources/default.yml
170
+ - spec/resources/js_file_per_locale.yml
169
171
  - spec/resources/locales.yml
170
172
  - spec/resources/multiple_conditions.yml
171
173
  - spec/resources/multiple_files.yml