i18n-js 3.2.1 → 4.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +4 -0
- data/.github/FUNDING.yml +3 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +41 -0
- data/.github/ISSUE_TEMPLATE/config.yml +5 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +38 -0
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/ruby-tests.yml +73 -0
- data/.gitignore +13 -7
- data/.rubocop.yml +19 -0
- data/CHANGELOG.md +45 -386
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +79 -0
- data/Gemfile +3 -0
- data/LICENSE.md +20 -0
- data/MIGRATING_FROM_V3_TO_V4.md +191 -0
- data/README.md +439 -791
- data/Rakefile +10 -20
- data/bin/release +81 -0
- data/exe/i18n +5 -0
- data/i18n-js.gemspec +51 -29
- data/lib/guard/i18n-js/templates/Guardfile +10 -0
- data/lib/guard/i18n-js/version.rb +13 -0
- data/lib/guard/i18n-js.rb +95 -0
- data/lib/i18n-js/clean_hash.rb +13 -0
- data/lib/i18n-js/cli/check_command.rb +17 -0
- data/lib/i18n-js/cli/command.rb +79 -0
- data/lib/i18n-js/cli/export_command.rb +95 -0
- data/lib/i18n-js/cli/init_command.rb +52 -0
- data/lib/i18n-js/cli/lint_scripts_command.rb +157 -0
- data/lib/i18n-js/cli/lint_translations_command.rb +155 -0
- data/lib/i18n-js/cli/plugins_command.rb +67 -0
- data/lib/i18n-js/cli/ui.rb +64 -0
- data/lib/i18n-js/cli/version_command.rb +18 -0
- data/lib/i18n-js/cli.rb +66 -0
- data/lib/i18n-js/embed_fallback_translations_plugin.rb +70 -0
- data/lib/i18n-js/export_files_plugin.rb +103 -0
- data/lib/i18n-js/lint.js +150645 -0
- data/lib/i18n-js/lint.ts +196 -0
- data/lib/i18n-js/listen.rb +96 -0
- data/lib/i18n-js/plugin.rb +103 -0
- data/lib/i18n-js/schema.rb +216 -0
- data/lib/i18n-js/sort_hash.rb +12 -0
- data/lib/i18n-js/version.rb +5 -0
- data/lib/i18n-js.rb +107 -1
- data/package.json +5 -20
- metadata +153 -181
- data/.editorconfig +0 -24
- data/.npmignore +0 -27
- data/.travis.yml +0 -36
- data/Appraisals +0 -32
- data/app/assets/javascripts/i18n/filtered.js.erb +0 -23
- data/app/assets/javascripts/i18n/shims.js +0 -208
- data/app/assets/javascripts/i18n/translations.js +0 -3
- data/app/assets/javascripts/i18n.js +0 -1077
- data/gemfiles/i18n_0_6.gemfile +0 -7
- data/gemfiles/i18n_0_7.gemfile +0 -7
- data/gemfiles/i18n_0_8.gemfile +0 -7
- data/gemfiles/i18n_0_9.gemfile +0 -7
- data/gemfiles/i18n_1_0.gemfile +0 -7
- data/gemfiles/i18n_1_1.gemfile +0 -7
- data/gemfiles/i18n_1_2.gemfile +0 -7
- data/gemfiles/i18n_1_3.gemfile +0 -7
- data/gemfiles/i18n_1_4.gemfile +0 -7
- data/gemfiles/i18n_1_5.gemfile +0 -7
- data/lib/i18n/js/dependencies.rb +0 -59
- data/lib/i18n/js/engine.rb +0 -87
- data/lib/i18n/js/fallback_locales.rb +0 -70
- data/lib/i18n/js/formatters/base.rb +0 -23
- data/lib/i18n/js/formatters/js.rb +0 -31
- data/lib/i18n/js/formatters/json.rb +0 -13
- data/lib/i18n/js/middleware.rb +0 -82
- data/lib/i18n/js/private/hash_with_symbol_keys.rb +0 -36
- data/lib/i18n/js/segment.rb +0 -75
- data/lib/i18n/js/utils.rb +0 -65
- data/lib/i18n/js/version.rb +0 -7
- data/lib/i18n/js.rb +0 -259
- data/lib/rails/generators/i18n/js/config/config_generator.rb +0 -19
- data/lib/rails/generators/i18n/js/config/templates/i18n-js.yml +0 -27
- data/lib/tasks/export.rake +0 -8
- data/spec/fixtures/custom_path.yml +0 -5
- data/spec/fixtures/default.yml +0 -5
- data/spec/fixtures/erb.yml +0 -5
- data/spec/fixtures/except_condition.yml +0 -7
- data/spec/fixtures/js_export_dir_custom.yml +0 -7
- data/spec/fixtures/js_export_dir_none.yml +0 -6
- data/spec/fixtures/js_extend_parent.yml +0 -6
- data/spec/fixtures/js_extend_segment.yml +0 -6
- data/spec/fixtures/js_file_per_locale.yml +0 -7
- data/spec/fixtures/js_file_per_locale_with_fallbacks_as_default_locale_symbol.yml +0 -4
- data/spec/fixtures/js_file_per_locale_with_fallbacks_as_hash.yml +0 -6
- data/spec/fixtures/js_file_per_locale_with_fallbacks_as_locale.yml +0 -4
- data/spec/fixtures/js_file_per_locale_with_fallbacks_as_locale_without_fallback_translations.yml +0 -4
- data/spec/fixtures/js_file_per_locale_with_fallbacks_enabled.yml +0 -4
- data/spec/fixtures/js_file_per_locale_without_fallbacks.yml +0 -4
- data/spec/fixtures/js_file_with_namespace_and_pretty_print.yml +0 -7
- data/spec/fixtures/js_sort_translation_keys_false.yml +0 -6
- data/spec/fixtures/js_sort_translation_keys_true.yml +0 -6
- data/spec/fixtures/json_only.yml +0 -18
- data/spec/fixtures/locales.yml +0 -95
- data/spec/fixtures/merge_plurals.yml +0 -6
- data/spec/fixtures/multiple_conditions.yml +0 -7
- data/spec/fixtures/multiple_conditions_per_locale.yml +0 -7
- data/spec/fixtures/multiple_files.yml +0 -7
- data/spec/fixtures/no_config.yml +0 -2
- data/spec/fixtures/no_scope.yml +0 -4
- data/spec/fixtures/simple_scope.yml +0 -5
- data/spec/js/currency.spec.js +0 -62
- data/spec/js/current_locale.spec.js +0 -19
- data/spec/js/dates.spec.js +0 -265
- data/spec/js/defaults.spec.js +0 -31
- data/spec/js/extend.spec.js +0 -110
- data/spec/js/interpolation.spec.js +0 -124
- data/spec/js/jasmine/MIT.LICENSE +0 -20
- data/spec/js/jasmine/jasmine-html.js +0 -190
- data/spec/js/jasmine/jasmine.css +0 -166
- data/spec/js/jasmine/jasmine.js +0 -2476
- data/spec/js/jasmine/jasmine_favicon.png +0 -0
- data/spec/js/locales.spec.js +0 -31
- data/spec/js/localization.spec.js +0 -48
- data/spec/js/numbers.spec.js +0 -170
- data/spec/js/placeholder.spec.js +0 -24
- data/spec/js/pluralization.spec.js +0 -211
- data/spec/js/prepare_options.spec.js +0 -41
- data/spec/js/require.js +0 -2083
- data/spec/js/specs.html +0 -49
- data/spec/js/specs_requirejs.html +0 -72
- data/spec/js/translate.spec.js +0 -284
- data/spec/js/translations.js +0 -163
- data/spec/js/utility_functions.spec.js +0 -20
- data/spec/ruby/i18n/js/fallback_locales_spec.rb +0 -84
- data/spec/ruby/i18n/js/segment_spec.rb +0 -219
- data/spec/ruby/i18n/js/utils_spec.rb +0 -106
- data/spec/ruby/i18n/js_spec.rb +0 -663
- data/spec/spec_helper.rb +0 -79
- data/yarn.lock +0 -131
@@ -1,19 +0,0 @@
|
|
1
|
-
var I18n = require("../../app/assets/javascripts/i18n");
|
2
|
-
|
3
|
-
describe("Current locale", function(){
|
4
|
-
beforeEach(function(){
|
5
|
-
I18n.reset();
|
6
|
-
});
|
7
|
-
|
8
|
-
it("returns I18n.locale", function(){
|
9
|
-
I18n.locale = "pt-BR";
|
10
|
-
expect(I18n.currentLocale()).toEqual("pt-BR");
|
11
|
-
});
|
12
|
-
|
13
|
-
it("returns I18n.defaultLocale", function(){
|
14
|
-
I18n.locale = null;
|
15
|
-
I18n.defaultLocale = "pt-BR";
|
16
|
-
|
17
|
-
expect(I18n.currentLocale()).toEqual("pt-BR");
|
18
|
-
});
|
19
|
-
});
|
data/spec/js/dates.spec.js
DELETED
@@ -1,265 +0,0 @@
|
|
1
|
-
var I18n = require("../../app/assets/javascripts/i18n")
|
2
|
-
, Translations = require("./translations")
|
3
|
-
;
|
4
|
-
|
5
|
-
describe("Dates", function(){
|
6
|
-
var actual, expected;
|
7
|
-
|
8
|
-
beforeEach(function() {
|
9
|
-
I18n.reset();
|
10
|
-
I18n.translations = Translations();
|
11
|
-
});
|
12
|
-
|
13
|
-
it("parses date", function(){
|
14
|
-
expected = new Date(2009, 0, 24, 0, 0, 0);
|
15
|
-
actual = I18n.parseDate("2009-01-24");
|
16
|
-
expect(actual.toString()).toEqual(expected.toString());
|
17
|
-
|
18
|
-
expected = new Date(2009, 0, 24, 0, 15, 0);
|
19
|
-
actual = I18n.parseDate("2009-01-24 00:15:00");
|
20
|
-
expect(actual.toString()).toEqual(expected.toString());
|
21
|
-
|
22
|
-
expected = new Date(2009, 0, 24, 0, 0, 15);
|
23
|
-
actual = I18n.parseDate("2009-01-24 00:00:15");
|
24
|
-
expect(actual.toString()).toEqual(expected.toString());
|
25
|
-
|
26
|
-
expected = new Date(2009, 0, 24, 15, 33, 44);
|
27
|
-
actual = I18n.parseDate("2009-01-24 15:33:44");
|
28
|
-
expect(actual.toString()).toEqual(expected.toString());
|
29
|
-
|
30
|
-
expected = new Date(2009, 0, 24, 0, 0, 0);
|
31
|
-
actual = I18n.parseDate(expected.getTime());
|
32
|
-
expect(actual.toString()).toEqual(expected.toString());
|
33
|
-
|
34
|
-
expected = new Date(2009, 0, 24, 0, 0, 0);
|
35
|
-
actual = I18n.parseDate("01/24/2009");
|
36
|
-
expect(actual.toString()).toEqual(expected.toString());
|
37
|
-
|
38
|
-
expected = new Date(2009, 0, 24, 14, 33, 55);
|
39
|
-
actual = I18n.parseDate(expected).toString();
|
40
|
-
expect(actual).toEqual(expected.toString());
|
41
|
-
|
42
|
-
expected = new Date(2009, 0, 24, 15, 33, 44);
|
43
|
-
actual = I18n.parseDate("2009-01-24T15:33:44");
|
44
|
-
expect(actual.toString()).toEqual(expected.toString());
|
45
|
-
|
46
|
-
expected = new Date(Date.UTC(2011, 6, 20, 12, 51, 55));
|
47
|
-
actual = I18n.parseDate("2011-07-20T12:51:55+0000");
|
48
|
-
expect(actual.toString()).toEqual(expected.toString());
|
49
|
-
|
50
|
-
expected = new Date(Date.UTC(2011, 6, 20, 12, 51, 55));
|
51
|
-
actual = I18n.parseDate("2011-07-20T12:51:55+00:00");
|
52
|
-
expect(actual.toString()).toEqual(expected.toString());
|
53
|
-
|
54
|
-
expected = new Date(Date.UTC(2011, 6, 20, 13, 03, 39));
|
55
|
-
actual = I18n.parseDate("Wed Jul 20 13:03:39 +0000 2011");
|
56
|
-
expect(actual.toString()).toEqual(expected.toString());
|
57
|
-
|
58
|
-
expected = new Date(Date.UTC(2009, 0, 24, 15, 33, 44));
|
59
|
-
actual = I18n.parseDate("2009-01-24T15:33:44Z");
|
60
|
-
expect(actual.toString()).toEqual(expected.toString());
|
61
|
-
|
62
|
-
expected = new Date(Date.UTC(2009, 0, 24, 15, 34, 44, 200));
|
63
|
-
actual = I18n.parseDate("2009-01-24T15:34:44.200Z");
|
64
|
-
expect(actual.toString()).toEqual(expected.toString());
|
65
|
-
expect(actual.getMilliseconds()).toEqual(expected.getMilliseconds())
|
66
|
-
|
67
|
-
expected = new Date(Date.UTC(2009, 0, 24, 15, 34, 45, 200));
|
68
|
-
actual = I18n.parseDate("2009-01-24T15:34:45.200+0000");
|
69
|
-
expect(actual.toString()).toEqual(expected.toString());
|
70
|
-
expect(actual.getMilliseconds()).toEqual(expected.getMilliseconds())
|
71
|
-
|
72
|
-
expected = new Date(Date.UTC(2009, 0, 24, 15, 34, 46, 200));
|
73
|
-
actual = I18n.parseDate("2009-01-24T15:34:46.200+00:00");
|
74
|
-
expect(actual.toString()).toEqual(expected.toString());
|
75
|
-
expect(actual.getMilliseconds()).toEqual(expected.getMilliseconds())
|
76
|
-
});
|
77
|
-
|
78
|
-
it("formats date", function(){
|
79
|
-
I18n.locale = "pt-BR";
|
80
|
-
|
81
|
-
// 2009-04-26 19:35:44 (Sunday)
|
82
|
-
var date = new Date(2009, 3, 26, 19, 35, 44);
|
83
|
-
|
84
|
-
// short week day
|
85
|
-
expect(I18n.strftime(date, "%a")).toEqual("Dom");
|
86
|
-
|
87
|
-
// full week day
|
88
|
-
expect(I18n.strftime(date, "%A")).toEqual("Domingo");
|
89
|
-
|
90
|
-
// short month
|
91
|
-
expect(I18n.strftime(date, "%b")).toEqual("Abr");
|
92
|
-
|
93
|
-
// full month
|
94
|
-
expect(I18n.strftime(date, "%B")).toEqual("Abril");
|
95
|
-
|
96
|
-
// day
|
97
|
-
expect(I18n.strftime(date, "%d")).toEqual("26");
|
98
|
-
|
99
|
-
// 24-hour
|
100
|
-
expect(I18n.strftime(date, "%H")).toEqual("19");
|
101
|
-
|
102
|
-
// 12-hour
|
103
|
-
expect(I18n.strftime(date, "%I")).toEqual("07");
|
104
|
-
|
105
|
-
// month
|
106
|
-
expect(I18n.strftime(date, "%m")).toEqual("04");
|
107
|
-
|
108
|
-
// minutes
|
109
|
-
expect(I18n.strftime(date, "%M")).toEqual("35");
|
110
|
-
|
111
|
-
// meridian
|
112
|
-
expect(I18n.strftime(date, "%p")).toEqual("PM");
|
113
|
-
|
114
|
-
// seconds
|
115
|
-
expect(I18n.strftime(date, "%S")).toEqual("44");
|
116
|
-
|
117
|
-
// week day
|
118
|
-
expect(I18n.strftime(date, "%w")).toEqual("0");
|
119
|
-
|
120
|
-
// short year
|
121
|
-
expect(I18n.strftime(date, "%y")).toEqual("09");
|
122
|
-
|
123
|
-
// full year
|
124
|
-
expect(I18n.strftime(date, "%Y")).toEqual("2009");
|
125
|
-
});
|
126
|
-
|
127
|
-
it("formats date without padding", function(){
|
128
|
-
I18n.locale = "pt-BR";
|
129
|
-
|
130
|
-
// 2009-04-26 19:35:44 (Sunday)
|
131
|
-
var date = new Date(2009, 3, 9, 7, 8, 9);
|
132
|
-
|
133
|
-
// 24-hour without padding
|
134
|
-
expect(I18n.strftime(date, "%-H")).toEqual("7");
|
135
|
-
|
136
|
-
// 12-hour without padding
|
137
|
-
expect(I18n.strftime(date, "%-I")).toEqual("7");
|
138
|
-
|
139
|
-
// minutes without padding
|
140
|
-
expect(I18n.strftime(date, "%-M")).toEqual("8");
|
141
|
-
|
142
|
-
// seconds without padding
|
143
|
-
expect(I18n.strftime(date, "%-S")).toEqual("9");
|
144
|
-
|
145
|
-
// short year without padding
|
146
|
-
expect(I18n.strftime(date, "%-y")).toEqual("9");
|
147
|
-
|
148
|
-
// month without padding
|
149
|
-
expect(I18n.strftime(date, "%-m")).toEqual("4");
|
150
|
-
|
151
|
-
// day without padding
|
152
|
-
expect(I18n.strftime(date, "%-d")).toEqual("9");
|
153
|
-
expect(I18n.strftime(date, "%e")).toEqual("9");
|
154
|
-
});
|
155
|
-
|
156
|
-
it("formats date with padding", function(){
|
157
|
-
I18n.locale = "pt-BR";
|
158
|
-
|
159
|
-
// 2009-04-26 19:35:44 (Sunday)
|
160
|
-
var date = new Date(2009, 3, 9, 7, 8, 9);
|
161
|
-
|
162
|
-
// 24-hour
|
163
|
-
expect(I18n.strftime(date, "%H")).toEqual("07");
|
164
|
-
|
165
|
-
// 12-hour
|
166
|
-
expect(I18n.strftime(date, "%I")).toEqual("07");
|
167
|
-
|
168
|
-
// minutes
|
169
|
-
expect(I18n.strftime(date, "%M")).toEqual("08");
|
170
|
-
|
171
|
-
// seconds
|
172
|
-
expect(I18n.strftime(date, "%S")).toEqual("09");
|
173
|
-
|
174
|
-
// short year
|
175
|
-
expect(I18n.strftime(date, "%y")).toEqual("09");
|
176
|
-
|
177
|
-
// month
|
178
|
-
expect(I18n.strftime(date, "%m")).toEqual("04");
|
179
|
-
|
180
|
-
// day
|
181
|
-
expect(I18n.strftime(date, "%d")).toEqual("09");
|
182
|
-
});
|
183
|
-
|
184
|
-
it("formats date with negative time zone", function(){
|
185
|
-
I18n.locale = "pt-BR";
|
186
|
-
var date = new Date(2009, 3, 26, 19, 35, 44);
|
187
|
-
|
188
|
-
spyOn(date, "getTimezoneOffset").andReturn(345);
|
189
|
-
|
190
|
-
expect(I18n.strftime(date, "%z")).toMatch(/^(\+|-)[\d]{4}$/);
|
191
|
-
expect(I18n.strftime(date, "%z")).toEqual("-0545");
|
192
|
-
});
|
193
|
-
|
194
|
-
it("formats date with positive time zone", function(){
|
195
|
-
I18n.locale = "pt-BR";
|
196
|
-
var date = new Date(2009, 3, 26, 19, 35, 44);
|
197
|
-
|
198
|
-
spyOn(date, "getTimezoneOffset").andReturn(-345);
|
199
|
-
|
200
|
-
expect(I18n.strftime(date, "%z")).toMatch(/^(\+|-)[\d]{4}$/);
|
201
|
-
expect(I18n.strftime(date, "%z")).toEqual("+0545");
|
202
|
-
});
|
203
|
-
|
204
|
-
it("formats date with custom meridian", function(){
|
205
|
-
I18n.locale = "en-US";
|
206
|
-
var date = new Date(2009, 3, 26, 19, 35, 44);
|
207
|
-
expect(I18n.strftime(date, "%p")).toEqual("pm");
|
208
|
-
});
|
209
|
-
|
210
|
-
it("formats date with meridian boundaries", function(){
|
211
|
-
I18n.locale = "en-US";
|
212
|
-
var date = new Date(2009, 3, 26, 0, 35, 44);
|
213
|
-
expect(I18n.strftime(date, "%p")).toEqual("am");
|
214
|
-
|
215
|
-
date = new Date(2009, 3, 26, 12, 35, 44);
|
216
|
-
expect(I18n.strftime(date, "%p")).toEqual("pm");
|
217
|
-
});
|
218
|
-
|
219
|
-
it("formats date using 12-hours format", function(){
|
220
|
-
I18n.locale = "pt-BR";
|
221
|
-
var date = new Date(2009, 3, 26, 19, 35, 44);
|
222
|
-
expect(I18n.strftime(date, "%I")).toEqual("07");
|
223
|
-
|
224
|
-
date = new Date(2009, 3, 26, 12, 35, 44);
|
225
|
-
expect(I18n.strftime(date, "%I")).toEqual("12");
|
226
|
-
|
227
|
-
date = new Date(2009, 3, 26, 0, 35, 44);
|
228
|
-
expect(I18n.strftime(date, "%I")).toEqual("12");
|
229
|
-
});
|
230
|
-
|
231
|
-
it("defaults to English", function() {
|
232
|
-
I18n.locale = "wk";
|
233
|
-
|
234
|
-
var date = new Date(2009, 3, 26, 19, 35, 44);
|
235
|
-
expect(I18n.strftime(date, "%a")).toEqual("Sun");
|
236
|
-
});
|
237
|
-
|
238
|
-
it("applies locale fallback", function(){
|
239
|
-
I18n.defaultLocale = "en-US";
|
240
|
-
I18n.locale = "de";
|
241
|
-
|
242
|
-
var date = new Date(2009, 3, 26, 19, 35, 44);
|
243
|
-
expect(I18n.strftime(date, "%A")).toEqual("Sonntag");
|
244
|
-
|
245
|
-
date = new Date(2009, 3, 26, 19, 35, 44);
|
246
|
-
expect(I18n.strftime(date, "%a")).toEqual("Sun");
|
247
|
-
});
|
248
|
-
|
249
|
-
it("uses time as the meridian scope", function(){
|
250
|
-
I18n.locale = "de";
|
251
|
-
|
252
|
-
var date = new Date(2009, 3, 26, 19, 35, 44);
|
253
|
-
expect(I18n.strftime(date, "%p")).toEqual("de:PM");
|
254
|
-
|
255
|
-
date = new Date(2009, 3, 26, 7, 35, 44);
|
256
|
-
expect(I18n.strftime(date, "%p")).toEqual("de:AM");
|
257
|
-
});
|
258
|
-
|
259
|
-
it("fails to format invalid date", function(){
|
260
|
-
var date = new Date('foo');
|
261
|
-
expect(function() {
|
262
|
-
I18n.strftime(date, "%a");
|
263
|
-
}).toThrow('I18n.strftime() requires a valid date object, but received an invalid date.');
|
264
|
-
});
|
265
|
-
});
|
data/spec/js/defaults.spec.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
var I18n = require("../../app/assets/javascripts/i18n");
|
2
|
-
|
3
|
-
describe("Defaults", function(){
|
4
|
-
beforeEach(function(){
|
5
|
-
I18n.reset();
|
6
|
-
});
|
7
|
-
|
8
|
-
it("sets the default locale", function(){
|
9
|
-
expect(I18n.defaultLocale).toEqual("en");
|
10
|
-
});
|
11
|
-
|
12
|
-
it("sets current locale", function(){
|
13
|
-
expect(I18n.locale).toEqual("en");
|
14
|
-
});
|
15
|
-
|
16
|
-
it("sets default separator", function(){
|
17
|
-
expect(I18n.defaultSeparator).toEqual(".");
|
18
|
-
});
|
19
|
-
|
20
|
-
it("sets fallback", function(){
|
21
|
-
expect(I18n.fallbacks).toEqual(false);
|
22
|
-
});
|
23
|
-
|
24
|
-
it("set empty translation prefix", function(){
|
25
|
-
expect(I18n.missingTranslationPrefix).toEqual('');
|
26
|
-
});
|
27
|
-
|
28
|
-
it("sets default missingBehaviour", function(){
|
29
|
-
expect(I18n.missingBehaviour).toEqual('message');
|
30
|
-
});
|
31
|
-
});
|
data/spec/js/extend.spec.js
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
var I18n = require("../../app/assets/javascripts/i18n")
|
2
|
-
, Translations = require("./translations")
|
3
|
-
;
|
4
|
-
|
5
|
-
describe("Extend", function () {
|
6
|
-
it("should return an object", function () {
|
7
|
-
expect(typeof I18n.extend()).toBe('object');
|
8
|
-
});
|
9
|
-
|
10
|
-
it("should merge 2 objects into 1", function () {
|
11
|
-
var obj1 = {
|
12
|
-
test1: "abc"
|
13
|
-
}
|
14
|
-
, obj2 = {
|
15
|
-
test2: "xyz"
|
16
|
-
}
|
17
|
-
, expected = {
|
18
|
-
test1: "abc"
|
19
|
-
, test2: "xyz"
|
20
|
-
};
|
21
|
-
|
22
|
-
expect(I18n.extend(obj1,obj2)).toEqual(expected);
|
23
|
-
});
|
24
|
-
it("should overwrite a property from obj1 with the same property of obj2", function () {
|
25
|
-
var obj1 = {
|
26
|
-
test1: "abc"
|
27
|
-
, test3: "def"
|
28
|
-
}
|
29
|
-
, obj2 = {
|
30
|
-
test2: "xyz"
|
31
|
-
, test3: "uvw"
|
32
|
-
}
|
33
|
-
, expected = {
|
34
|
-
test1: "abc"
|
35
|
-
, test2: "xyz"
|
36
|
-
, test3: "uvw"
|
37
|
-
};
|
38
|
-
|
39
|
-
expect(I18n.extend(obj1,obj2)).toEqual(expected);
|
40
|
-
});
|
41
|
-
|
42
|
-
it("should merge deeply from obj1 with the same key of obj2", function() {
|
43
|
-
var obj1 = {
|
44
|
-
test1: {
|
45
|
-
test2: "abc"
|
46
|
-
}
|
47
|
-
}
|
48
|
-
, obj2 = {
|
49
|
-
test1: {
|
50
|
-
test3: "xyz"
|
51
|
-
}
|
52
|
-
}
|
53
|
-
, expected = {
|
54
|
-
test1: {
|
55
|
-
test2: "abc"
|
56
|
-
, test3: "xyz"
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
expect(I18n.extend(obj1, obj2)).toEqual(expected);
|
61
|
-
});
|
62
|
-
|
63
|
-
it("should correctly merge string, numberic, boolean, and null values", function() {
|
64
|
-
var obj1 = {
|
65
|
-
test1: {
|
66
|
-
test2: false
|
67
|
-
}
|
68
|
-
}
|
69
|
-
, obj2 = {
|
70
|
-
test1: {
|
71
|
-
test3: 23,
|
72
|
-
test4: 'abc',
|
73
|
-
test5: null
|
74
|
-
}
|
75
|
-
}
|
76
|
-
, expected = {
|
77
|
-
test1: {
|
78
|
-
test2: false
|
79
|
-
, test3: 23
|
80
|
-
, test4: 'abc'
|
81
|
-
, test5: null
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
expect(I18n.extend(obj1, obj2)).toEqual(expected);
|
86
|
-
});
|
87
|
-
|
88
|
-
it("should merge array values", function() {
|
89
|
-
var obj1 = {
|
90
|
-
array1: [1, 2]
|
91
|
-
},
|
92
|
-
obj2 = {
|
93
|
-
array2: [1, 2],
|
94
|
-
obj3: {
|
95
|
-
array3: [1, 2],
|
96
|
-
array4: [{obj4: 1}, 2]
|
97
|
-
}
|
98
|
-
},
|
99
|
-
expected = {
|
100
|
-
array1: [1, 2],
|
101
|
-
array2: [1, 2],
|
102
|
-
obj3: {
|
103
|
-
array3: [1, 2],
|
104
|
-
array4: [{obj4: 1}, 2]
|
105
|
-
}
|
106
|
-
}
|
107
|
-
|
108
|
-
expect(JSON.stringify(I18n.extend(obj1, obj2))).toEqual(JSON.stringify(expected));
|
109
|
-
});
|
110
|
-
});
|
@@ -1,124 +0,0 @@
|
|
1
|
-
var I18n = require("../../app/assets/javascripts/i18n")
|
2
|
-
, Translations = require("./translations")
|
3
|
-
;
|
4
|
-
|
5
|
-
describe("Interpolation", function(){
|
6
|
-
var actual, expected;
|
7
|
-
|
8
|
-
beforeEach(function(){
|
9
|
-
I18n.reset();
|
10
|
-
I18n.translations = Translations();
|
11
|
-
});
|
12
|
-
|
13
|
-
it("performs single interpolation", function(){
|
14
|
-
actual = I18n.t("greetings.name", {name: "John Doe"});
|
15
|
-
expect(actual).toEqual("Hello John Doe!");
|
16
|
-
});
|
17
|
-
|
18
|
-
it("performs multiple interpolations", function(){
|
19
|
-
actual = I18n.t("profile.details", {name: "John Doe", age: 27});
|
20
|
-
expect(actual).toEqual("John Doe is 27-years old");
|
21
|
-
});
|
22
|
-
|
23
|
-
describe("Pluralization", function() {
|
24
|
-
var translation_key;
|
25
|
-
|
26
|
-
describe("when count is passed in", function() {
|
27
|
-
describe("and translation key does contain pluralization", function() {
|
28
|
-
beforeEach(function() {
|
29
|
-
translation_key = "inbox";
|
30
|
-
});
|
31
|
-
|
32
|
-
it("return translated and pluralized string", function() {
|
33
|
-
expect(I18n.t(translation_key, {count: 0})).toEqual("You have no messages");
|
34
|
-
expect(I18n.t(translation_key, {count: 1})).toEqual("You have 1 message");
|
35
|
-
expect(I18n.t(translation_key, {count: 5})).toEqual("You have 5 messages");
|
36
|
-
});
|
37
|
-
});
|
38
|
-
describe("and translation key does NOT contain pluralization", function() {
|
39
|
-
beforeEach(function() {
|
40
|
-
translation_key = "hello";
|
41
|
-
});
|
42
|
-
|
43
|
-
it("return translated string ONLY", function() {
|
44
|
-
expect(I18n.t(translation_key, {count: 0})).toEqual("Hello World!");
|
45
|
-
expect(I18n.t(translation_key, {count: 1})).toEqual("Hello World!");
|
46
|
-
expect(I18n.t(translation_key, {count: 5})).toEqual("Hello World!");
|
47
|
-
});
|
48
|
-
});
|
49
|
-
describe("and translation key does contain pluralization with null content", function() {
|
50
|
-
beforeEach(function() {
|
51
|
-
translation_key = "sent";
|
52
|
-
});
|
53
|
-
|
54
|
-
it("return empty string", function() {
|
55
|
-
expect(I18n.t(translation_key, {count: 0})).toEqual('[missing "en.sent.zero" translation]');
|
56
|
-
expect(I18n.t(translation_key, {count: 1})).toEqual('[missing "en.sent.one" translation]');
|
57
|
-
expect(I18n.t(translation_key, {count: 5})).toEqual('[missing "en.sent.other" translation]');
|
58
|
-
});
|
59
|
-
});
|
60
|
-
});
|
61
|
-
|
62
|
-
describe("when count is NOT passed in", function() {
|
63
|
-
describe("and translation key does contain pluralization", function() {
|
64
|
-
beforeEach(function() {
|
65
|
-
translation_key = "inbox";
|
66
|
-
});
|
67
|
-
|
68
|
-
var expected_translation_object = {
|
69
|
-
one : 'You have {{count}} message',
|
70
|
-
other : 'You have {{count}} messages',
|
71
|
-
zero : 'You have no messages'
|
72
|
-
}
|
73
|
-
|
74
|
-
it("return translated and pluralized string", function() {
|
75
|
-
expect(I18n.t(translation_key, {not_count: 0})).toEqual(expected_translation_object);
|
76
|
-
expect(I18n.t(translation_key, {not_count: 1})).toEqual(expected_translation_object);
|
77
|
-
expect(I18n.t(translation_key, {not_count: 5})).toEqual(expected_translation_object);
|
78
|
-
});
|
79
|
-
});
|
80
|
-
describe("and translation key does NOT contain pluralization", function() {
|
81
|
-
beforeEach(function() {
|
82
|
-
translation_key = "hello";
|
83
|
-
});
|
84
|
-
|
85
|
-
it("return translated string ONLY", function() {
|
86
|
-
expect(I18n.t(translation_key, {not_count: 0})).toEqual("Hello World!");
|
87
|
-
expect(I18n.t(translation_key, {not_count: 1})).toEqual("Hello World!");
|
88
|
-
expect(I18n.t(translation_key, {not_count: 5})).toEqual("Hello World!");
|
89
|
-
});
|
90
|
-
});
|
91
|
-
});
|
92
|
-
});
|
93
|
-
|
94
|
-
it("outputs missing placeholder message if interpolation value is missing", function(){
|
95
|
-
actual = I18n.t("greetings.name");
|
96
|
-
expect(actual).toEqual("Hello [missing {{name}} value]!");
|
97
|
-
});
|
98
|
-
|
99
|
-
it("outputs missing placeholder message if interpolation value is null", function(){
|
100
|
-
actual = I18n.t("greetings.name", {name: null});
|
101
|
-
expect(actual).toEqual("Hello [missing {{name}} value]!");
|
102
|
-
});
|
103
|
-
|
104
|
-
it("allows overriding the null placeholder message", function(){
|
105
|
-
var orig = I18n.nullPlaceholder;
|
106
|
-
I18n.nullPlaceholder = function() {return "";}
|
107
|
-
actual = I18n.t("greetings.name", {name: null});
|
108
|
-
expect(actual).toEqual("Hello !");
|
109
|
-
I18n.nullPlaceholder = orig;
|
110
|
-
});
|
111
|
-
|
112
|
-
it("provides missingPlaceholder with the placeholder, message, and options object", function(){
|
113
|
-
var orig = I18n.missingPlaceholder;
|
114
|
-
I18n.missingPlaceholder = function(placeholder, message, options) {
|
115
|
-
expect(placeholder).toEqual('{{name}}');
|
116
|
-
expect(message).toEqual('Hello {{name}}!');
|
117
|
-
expect(options.debugScope).toEqual('landing-page');
|
118
|
-
return '[missing-placeholder-debug]';
|
119
|
-
};
|
120
|
-
actual = I18n.t("greetings.name", {debugScope: 'landing-page'});
|
121
|
-
expect(actual).toEqual("Hello [missing-placeholder-debug]!");
|
122
|
-
I18n.missingPlaceholder = orig;
|
123
|
-
});
|
124
|
-
});
|
data/spec/js/jasmine/MIT.LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2008-2011 Pivotal Labs
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|