i18n-js 2.1.2 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +23 -31
- data/README.md +318 -0
- data/Rakefile +6 -6
- data/app/assets/javascripts/i18n/translations.js.erb +3 -0
- data/i18n-js.gemspec +5 -6
- data/lib/i18n-js.rb +1 -177
- data/lib/i18n.js +698 -0
- data/lib/i18n/js.rb +157 -0
- data/lib/i18n/js/engine.rb +22 -0
- data/lib/{i18n-js → i18n/js}/middleware.rb +7 -7
- data/lib/i18n/js/version.rb +10 -0
- data/spec/{resources → fixtures}/custom_path.yml +1 -1
- data/spec/{resources → fixtures}/default.yml +1 -1
- data/spec/fixtures/js_file_per_locale.yml +3 -0
- data/spec/{resources → fixtures}/locales.yml +1 -1
- data/spec/fixtures/multiple_conditions.yml +5 -0
- data/spec/{resources → fixtures}/multiple_files.yml +3 -3
- data/spec/{resources → fixtures}/no_config.yml +0 -0
- data/spec/{resources → fixtures}/no_scope.yml +1 -1
- data/spec/{resources → fixtures}/simple_scope.yml +1 -1
- data/spec/i18n_js_spec.rb +122 -0
- data/spec/js/currency.spec.js +60 -0
- data/spec/js/current_locale.spec.js +19 -0
- data/spec/js/dates.spec.js +218 -0
- data/spec/js/defaults.spec.js +23 -0
- data/spec/js/interpolation.spec.js +28 -0
- data/spec/js/jasmine/MIT.LICENSE +20 -0
- data/spec/js/jasmine/jasmine-html.js +190 -0
- data/spec/js/jasmine/jasmine.css +166 -0
- data/spec/js/jasmine/jasmine.js +2476 -0
- data/spec/js/jasmine/jasmine_favicon.png +0 -0
- data/spec/js/localization.spec.js +41 -0
- data/spec/js/numbers.spec.js +124 -0
- data/spec/js/placeholder.spec.js +24 -0
- data/spec/js/pluralization.spec.js +105 -0
- data/spec/js/prepare_options.spec.js +41 -0
- data/spec/js/specs.html +46 -0
- data/spec/js/translate.spec.js +115 -0
- data/spec/js/translations.js +115 -0
- data/spec/spec_helper.rb +36 -14
- metadata +115 -69
- data/.gitignore +0 -5
- data/.rspec +0 -1
- data/README.rdoc +0 -305
- data/config/i18n-js.yml +0 -22
- data/lib/i18n-js/engine.rb +0 -62
- data/lib/i18n-js/railtie.rb +0 -13
- data/lib/i18n-js/rake.rb +0 -16
- data/lib/i18n-js/version.rb +0 -10
- data/spec/i18n_spec.js +0 -768
- data/spec/i18n_spec.rb +0 -205
- data/spec/resources/js_file_per_locale.yml +0 -3
- data/spec/resources/multiple_conditions.yml +0 -6
- data/vendor/assets/javascripts/i18n.js +0 -450
- data/vendor/assets/javascripts/i18n/translations.js.erb +0 -7
@@ -0,0 +1,115 @@
|
|
1
|
+
;(function(){
|
2
|
+
var generator = function() {
|
3
|
+
var Translations = {};
|
4
|
+
|
5
|
+
Translations.en = {
|
6
|
+
hello: "Hello World!"
|
7
|
+
|
8
|
+
, greetings: {
|
9
|
+
stranger: "Hello stranger!"
|
10
|
+
, name: "Hello {{name}}!"
|
11
|
+
}
|
12
|
+
|
13
|
+
, profile: {
|
14
|
+
details: "{{name}} is {{age}}-years old"
|
15
|
+
}
|
16
|
+
|
17
|
+
, inbox: {
|
18
|
+
one: "You have {{count}} message"
|
19
|
+
, other: "You have {{count}} messages"
|
20
|
+
, zero: "You have no messages"
|
21
|
+
}
|
22
|
+
|
23
|
+
, unread: {
|
24
|
+
one: "You have 1 new message ({{unread}} unread)"
|
25
|
+
, other: "You have {{count}} new messages ({{unread}} unread)"
|
26
|
+
, zero: "You have no new messages ({{unread}} unread)"
|
27
|
+
}
|
28
|
+
|
29
|
+
, number: {
|
30
|
+
human: {
|
31
|
+
storage_units: {
|
32
|
+
units: {
|
33
|
+
"byte": {
|
34
|
+
one: "Byte"
|
35
|
+
, other: "Bytes"
|
36
|
+
}
|
37
|
+
, "kb": "KB"
|
38
|
+
, "mb": "MB"
|
39
|
+
, "gb": "GB"
|
40
|
+
, "tb": "TB"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
};
|
46
|
+
|
47
|
+
Translations["en-US"] = {
|
48
|
+
date: {
|
49
|
+
formats: {
|
50
|
+
"default": "%d/%m/%Y"
|
51
|
+
, "short": "%d de %B"
|
52
|
+
, "long": "%d de %B de %Y"
|
53
|
+
}
|
54
|
+
|
55
|
+
, day_names: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
|
56
|
+
, abbr_day_names: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
57
|
+
, month_names: [null, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
|
58
|
+
, abbr_month_names: [null, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]
|
59
|
+
, meridian: ["am", "pm"]
|
60
|
+
}
|
61
|
+
};
|
62
|
+
|
63
|
+
Translations["pt-BR"] = {
|
64
|
+
hello: "Olá Mundo!"
|
65
|
+
|
66
|
+
, number: {
|
67
|
+
percentage: {
|
68
|
+
format: {
|
69
|
+
delimiter: ""
|
70
|
+
, separator: ","
|
71
|
+
, precision: 2
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
, date: {
|
77
|
+
formats: {
|
78
|
+
"default": "%d/%m/%Y"
|
79
|
+
, "short": "%d de %B"
|
80
|
+
, "long": "%d de %B de %Y"
|
81
|
+
}
|
82
|
+
, day_names: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"]
|
83
|
+
, abbr_day_names: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"]
|
84
|
+
, month_names: [null, "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]
|
85
|
+
, abbr_month_names: [null, "Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"]
|
86
|
+
}
|
87
|
+
|
88
|
+
, time: {
|
89
|
+
formats: {
|
90
|
+
"default": "%A, %d de %B de %Y, %H:%M h"
|
91
|
+
, "short": "%d/%m, %H:%M h"
|
92
|
+
, "long": "%A, %d de %B de %Y, %H:%M h"
|
93
|
+
}
|
94
|
+
, am: "AM"
|
95
|
+
, pm: "PM"
|
96
|
+
}
|
97
|
+
};
|
98
|
+
|
99
|
+
Translations["de"] = {
|
100
|
+
hello: "Hallo Welt!"
|
101
|
+
};
|
102
|
+
|
103
|
+
Translations["nb"] = {
|
104
|
+
hello: "Hei Verden!"
|
105
|
+
};
|
106
|
+
|
107
|
+
return Translations;
|
108
|
+
};
|
109
|
+
|
110
|
+
if (typeof(exports) === "undefined") {
|
111
|
+
window.Translations = generator;
|
112
|
+
} else {
|
113
|
+
module.exports = generator;
|
114
|
+
}
|
115
|
+
})();
|
data/spec/spec_helper.rb
CHANGED
@@ -1,19 +1,41 @@
|
|
1
|
-
require "active_support/all"
|
2
|
-
require "active_support/version"
|
3
|
-
require "active_support/test_case"
|
4
|
-
require "ostruct"
|
5
|
-
require "pathname"
|
6
1
|
require "i18n"
|
7
2
|
require "json"
|
8
|
-
require "fakeweb"
|
9
3
|
|
10
|
-
|
4
|
+
require "active_support/all"
|
5
|
+
require "i18n/js"
|
6
|
+
|
7
|
+
module Helpers
|
8
|
+
# Set the configuration as the current one
|
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)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Shortcut to I18n::JS.translations
|
15
|
+
def translations
|
16
|
+
I18n::JS.translations
|
17
|
+
end
|
18
|
+
|
19
|
+
def file_should_exist(name)
|
20
|
+
file_path = File.join(I18n::JS.export_dir, name)
|
21
|
+
File.should be_file(file_path)
|
22
|
+
end
|
23
|
+
|
24
|
+
def temp_path(file_name = "")
|
25
|
+
File.expand_path("../../tmp/i18n-js/#{file_name}", __FILE__)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
RSpec.configure do |config|
|
30
|
+
config.before do
|
31
|
+
I18n.load_path = [File.dirname(__FILE__) + "/fixtures/locales.yml"]
|
32
|
+
FileUtils.rm_rf(temp_path)
|
33
|
+
end
|
34
|
+
|
35
|
+
config.after do
|
36
|
+
FileUtils.rm_rf(temp_path)
|
37
|
+
end
|
11
38
|
|
12
|
-
|
13
|
-
|
14
|
-
Rails = OpenStruct.new({
|
15
|
-
:root => Pathname.new(File.dirname(__FILE__) + "/tmp"),
|
16
|
-
:version => "0"
|
17
|
-
})
|
39
|
+
config.include Helpers
|
40
|
+
end
|
18
41
|
|
19
|
-
require "i18n-js"
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 3.0.0.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nando Vieira
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,54 +21,63 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: fakeweb
|
27
|
-
requirement: &70147377739360 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
none: false
|
29
26
|
requirements:
|
30
27
|
- - ! '>='
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: '0'
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70147377739360
|
36
30
|
- !ruby/object:Gem::Dependency
|
37
31
|
name: activesupport
|
38
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
34
|
requirements:
|
41
35
|
- - ! '>='
|
42
36
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
37
|
+
version: '0'
|
44
38
|
type: :development
|
45
39
|
prerelease: false
|
46
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
47
46
|
- !ruby/object:Gem::Dependency
|
48
47
|
name: rspec
|
49
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
50
49
|
none: false
|
51
50
|
requirements:
|
52
|
-
- -
|
51
|
+
- - ! '>='
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
53
|
+
version: '0'
|
55
54
|
type: :development
|
56
55
|
prerelease: false
|
57
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
58
62
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
60
|
-
requirement:
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
61
65
|
none: false
|
62
66
|
requirements:
|
63
|
-
- -
|
67
|
+
- - ! '>='
|
64
68
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0
|
69
|
+
version: '0'
|
66
70
|
type: :development
|
67
71
|
prerelease: false
|
68
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
71
|
-
requirement:
|
79
|
+
name: pry
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
72
81
|
none: false
|
73
82
|
requirements:
|
74
83
|
- - ! '>='
|
@@ -76,10 +85,15 @@ dependencies:
|
|
76
85
|
version: '0'
|
77
86
|
type: :development
|
78
87
|
prerelease: false
|
79
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
80
94
|
- !ruby/object:Gem::Dependency
|
81
|
-
name:
|
82
|
-
requirement:
|
95
|
+
name: awesome_print
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
83
97
|
none: false
|
84
98
|
requirements:
|
85
99
|
- - ! '>='
|
@@ -87,7 +101,12 @@ dependencies:
|
|
87
101
|
version: '0'
|
88
102
|
type: :development
|
89
103
|
prerelease: false
|
90
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
91
110
|
description: It's a small library to provide the Rails I18n translations on the Javascript.
|
92
111
|
email:
|
93
112
|
- fnando.vieira@gmail.com
|
@@ -95,34 +114,47 @@ executables: []
|
|
95
114
|
extensions: []
|
96
115
|
extra_rdoc_files: []
|
97
116
|
files:
|
98
|
-
- .gitignore
|
99
|
-
- .rspec
|
100
117
|
- Gemfile
|
101
118
|
- Gemfile.lock
|
102
|
-
- README.
|
119
|
+
- README.md
|
103
120
|
- Rakefile
|
104
|
-
-
|
121
|
+
- app/assets/javascripts/i18n/translations.js.erb
|
105
122
|
- i18n-js.gemspec
|
106
123
|
- lib/i18n-js.rb
|
107
|
-
- lib/i18n
|
108
|
-
- lib/i18n
|
109
|
-
- lib/i18n
|
110
|
-
- lib/i18n
|
111
|
-
- lib/i18n
|
112
|
-
- spec/
|
113
|
-
- spec/
|
114
|
-
- spec/
|
115
|
-
- spec/
|
116
|
-
- spec/
|
117
|
-
- spec/
|
118
|
-
- spec/
|
119
|
-
- spec/
|
120
|
-
- spec/
|
121
|
-
- spec/
|
122
|
-
- spec/
|
124
|
+
- lib/i18n.js
|
125
|
+
- lib/i18n/js.rb
|
126
|
+
- lib/i18n/js/engine.rb
|
127
|
+
- lib/i18n/js/middleware.rb
|
128
|
+
- lib/i18n/js/version.rb
|
129
|
+
- spec/fixtures/custom_path.yml
|
130
|
+
- spec/fixtures/default.yml
|
131
|
+
- spec/fixtures/js_file_per_locale.yml
|
132
|
+
- spec/fixtures/locales.yml
|
133
|
+
- spec/fixtures/multiple_conditions.yml
|
134
|
+
- spec/fixtures/multiple_files.yml
|
135
|
+
- spec/fixtures/no_config.yml
|
136
|
+
- spec/fixtures/no_scope.yml
|
137
|
+
- spec/fixtures/simple_scope.yml
|
138
|
+
- spec/i18n_js_spec.rb
|
139
|
+
- spec/js/currency.spec.js
|
140
|
+
- spec/js/current_locale.spec.js
|
141
|
+
- spec/js/dates.spec.js
|
142
|
+
- spec/js/defaults.spec.js
|
143
|
+
- spec/js/interpolation.spec.js
|
144
|
+
- spec/js/jasmine/MIT.LICENSE
|
145
|
+
- spec/js/jasmine/jasmine-html.js
|
146
|
+
- spec/js/jasmine/jasmine.css
|
147
|
+
- spec/js/jasmine/jasmine.js
|
148
|
+
- spec/js/jasmine/jasmine_favicon.png
|
149
|
+
- spec/js/localization.spec.js
|
150
|
+
- spec/js/numbers.spec.js
|
151
|
+
- spec/js/placeholder.spec.js
|
152
|
+
- spec/js/pluralization.spec.js
|
153
|
+
- spec/js/prepare_options.spec.js
|
154
|
+
- spec/js/specs.html
|
155
|
+
- spec/js/translate.spec.js
|
156
|
+
- spec/js/translations.js
|
123
157
|
- spec/spec_helper.rb
|
124
|
-
- vendor/assets/javascripts/i18n.js
|
125
|
-
- vendor/assets/javascripts/i18n/translations.js.erb
|
126
158
|
homepage: http://rubygems.org/gems/i18n-js
|
127
159
|
licenses: []
|
128
160
|
post_install_message:
|
@@ -137,32 +169,46 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
169
|
version: '0'
|
138
170
|
segments:
|
139
171
|
- 0
|
140
|
-
hash:
|
172
|
+
hash: 2924764751432745810
|
141
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
174
|
none: false
|
143
175
|
requirements:
|
144
|
-
- - ! '
|
176
|
+
- - ! '>'
|
145
177
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
147
|
-
segments:
|
148
|
-
- 0
|
149
|
-
hash: -360078987337318543
|
178
|
+
version: 1.3.1
|
150
179
|
requirements: []
|
151
180
|
rubyforge_project:
|
152
|
-
rubygems_version: 1.8.
|
181
|
+
rubygems_version: 1.8.23
|
153
182
|
signing_key:
|
154
183
|
specification_version: 3
|
155
184
|
summary: It's a small library to provide the Rails I18n translations on the Javascript.
|
156
185
|
test_files:
|
157
|
-
- spec/
|
158
|
-
- spec/
|
159
|
-
- spec/
|
160
|
-
- spec/
|
161
|
-
- spec/
|
162
|
-
- spec/
|
163
|
-
- spec/
|
164
|
-
- spec/
|
165
|
-
- spec/
|
166
|
-
- spec/
|
167
|
-
- spec/
|
186
|
+
- spec/fixtures/custom_path.yml
|
187
|
+
- spec/fixtures/default.yml
|
188
|
+
- spec/fixtures/js_file_per_locale.yml
|
189
|
+
- spec/fixtures/locales.yml
|
190
|
+
- spec/fixtures/multiple_conditions.yml
|
191
|
+
- spec/fixtures/multiple_files.yml
|
192
|
+
- spec/fixtures/no_config.yml
|
193
|
+
- spec/fixtures/no_scope.yml
|
194
|
+
- spec/fixtures/simple_scope.yml
|
195
|
+
- spec/i18n_js_spec.rb
|
196
|
+
- spec/js/currency.spec.js
|
197
|
+
- spec/js/current_locale.spec.js
|
198
|
+
- spec/js/dates.spec.js
|
199
|
+
- spec/js/defaults.spec.js
|
200
|
+
- spec/js/interpolation.spec.js
|
201
|
+
- spec/js/jasmine/MIT.LICENSE
|
202
|
+
- spec/js/jasmine/jasmine-html.js
|
203
|
+
- spec/js/jasmine/jasmine.css
|
204
|
+
- spec/js/jasmine/jasmine.js
|
205
|
+
- spec/js/jasmine/jasmine_favicon.png
|
206
|
+
- spec/js/localization.spec.js
|
207
|
+
- spec/js/numbers.spec.js
|
208
|
+
- spec/js/placeholder.spec.js
|
209
|
+
- spec/js/pluralization.spec.js
|
210
|
+
- spec/js/prepare_options.spec.js
|
211
|
+
- spec/js/specs.html
|
212
|
+
- spec/js/translate.spec.js
|
213
|
+
- spec/js/translations.js
|
168
214
|
- spec/spec_helper.rb
|