i18n-js 3.8.2 → 4.2.3

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.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +4 -0
  3. data/.github/FUNDING.yml +1 -1
  4. data/.github/ISSUE_TEMPLATE/bug_report.md +41 -0
  5. data/.github/ISSUE_TEMPLATE/config.yml +5 -0
  6. data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
  7. data/.github/PULL_REQUEST_TEMPLATE.md +38 -0
  8. data/.github/dependabot.yml +15 -0
  9. data/.github/workflows/ruby-tests.yml +73 -0
  10. data/.gitignore +13 -7
  11. data/.rubocop.yml +19 -0
  12. data/CHANGELOG.md +47 -512
  13. data/CODE_OF_CONDUCT.md +74 -0
  14. data/CONTRIBUTING.md +79 -0
  15. data/Gemfile +3 -0
  16. data/LICENSE.md +20 -0
  17. data/MIGRATING_FROM_V3_TO_V4.md +192 -0
  18. data/README.md +425 -921
  19. data/Rakefile +10 -20
  20. data/bin/release +81 -0
  21. data/exe/i18n +5 -0
  22. data/i18n-js.gemspec +51 -29
  23. data/lib/guard/i18n-js/templates/Guardfile +10 -0
  24. data/lib/guard/i18n-js/version.rb +13 -0
  25. data/lib/guard/i18n-js.rb +95 -0
  26. data/lib/i18n-js/clean_hash.rb +13 -0
  27. data/lib/i18n-js/cli/check_command.rb +17 -0
  28. data/lib/i18n-js/cli/command.rb +79 -0
  29. data/lib/i18n-js/cli/export_command.rb +95 -0
  30. data/lib/i18n-js/cli/init_command.rb +52 -0
  31. data/lib/i18n-js/cli/lint_scripts_command.rb +159 -0
  32. data/lib/i18n-js/cli/lint_translations_command.rb +157 -0
  33. data/lib/i18n-js/cli/plugins_command.rb +67 -0
  34. data/lib/i18n-js/cli/ui.rb +64 -0
  35. data/lib/i18n-js/cli/version_command.rb +18 -0
  36. data/lib/i18n-js/cli.rb +66 -0
  37. data/lib/i18n-js/embed_fallback_translations_plugin.rb +70 -0
  38. data/lib/i18n-js/export_files_plugin.rb +103 -0
  39. data/lib/i18n-js/lint.js +150645 -0
  40. data/lib/i18n-js/lint.ts +196 -0
  41. data/lib/i18n-js/listen.rb +96 -0
  42. data/lib/i18n-js/plugin.rb +103 -0
  43. data/lib/i18n-js/schema.rb +216 -0
  44. data/lib/i18n-js/sort_hash.rb +12 -0
  45. data/lib/i18n-js/version.rb +5 -0
  46. data/lib/i18n-js.rb +107 -1
  47. data/package.json +5 -20
  48. metadata +149 -189
  49. data/.editorconfig +0 -24
  50. data/.github/workflows/tests.yaml +0 -100
  51. data/.npmignore +0 -27
  52. data/Appraisals +0 -44
  53. data/app/assets/javascripts/i18n/filtered.js.erb +0 -23
  54. data/app/assets/javascripts/i18n/shims.js +0 -240
  55. data/app/assets/javascripts/i18n/translations.js +0 -3
  56. data/app/assets/javascripts/i18n.js +0 -1095
  57. data/gemfiles/i18n_0_6.gemfile +0 -7
  58. data/gemfiles/i18n_0_7.gemfile +0 -7
  59. data/gemfiles/i18n_0_8.gemfile +0 -7
  60. data/gemfiles/i18n_0_9.gemfile +0 -7
  61. data/gemfiles/i18n_1_0.gemfile +0 -7
  62. data/gemfiles/i18n_1_1.gemfile +0 -7
  63. data/gemfiles/i18n_1_2.gemfile +0 -7
  64. data/gemfiles/i18n_1_3.gemfile +0 -7
  65. data/gemfiles/i18n_1_4.gemfile +0 -7
  66. data/gemfiles/i18n_1_5.gemfile +0 -7
  67. data/gemfiles/i18n_1_6.gemfile +0 -7
  68. data/gemfiles/i18n_1_7.gemfile +0 -7
  69. data/gemfiles/i18n_1_8.gemfile +0 -7
  70. data/i18njs.png +0 -0
  71. data/lib/i18n/js/dependencies.rb +0 -63
  72. data/lib/i18n/js/engine.rb +0 -87
  73. data/lib/i18n/js/fallback_locales.rb +0 -70
  74. data/lib/i18n/js/formatters/base.rb +0 -25
  75. data/lib/i18n/js/formatters/js.rb +0 -32
  76. data/lib/i18n/js/formatters/json.rb +0 -13
  77. data/lib/i18n/js/middleware.rb +0 -82
  78. data/lib/i18n/js/private/config_store.rb +0 -31
  79. data/lib/i18n/js/private/hash_with_symbol_keys.rb +0 -36
  80. data/lib/i18n/js/segment.rb +0 -80
  81. data/lib/i18n/js/utils.rb +0 -78
  82. data/lib/i18n/js/version.rb +0 -7
  83. data/lib/i18n/js.rb +0 -264
  84. data/lib/rails/generators/i18n/js/config/config_generator.rb +0 -19
  85. data/lib/rails/generators/i18n/js/config/templates/i18n-js.yml +0 -27
  86. data/lib/tasks/export.rake +0 -8
  87. data/spec/fixtures/custom_path.yml +0 -5
  88. data/spec/fixtures/default.yml +0 -5
  89. data/spec/fixtures/erb.yml +0 -5
  90. data/spec/fixtures/except_condition.yml +0 -7
  91. data/spec/fixtures/js_export_dir_custom.yml +0 -7
  92. data/spec/fixtures/js_export_dir_none.yml +0 -6
  93. data/spec/fixtures/js_extend_parent.yml +0 -6
  94. data/spec/fixtures/js_extend_segment.yml +0 -6
  95. data/spec/fixtures/js_file_per_locale.yml +0 -7
  96. data/spec/fixtures/js_file_per_locale_with_fallbacks_as_default_locale_symbol.yml +0 -4
  97. data/spec/fixtures/js_file_per_locale_with_fallbacks_as_hash.yml +0 -6
  98. data/spec/fixtures/js_file_per_locale_with_fallbacks_as_locale.yml +0 -4
  99. data/spec/fixtures/js_file_per_locale_with_fallbacks_as_locale_without_fallback_translations.yml +0 -4
  100. data/spec/fixtures/js_file_per_locale_with_fallbacks_enabled.yml +0 -4
  101. data/spec/fixtures/js_file_per_locale_without_fallbacks.yml +0 -4
  102. data/spec/fixtures/js_file_with_namespace_prefix_and_pretty_print.yml +0 -9
  103. data/spec/fixtures/js_sort_translation_keys_false.yml +0 -6
  104. data/spec/fixtures/js_sort_translation_keys_true.yml +0 -6
  105. data/spec/fixtures/json_only.yml +0 -18
  106. data/spec/fixtures/locales.yml +0 -133
  107. data/spec/fixtures/merge_plurals.yml +0 -6
  108. data/spec/fixtures/merge_plurals_with_no_overrides.yml +0 -4
  109. data/spec/fixtures/merge_plurals_with_partial_overrides.yml +0 -4
  110. data/spec/fixtures/millions.yml +0 -4
  111. data/spec/fixtures/multiple_conditions.yml +0 -7
  112. data/spec/fixtures/multiple_conditions_per_locale.yml +0 -7
  113. data/spec/fixtures/multiple_files.yml +0 -7
  114. data/spec/fixtures/no_config.yml +0 -2
  115. data/spec/fixtures/no_scope.yml +0 -4
  116. data/spec/fixtures/simple_scope.yml +0 -5
  117. data/spec/js/currency.spec.js +0 -62
  118. data/spec/js/current_locale.spec.js +0 -19
  119. data/spec/js/dates.spec.js +0 -276
  120. data/spec/js/defaults.spec.js +0 -31
  121. data/spec/js/extend.spec.js +0 -110
  122. data/spec/js/interpolation.spec.js +0 -124
  123. data/spec/js/jasmine/MIT.LICENSE +0 -20
  124. data/spec/js/jasmine/jasmine-html.js +0 -190
  125. data/spec/js/jasmine/jasmine.css +0 -166
  126. data/spec/js/jasmine/jasmine.js +0 -2476
  127. data/spec/js/jasmine/jasmine_favicon.png +0 -0
  128. data/spec/js/locales.spec.js +0 -31
  129. data/spec/js/localization.spec.js +0 -78
  130. data/spec/js/numbers.spec.js +0 -174
  131. data/spec/js/placeholder.spec.js +0 -24
  132. data/spec/js/pluralization.spec.js +0 -219
  133. data/spec/js/prepare_options.spec.js +0 -41
  134. data/spec/js/require.js +0 -2083
  135. data/spec/js/specs.html +0 -49
  136. data/spec/js/specs_requirejs.html +0 -72
  137. data/spec/js/translate.spec.js +0 -304
  138. data/spec/js/translations.js +0 -188
  139. data/spec/js/utility_functions.spec.js +0 -20
  140. data/spec/ruby/i18n/js/fallback_locales_spec.rb +0 -84
  141. data/spec/ruby/i18n/js/segment_spec.rb +0 -219
  142. data/spec/ruby/i18n/js/utils_spec.rb +0 -106
  143. data/spec/ruby/i18n/js_spec.rb +0 -748
  144. data/spec/spec_helper.rb +0 -80
  145. data/yarn.lock +0 -131
@@ -1,133 +0,0 @@
1
- en:
2
- number:
3
- human:
4
- decimal_units:
5
- units:
6
- million: Million
7
- format:
8
- separator: "."
9
- delimiter: ","
10
- precision: 3
11
- currency:
12
- format:
13
- format: "%u%n"
14
- unit: "$"
15
- separator: "."
16
- delimiter: ","
17
- precision: 2
18
- date:
19
- formats:
20
- default: "%Y-%m-%d"
21
- short: "%b %d"
22
- long: "%B %d, %Y"
23
- day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
24
- abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
25
- month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
26
- abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
27
- # order: [ :year, :month, :day ]
28
- time:
29
- formats:
30
- default: "%a, %d %b %Y %H:%M:%S %z"
31
- short: "%d %b %H:%M"
32
- long: "%B %d, %Y %H:%M"
33
- am: "am"
34
- pm: "pm"
35
- admin:
36
- show:
37
- title: "Show"
38
- note: "more details"
39
- edit:
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: ~
74
-
75
- fr:
76
- date:
77
- formats:
78
- default: "%d/%m/%Y"
79
- short: "%e %b"
80
- long: "%e %B %Y"
81
- long_ordinal: "%e %B %Y"
82
- only_day: "%e"
83
- day_names: [dimanche, lundi, mardi, mercredi, jeudi, vendredi, samedi]
84
- abbr_day_names: [dim, lun, mar, mer, jeu, ven, sam]
85
- month_names: [~, janvier, février, mars, avril, mai, juin, juillet, août, septembre, octobre, novembre, décembre]
86
- abbr_month_names: [~, jan., fév., mar., avr., mai, juin, juil., août, sept., oct., nov., déc.]
87
- # order: [ :day, :month, :year ]
88
- time:
89
- formats:
90
- default: "%d %B %Y %H:%M"
91
- time: "%H:%M"
92
- short: "%d %b %H:%M"
93
- long: "%A %d %B %Y %H:%M:%S %Z"
94
- long_ordinal: "%A %d %B %Y %H:%M:%S %Z"
95
- only_second: "%S"
96
- am: 'am'
97
- pm: 'pm'
98
- number:
99
- format:
100
- precision: 3
101
- separator: ','
102
- delimiter: ' '
103
- currency:
104
- format:
105
- unit: '€'
106
- precision: 2
107
- format: '%n %u'
108
- admin:
109
- show:
110
- title: "Visualiser"
111
- note: "plus de détails"
112
- edit:
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"
@@ -1,6 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/merge_plurals.js"
5
- only:
6
- - "*.merge_plurals"
@@ -1,4 +0,0 @@
1
- translations:
2
- - file: "tmp/i18n-js/merge_plurals_with_no_overrides.js"
3
- only:
4
- - "*.merge_plurals_with_no_overrides"
@@ -1,4 +0,0 @@
1
- translations:
2
- - file: "tmp/i18n-js/merge_plurals_with_partial_overrides.js"
3
- only:
4
- - "*.merge_plurals_with_partial_overrides"
@@ -1,4 +0,0 @@
1
- translations:
2
- - file: "tmp/i18n-js/millions.js"
3
- only:
4
- - "*.number.human.decimal_units.units"
@@ -1,7 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/bitsnpieces.js"
5
- only:
6
- - "*.date.formats"
7
- - "*.number.currency"
@@ -1,7 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/bits.%{locale}.js"
5
- only:
6
- - "*.date.formats.*"
7
- - "*.number.currency.*"
@@ -1,7 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/all.js"
5
- only: "*"
6
- - file: "tmp/i18n-js/tudo.js"
7
- only: "*"
@@ -1,2 +0,0 @@
1
- #This file has no config
2
-
@@ -1,4 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/no_scope.js"
@@ -1,5 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/simple_scope.js"
5
- only: "*.date.formats"
@@ -1,62 +0,0 @@
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
- });
@@ -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
- });
@@ -1,276 +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
- expect(I18n.strftime(date, "%k")).toEqual("7");
136
-
137
- // 12-hour without padding
138
- expect(I18n.strftime(date, "%-I")).toEqual("7");
139
- expect(I18n.strftime(date, "%l")).toEqual("7");
140
-
141
- // minutes without padding
142
- expect(I18n.strftime(date, "%-M")).toEqual("8");
143
-
144
- // seconds without padding
145
- expect(I18n.strftime(date, "%-S")).toEqual("9");
146
-
147
- // short year without padding
148
- expect(I18n.strftime(date, "%-y")).toEqual("9");
149
-
150
- // month without padding
151
- expect(I18n.strftime(date, "%-m")).toEqual("4");
152
-
153
- // day without padding
154
- expect(I18n.strftime(date, "%-d")).toEqual("9");
155
- expect(I18n.strftime(date, "%e")).toEqual("9");
156
- });
157
-
158
- it("formats date with padding", function(){
159
- I18n.locale = "pt-BR";
160
-
161
- // 2009-04-26 19:35:44 (Sunday)
162
- var date = new Date(2009, 3, 9, 7, 8, 9);
163
-
164
- // 24-hour
165
- expect(I18n.strftime(date, "%H")).toEqual("07");
166
-
167
- // 12-hour
168
- expect(I18n.strftime(date, "%I")).toEqual("07");
169
-
170
- // minutes
171
- expect(I18n.strftime(date, "%M")).toEqual("08");
172
-
173
- // seconds
174
- expect(I18n.strftime(date, "%S")).toEqual("09");
175
-
176
- // short year
177
- expect(I18n.strftime(date, "%y")).toEqual("09");
178
-
179
- // month
180
- expect(I18n.strftime(date, "%m")).toEqual("04");
181
-
182
- // day
183
- expect(I18n.strftime(date, "%d")).toEqual("09");
184
- });
185
-
186
- it("formats date with negative time zone", function(){
187
- I18n.locale = "pt-BR";
188
- var date = new Date(2009, 3, 26, 19, 35, 44);
189
-
190
- spyOn(date, "getTimezoneOffset").andReturn(345);
191
-
192
- expect(I18n.strftime(date, "%z")).toMatch(/^(\+|-)[\d]{4}$/);
193
- expect(I18n.strftime(date, "%Z")).toMatch(/^(\+|-)[\d]{4}$/);
194
- expect(I18n.strftime(date, "%z")).toEqual("-0545");
195
- expect(I18n.strftime(date, "%Z")).toEqual("-0545");
196
- });
197
-
198
- it("formats date with positive time zone", function(){
199
- I18n.locale = "pt-BR";
200
- var date = new Date(2009, 3, 26, 19, 35, 44);
201
-
202
- spyOn(date, "getTimezoneOffset").andReturn(-345);
203
-
204
- expect(I18n.strftime(date, "%z")).toMatch(/^(\+|-)[\d]{4}$/);
205
- expect(I18n.strftime(date, "%Z")).toMatch(/^(\+|-)[\d]{4}$/);
206
- expect(I18n.strftime(date, "%z")).toEqual("+0545");
207
- expect(I18n.strftime(date, "%Z")).toEqual("+0545");
208
- });
209
-
210
- it("formats date with custom meridian", function(){
211
- I18n.locale = "en-US";
212
- var date = new Date(2009, 3, 26, 19, 35, 44);
213
- expect(I18n.strftime(date, "%p")).toEqual("pm");
214
- expect(I18n.strftime(date, "%P")).toEqual("pm");
215
- });
216
-
217
- it("formats date with meridian boundaries", function(){
218
- I18n.locale = "en-US";
219
- var date = new Date(2009, 3, 26, 0, 35, 44);
220
- expect(I18n.strftime(date, "%p")).toEqual("am");
221
- expect(I18n.strftime(date, "%P")).toEqual("am");
222
-
223
- date = new Date(2009, 3, 26, 12, 35, 44);
224
- expect(I18n.strftime(date, "%p")).toEqual("pm");
225
- expect(I18n.strftime(date, "%P")).toEqual("pm");
226
- });
227
-
228
- it("formats date using 12-hours format", function(){
229
- I18n.locale = "pt-BR";
230
- var date = new Date(2009, 3, 26, 19, 35, 44);
231
- expect(I18n.strftime(date, "%I")).toEqual("07");
232
-
233
- date = new Date(2009, 3, 26, 12, 35, 44);
234
- expect(I18n.strftime(date, "%I")).toEqual("12");
235
-
236
- date = new Date(2009, 3, 26, 0, 35, 44);
237
- expect(I18n.strftime(date, "%I")).toEqual("12");
238
- });
239
-
240
- it("defaults to English", function() {
241
- I18n.locale = "wk";
242
-
243
- var date = new Date(2009, 3, 26, 19, 35, 44);
244
- expect(I18n.strftime(date, "%a")).toEqual("Sun");
245
- });
246
-
247
- it("applies locale fallback", function(){
248
- I18n.defaultLocale = "en-US";
249
- I18n.locale = "de";
250
-
251
- var date = new Date(2009, 3, 26, 19, 35, 44);
252
- expect(I18n.strftime(date, "%A")).toEqual("Sonntag");
253
-
254
- date = new Date(2009, 3, 26, 19, 35, 44);
255
- expect(I18n.strftime(date, "%a")).toEqual("Sun");
256
- });
257
-
258
- it("uses time as the meridian scope", function(){
259
- I18n.locale = "de";
260
-
261
- var date = new Date(2009, 3, 26, 19, 35, 44);
262
- expect(I18n.strftime(date, "%p")).toEqual("de:PM");
263
- expect(I18n.strftime(date, "%P")).toEqual("de:pm");
264
-
265
- date = new Date(2009, 3, 26, 7, 35, 44);
266
- expect(I18n.strftime(date, "%p")).toEqual("de:AM");
267
- expect(I18n.strftime(date, "%P")).toEqual("de:am");
268
- });
269
-
270
- it("fails to format invalid date", function(){
271
- var date = new Date('foo');
272
- expect(function() {
273
- I18n.strftime(date, "%a");
274
- }).toThrow('I18n.strftime() requires a valid date object, but received an invalid date.');
275
- });
276
- });
@@ -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
- });