i18n-js 2.1.2 → 3.9.2
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.
- checksums.yaml +7 -0
- data/.editorconfig +24 -0
- data/.github/FUNDING.yml +3 -0
- data/.github/workflows/tests.yaml +106 -0
- data/.gitignore +6 -4
- data/.npmignore +27 -0
- data/Appraisals +52 -0
- data/CHANGELOG.md +575 -0
- data/Gemfile +1 -1
- data/README.md +1099 -0
- data/Rakefile +19 -7
- data/app/assets/javascripts/i18n/filtered.js.erb +23 -0
- data/app/assets/javascripts/i18n/shims.js +240 -0
- data/app/assets/javascripts/i18n/translations.js +3 -0
- data/app/assets/javascripts/i18n.js +1095 -0
- data/gemfiles/i18n_0_6.gemfile +7 -0
- data/gemfiles/i18n_0_7.gemfile +7 -0
- data/gemfiles/i18n_0_8.gemfile +7 -0
- data/gemfiles/i18n_0_9.gemfile +7 -0
- data/gemfiles/i18n_1_0.gemfile +7 -0
- data/gemfiles/i18n_1_1.gemfile +7 -0
- data/gemfiles/i18n_1_10.gemfile +7 -0
- data/gemfiles/i18n_1_2.gemfile +7 -0
- data/gemfiles/i18n_1_3.gemfile +7 -0
- data/gemfiles/i18n_1_4.gemfile +7 -0
- data/gemfiles/i18n_1_5.gemfile +7 -0
- data/gemfiles/i18n_1_6.gemfile +7 -0
- data/gemfiles/i18n_1_7.gemfile +7 -0
- data/gemfiles/i18n_1_8.gemfile +7 -0
- data/gemfiles/i18n_1_9.gemfile +7 -0
- data/i18n-js.gemspec +13 -10
- data/i18njs.png +0 -0
- data/lib/i18n/js/dependencies.rb +67 -0
- data/lib/i18n/js/engine.rb +87 -0
- data/lib/i18n/js/fallback_locales.rb +70 -0
- data/lib/i18n/js/formatters/base.rb +25 -0
- data/lib/i18n/js/formatters/js.rb +39 -0
- data/lib/i18n/js/formatters/json.rb +13 -0
- data/lib/{i18n-js → i18n/js}/middleware.rb +32 -9
- data/lib/i18n/js/private/config_store.rb +31 -0
- data/lib/i18n/js/private/hash_with_symbol_keys.rb +36 -0
- data/lib/i18n/js/segment.rb +81 -0
- data/lib/i18n/js/utils.rb +91 -0
- data/lib/i18n/js/version.rb +7 -0
- data/lib/i18n/js.rb +274 -0
- data/lib/i18n-js.rb +1 -177
- data/lib/rails/generators/i18n/js/config/config_generator.rb +19 -0
- data/{config → lib/rails/generators/i18n/js/config/templates}/i18n-js.yml +11 -6
- data/lib/tasks/export.rake +8 -0
- data/package.json +25 -0
- data/spec/fixtures/custom_path.yml +5 -0
- data/spec/fixtures/default.yml +5 -0
- data/spec/fixtures/erb.yml +5 -0
- data/spec/fixtures/except_condition.yml +7 -0
- data/spec/fixtures/js_available_locales_custom.yml +1 -0
- data/spec/fixtures/js_export_dir_custom.yml +7 -0
- data/spec/fixtures/js_export_dir_none.yml +6 -0
- data/spec/fixtures/js_extend_parent.yml +6 -0
- data/spec/fixtures/js_extend_segment.yml +6 -0
- data/spec/fixtures/js_file_per_locale.yml +7 -0
- data/spec/fixtures/js_file_per_locale_with_fallbacks_as_default_locale_symbol.yml +4 -0
- data/spec/fixtures/js_file_per_locale_with_fallbacks_as_hash.yml +6 -0
- data/spec/fixtures/js_file_per_locale_with_fallbacks_as_locale.yml +4 -0
- data/spec/fixtures/js_file_per_locale_with_fallbacks_as_locale_without_fallback_translations.yml +4 -0
- data/spec/fixtures/js_file_per_locale_with_fallbacks_enabled.yml +4 -0
- data/spec/fixtures/js_file_per_locale_without_fallbacks.yml +4 -0
- data/spec/fixtures/js_file_with_namespace_prefix_and_pretty_print.yml +9 -0
- data/spec/fixtures/js_sort_translation_keys_false.yml +6 -0
- data/spec/fixtures/js_sort_translation_keys_true.yml +6 -0
- data/spec/fixtures/json_only.yml +18 -0
- data/spec/{resources → fixtures}/locales.yml +58 -1
- data/spec/fixtures/merge_plurals.yml +6 -0
- data/spec/fixtures/merge_plurals_with_no_overrides.yml +4 -0
- data/spec/fixtures/merge_plurals_with_partial_overrides.yml +4 -0
- data/spec/fixtures/millions.yml +4 -0
- data/spec/fixtures/multiple_conditions.yml +7 -0
- data/spec/fixtures/multiple_conditions_per_locale.yml +7 -0
- data/spec/fixtures/multiple_files.yml +7 -0
- data/spec/{resources → fixtures}/no_config.yml +0 -0
- data/spec/fixtures/no_scope.yml +4 -0
- data/spec/fixtures/simple_scope.yml +5 -0
- data/spec/js/currency.spec.js +62 -0
- data/spec/js/current_locale.spec.js +19 -0
- data/spec/js/dates.spec.js +276 -0
- data/spec/js/defaults.spec.js +31 -0
- data/spec/js/extend.spec.js +110 -0
- data/spec/js/interpolation.spec.js +124 -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/json_parsable.spec.js +14 -0
- data/spec/js/locales.spec.js +31 -0
- data/spec/js/localization.spec.js +78 -0
- data/spec/js/numbers.spec.js +174 -0
- data/spec/js/placeholder.spec.js +24 -0
- data/spec/js/pluralization.spec.js +228 -0
- data/spec/js/prepare_options.spec.js +41 -0
- data/spec/js/require.js +2083 -0
- data/spec/js/specs.html +49 -0
- data/spec/js/specs_requirejs.html +72 -0
- data/spec/js/translate.spec.js +304 -0
- data/spec/js/translations.js +188 -0
- data/spec/js/utility_functions.spec.js +20 -0
- data/spec/ruby/i18n/js/fallback_locales_spec.rb +84 -0
- data/spec/ruby/i18n/js/segment_spec.rb +286 -0
- data/spec/ruby/i18n/js/utils_spec.rb +138 -0
- data/spec/ruby/i18n/js_spec.rb +797 -0
- data/spec/spec_helper.rb +75 -14
- data/yarn.lock +138 -0
- metadata +225 -96
- data/.rspec +0 -1
- data/Gemfile.lock +0 -51
- data/README.rdoc +0 -305
- 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/custom_path.yml +0 -4
- data/spec/resources/default.yml +0 -4
- data/spec/resources/js_file_per_locale.yml +0 -3
- data/spec/resources/multiple_conditions.yml +0 -6
- data/spec/resources/multiple_files.yml +0 -6
- data/spec/resources/no_scope.yml +0 -3
- data/spec/resources/simple_scope.yml +0 -4
- data/vendor/assets/javascripts/i18n/translations.js.erb +0 -7
- data/vendor/assets/javascripts/i18n.js +0 -450
data/package.json
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"name": "i18n-js",
|
3
|
+
"version": "3.9.2",
|
4
|
+
"description": "A javascript library similar to Ruby on Rails i18n gem",
|
5
|
+
"author": "Nando Vieira",
|
6
|
+
"license": "MIT",
|
7
|
+
"keywords": [
|
8
|
+
"i18n"
|
9
|
+
],
|
10
|
+
"devDependencies": {
|
11
|
+
"jasmine-node": "^3.0.0"
|
12
|
+
},
|
13
|
+
"main": "app/assets/javascripts/i18n.js",
|
14
|
+
"scripts": {
|
15
|
+
"test": "./node_modules/.bin/jasmine-node spec/js"
|
16
|
+
},
|
17
|
+
"homepage": "https://github.com/fnando/i18n-js",
|
18
|
+
"bugs": {
|
19
|
+
"url": "https://github.com/fnando/i18n-js/issues"
|
20
|
+
},
|
21
|
+
"repository": {
|
22
|
+
"type": "git",
|
23
|
+
"url": "https://github.com/fnando/i18n-js.git"
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
js_available_locales: ["en", "foo"]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
fallbacks: false
|
2
|
+
json_only: true
|
3
|
+
|
4
|
+
translations:
|
5
|
+
- file: "tmp/i18n-js/json_only.%{locale}.js"
|
6
|
+
only:
|
7
|
+
- "*.date.formats.*"
|
8
|
+
- "*.number.currency.*"
|
9
|
+
|
10
|
+
- file: "tmp/i18n-js/json_only_multi.js"
|
11
|
+
only:
|
12
|
+
- "*.date.formats.*"
|
13
|
+
- "*.number.currency.*"
|
14
|
+
|
15
|
+
- file: "tmp/i18n-js/json_only_multi_pretty.js"
|
16
|
+
only:
|
17
|
+
- "*.date.formats.*"
|
18
|
+
- "*.number.currency.*"
|
@@ -1,5 +1,9 @@
|
|
1
1
|
en:
|
2
2
|
number:
|
3
|
+
human:
|
4
|
+
decimal_units:
|
5
|
+
units:
|
6
|
+
million: Million
|
3
7
|
format:
|
4
8
|
separator: "."
|
5
9
|
delimiter: ","
|
@@ -34,6 +38,39 @@ en:
|
|
34
38
|
note: "more details"
|
35
39
|
edit:
|
36
40
|
title: "Edit"
|
41
|
+
foo: "Foo"
|
42
|
+
fallback_test: "Success"
|
43
|
+
null_test: "fallback for null"
|
44
|
+
merge_plurals:
|
45
|
+
one: Apple
|
46
|
+
other: Apples
|
47
|
+
merge_plurals_with_no_overrides:
|
48
|
+
zero: "No Apple"
|
49
|
+
one: Apple
|
50
|
+
other: Apples
|
51
|
+
merge_plurals_with_partial_overrides:
|
52
|
+
one: Cat
|
53
|
+
other: Cats
|
54
|
+
|
55
|
+
es:
|
56
|
+
number:
|
57
|
+
human:
|
58
|
+
decimal_units:
|
59
|
+
units:
|
60
|
+
million:
|
61
|
+
one: millón
|
62
|
+
other: millones
|
63
|
+
|
64
|
+
ru:
|
65
|
+
merge_plurals_with_no_overrides:
|
66
|
+
one: кот
|
67
|
+
few: кошек
|
68
|
+
many: кошка
|
69
|
+
other: кошек
|
70
|
+
|
71
|
+
de:
|
72
|
+
fallback_test: "Erfolg"
|
73
|
+
null_test: ~
|
37
74
|
|
38
75
|
fr:
|
39
76
|
date:
|
@@ -73,4 +110,24 @@ fr:
|
|
73
110
|
title: "Visualiser"
|
74
111
|
note: "plus de détails"
|
75
112
|
edit:
|
76
|
-
title: "Editer"
|
113
|
+
title: "Editer"
|
114
|
+
merge_plurals:
|
115
|
+
zero: Pomme
|
116
|
+
one: Pomme
|
117
|
+
other: Pommes
|
118
|
+
|
119
|
+
en-US:
|
120
|
+
merge_plurals_with_no_overrides:
|
121
|
+
zero:
|
122
|
+
one:
|
123
|
+
other:
|
124
|
+
merge_plurals_with_partial_overrides:
|
125
|
+
one: Cat
|
126
|
+
few:
|
127
|
+
many:
|
128
|
+
other:
|
129
|
+
|
130
|
+
ja:
|
131
|
+
admin:
|
132
|
+
show:
|
133
|
+
title: "Ignore me"
|
File without changes
|
@@ -0,0 +1,62 @@
|
|
1
|
+
var I18n = require("../../app/assets/javascripts/i18n")
|
2
|
+
, Translations = require("./translations")
|
3
|
+
;
|
4
|
+
|
5
|
+
describe("Currency", function(){
|
6
|
+
var actual, expected;
|
7
|
+
|
8
|
+
beforeEach(function() {
|
9
|
+
I18n.reset();
|
10
|
+
I18n.translations = Translations();
|
11
|
+
});
|
12
|
+
|
13
|
+
it("formats currency with default settings", function(){
|
14
|
+
expect(I18n.toCurrency(100.99)).toEqual("$100.99");
|
15
|
+
expect(I18n.toCurrency(1000.99)).toEqual("$1,000.99");
|
16
|
+
expect(I18n.toCurrency(-1000)).toEqual("-$1,000.00");
|
17
|
+
});
|
18
|
+
|
19
|
+
it("formats currency with custom settings", function(){
|
20
|
+
I18n.translations.en.number = {
|
21
|
+
currency: {
|
22
|
+
format: {
|
23
|
+
format: "%n %u",
|
24
|
+
unit: "USD",
|
25
|
+
delimiter: ".",
|
26
|
+
separator: ",",
|
27
|
+
precision: 2
|
28
|
+
}
|
29
|
+
}
|
30
|
+
};
|
31
|
+
|
32
|
+
expect(I18n.toCurrency(12)).toEqual("12,00 USD");
|
33
|
+
expect(I18n.toCurrency(123)).toEqual("123,00 USD");
|
34
|
+
expect(I18n.toCurrency(1234.56)).toEqual("1.234,56 USD");
|
35
|
+
});
|
36
|
+
|
37
|
+
it("formats currency with custom settings and partial overriding", function(){
|
38
|
+
I18n.translations.en.number = {
|
39
|
+
currency: {
|
40
|
+
format: {
|
41
|
+
format: "%n %u",
|
42
|
+
unit: "USD",
|
43
|
+
delimiter: ".",
|
44
|
+
separator: ",",
|
45
|
+
precision: 2
|
46
|
+
}
|
47
|
+
}
|
48
|
+
};
|
49
|
+
|
50
|
+
expect(I18n.toCurrency(12, {precision: 0})).toEqual("12 USD");
|
51
|
+
expect(I18n.toCurrency(123, {unit: "bucks"})).toEqual("123,00 bucks");
|
52
|
+
});
|
53
|
+
|
54
|
+
it("formats currency with some custom options that should be merged with default options", function(){
|
55
|
+
expect(I18n.toCurrency(1234, {precision: 0})).toEqual("$1,234");
|
56
|
+
expect(I18n.toCurrency(1234, {unit: "º"})).toEqual("º1,234.00");
|
57
|
+
expect(I18n.toCurrency(1234, {separator: "-"})).toEqual("$1,234-00");
|
58
|
+
expect(I18n.toCurrency(1234, {delimiter: "-"})).toEqual("$1-234.00");
|
59
|
+
expect(I18n.toCurrency(1234, {format: "%u %n"})).toEqual("$ 1,234.00");
|
60
|
+
expect(I18n.toCurrency(-123, {sign_first: false})).toEqual("$-123.00");
|
61
|
+
});
|
62
|
+
});
|
@@ -0,0 +1,19 @@
|
|
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
|
+
});
|