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.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +4 -0
  3. data/.github/FUNDING.yml +3 -0
  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 +45 -386
  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 +191 -0
  18. data/README.md +439 -791
  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 +157 -0
  32. data/lib/i18n-js/cli/lint_translations_command.rb +155 -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 +153 -181
  49. data/.editorconfig +0 -24
  50. data/.npmignore +0 -27
  51. data/.travis.yml +0 -36
  52. data/Appraisals +0 -32
  53. data/app/assets/javascripts/i18n/filtered.js.erb +0 -23
  54. data/app/assets/javascripts/i18n/shims.js +0 -208
  55. data/app/assets/javascripts/i18n/translations.js +0 -3
  56. data/app/assets/javascripts/i18n.js +0 -1077
  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/lib/i18n/js/dependencies.rb +0 -59
  68. data/lib/i18n/js/engine.rb +0 -87
  69. data/lib/i18n/js/fallback_locales.rb +0 -70
  70. data/lib/i18n/js/formatters/base.rb +0 -23
  71. data/lib/i18n/js/formatters/js.rb +0 -31
  72. data/lib/i18n/js/formatters/json.rb +0 -13
  73. data/lib/i18n/js/middleware.rb +0 -82
  74. data/lib/i18n/js/private/hash_with_symbol_keys.rb +0 -36
  75. data/lib/i18n/js/segment.rb +0 -75
  76. data/lib/i18n/js/utils.rb +0 -65
  77. data/lib/i18n/js/version.rb +0 -7
  78. data/lib/i18n/js.rb +0 -259
  79. data/lib/rails/generators/i18n/js/config/config_generator.rb +0 -19
  80. data/lib/rails/generators/i18n/js/config/templates/i18n-js.yml +0 -27
  81. data/lib/tasks/export.rake +0 -8
  82. data/spec/fixtures/custom_path.yml +0 -5
  83. data/spec/fixtures/default.yml +0 -5
  84. data/spec/fixtures/erb.yml +0 -5
  85. data/spec/fixtures/except_condition.yml +0 -7
  86. data/spec/fixtures/js_export_dir_custom.yml +0 -7
  87. data/spec/fixtures/js_export_dir_none.yml +0 -6
  88. data/spec/fixtures/js_extend_parent.yml +0 -6
  89. data/spec/fixtures/js_extend_segment.yml +0 -6
  90. data/spec/fixtures/js_file_per_locale.yml +0 -7
  91. data/spec/fixtures/js_file_per_locale_with_fallbacks_as_default_locale_symbol.yml +0 -4
  92. data/spec/fixtures/js_file_per_locale_with_fallbacks_as_hash.yml +0 -6
  93. data/spec/fixtures/js_file_per_locale_with_fallbacks_as_locale.yml +0 -4
  94. data/spec/fixtures/js_file_per_locale_with_fallbacks_as_locale_without_fallback_translations.yml +0 -4
  95. data/spec/fixtures/js_file_per_locale_with_fallbacks_enabled.yml +0 -4
  96. data/spec/fixtures/js_file_per_locale_without_fallbacks.yml +0 -4
  97. data/spec/fixtures/js_file_with_namespace_and_pretty_print.yml +0 -7
  98. data/spec/fixtures/js_sort_translation_keys_false.yml +0 -6
  99. data/spec/fixtures/js_sort_translation_keys_true.yml +0 -6
  100. data/spec/fixtures/json_only.yml +0 -18
  101. data/spec/fixtures/locales.yml +0 -95
  102. data/spec/fixtures/merge_plurals.yml +0 -6
  103. data/spec/fixtures/multiple_conditions.yml +0 -7
  104. data/spec/fixtures/multiple_conditions_per_locale.yml +0 -7
  105. data/spec/fixtures/multiple_files.yml +0 -7
  106. data/spec/fixtures/no_config.yml +0 -2
  107. data/spec/fixtures/no_scope.yml +0 -4
  108. data/spec/fixtures/simple_scope.yml +0 -5
  109. data/spec/js/currency.spec.js +0 -62
  110. data/spec/js/current_locale.spec.js +0 -19
  111. data/spec/js/dates.spec.js +0 -265
  112. data/spec/js/defaults.spec.js +0 -31
  113. data/spec/js/extend.spec.js +0 -110
  114. data/spec/js/interpolation.spec.js +0 -124
  115. data/spec/js/jasmine/MIT.LICENSE +0 -20
  116. data/spec/js/jasmine/jasmine-html.js +0 -190
  117. data/spec/js/jasmine/jasmine.css +0 -166
  118. data/spec/js/jasmine/jasmine.js +0 -2476
  119. data/spec/js/jasmine/jasmine_favicon.png +0 -0
  120. data/spec/js/locales.spec.js +0 -31
  121. data/spec/js/localization.spec.js +0 -48
  122. data/spec/js/numbers.spec.js +0 -170
  123. data/spec/js/placeholder.spec.js +0 -24
  124. data/spec/js/pluralization.spec.js +0 -211
  125. data/spec/js/prepare_options.spec.js +0 -41
  126. data/spec/js/require.js +0 -2083
  127. data/spec/js/specs.html +0 -49
  128. data/spec/js/specs_requirejs.html +0 -72
  129. data/spec/js/translate.spec.js +0 -284
  130. data/spec/js/translations.js +0 -163
  131. data/spec/js/utility_functions.spec.js +0 -20
  132. data/spec/ruby/i18n/js/fallback_locales_spec.rb +0 -84
  133. data/spec/ruby/i18n/js/segment_spec.rb +0 -219
  134. data/spec/ruby/i18n/js/utils_spec.rb +0 -106
  135. data/spec/ruby/i18n/js_spec.rb +0 -663
  136. data/spec/spec_helper.rb +0 -79
  137. data/yarn.lock +0 -131
data/lib/i18n/js.rb DELETED
@@ -1,259 +0,0 @@
1
- require "yaml"
2
- require "fileutils"
3
- require "i18n"
4
-
5
- require "i18n/js/utils"
6
- require "i18n/js/private/hash_with_symbol_keys"
7
-
8
- module I18n
9
- module JS
10
- require "i18n/js/dependencies"
11
- require "i18n/js/fallback_locales"
12
- require "i18n/js/segment"
13
- if JS::Dependencies.rails?
14
- require "i18n/js/middleware"
15
- require "i18n/js/engine"
16
- end
17
-
18
- DEFAULT_CONFIG_PATH = "config/i18n-js.yml"
19
- DEFAULT_EXPORT_DIR_PATH = "public/javascripts"
20
-
21
- # The configuration file. This defaults to the `config/i18n-js.yml` file.
22
- #
23
- def self.config_file_path
24
- @config_file_path ||= DEFAULT_CONFIG_PATH
25
- end
26
-
27
- def self.config_file_path=(new_path)
28
- @config_file_path = new_path
29
- end
30
-
31
- # Allow using a different backend than the one globally configured
32
- def self.backend
33
- @backend ||= I18n.backend
34
- end
35
-
36
- def self.backend=(alternative_backend)
37
- @backend = alternative_backend
38
- end
39
-
40
- # Export translations to JavaScript, considering settings
41
- # from configuration file
42
- def self.export
43
- export_i18n_js
44
-
45
- translation_segments.each(&:save!)
46
- end
47
-
48
- def self.segment_for_scope(scope, exceptions)
49
- if scope == "*"
50
- exclude(translations, exceptions)
51
- else
52
- scoped_translations(scope, exceptions)
53
- end
54
- end
55
-
56
- def self.configured_segments
57
- config[:translations].inject([]) do |segments, options_hash|
58
- options_hash_with_symbol_keys = Private::HashWithSymbolKeys.new(options_hash)
59
- file = options_hash_with_symbol_keys[:file]
60
- only = options_hash_with_symbol_keys[:only] || '*'
61
- exceptions = [options_hash_with_symbol_keys[:except] || []].flatten
62
-
63
- result = segment_for_scope(only, exceptions)
64
-
65
- merge_with_fallbacks!(result) if fallbacks
66
-
67
- unless result.empty?
68
- segments << Segment.new(
69
- file,
70
- result,
71
- extract_segment_options(options_hash_with_symbol_keys),
72
- )
73
- end
74
-
75
- segments
76
- end
77
- end
78
-
79
- # deep_merge! given result with result for fallback locale
80
- def self.merge_with_fallbacks!(result)
81
- I18n.available_locales.each do |locale|
82
- fallback_locales = FallbackLocales.new(fallbacks, locale)
83
- fallback_locales.each do |fallback_locale|
84
- # `result[fallback_locale]` could be missing
85
- result[locale] = Utils.deep_merge(result[fallback_locale] || {}, result[locale] || {})
86
- end
87
- end
88
- end
89
-
90
- def self.filtered_translations
91
- translations = {}.tap do |result|
92
- translation_segments.each do |segment|
93
- Utils.deep_merge!(result, segment.translations)
94
- end
95
- end
96
- return Utils.deep_key_sort(translations) if I18n::JS.sort_translation_keys?
97
- translations
98
- end
99
-
100
- def self.translation_segments
101
- if config_file_exists? && config[:translations]
102
- configured_segments
103
- else
104
- [Segment.new("#{DEFAULT_EXPORT_DIR_PATH}/translations.js", translations)]
105
- end
106
- end
107
-
108
- # Load configuration file for partial exporting and
109
- # custom output directory
110
- def self.config
111
- if config_file_exists?
112
- erb_result_from_yaml_file = ERB.new(File.read(config_file_path)).result
113
- Private::HashWithSymbolKeys.new(
114
- (::YAML.load(erb_result_from_yaml_file) || {})
115
- )
116
- else
117
- Private::HashWithSymbolKeys.new({})
118
- end.freeze
119
- end
120
-
121
- # @api private
122
- # Check if configuration file exist
123
- def self.config_file_exists?
124
- File.file? config_file_path
125
- end
126
-
127
- def self.scoped_translations(scopes, exceptions = []) # :nodoc:
128
- result = {}
129
-
130
- [scopes].flatten.each do |scope|
131
- translations_without_exceptions = exclude(translations, exceptions)
132
- filtered_translations = filter(translations_without_exceptions, scope) || {}
133
-
134
- Utils.deep_merge!(result, filtered_translations)
135
- end
136
-
137
- result
138
- end
139
-
140
- # Exclude keys from translations listed in the `except:` section in the config file
141
- def self.exclude(translations, exceptions)
142
- return translations if exceptions.empty?
143
-
144
- exceptions.inject(translations) do |memo, exception|
145
- exception_scopes = exception.to_s.split(".")
146
- Utils.deep_reject(memo) do |key, value, scopes|
147
- Utils.scopes_match?(scopes, exception_scopes)
148
- end
149
- end
150
- end
151
-
152
- # Filter translations according to the specified scope.
153
- def self.filter(translations, scopes)
154
- scopes = scopes.split(".") if scopes.is_a?(String)
155
- scopes = scopes.clone
156
- scope = scopes.shift
157
-
158
- if scope == "*"
159
- results = {}
160
- translations.each do |scope, translations|
161
- tmp = scopes.empty? ? translations : filter(translations, scopes)
162
- results[scope.to_sym] = tmp unless tmp.nil?
163
- end
164
- return results
165
- elsif translations.respond_to?(:key?) && translations.key?(scope.to_sym)
166
- return {scope.to_sym => scopes.empty? ? translations[scope.to_sym] : filter(translations[scope.to_sym], scopes)}
167
- end
168
- nil
169
- end
170
-
171
- # Initialize and return translations
172
- def self.translations
173
- self.backend.instance_eval do
174
- init_translations unless initialized?
175
- # When activesupport is absent,
176
- # the core extension (`#slice`) from `i18n` gem will be used instead
177
- # And it's causing errors (at least in test)
178
- #
179
- # So the input is wrapped by our class for better `#slice`
180
- Private::HashWithSymbolKeys.new(translations).
181
- slice(*::I18n.available_locales).
182
- to_h
183
- end
184
- end
185
-
186
- def self.use_fallbacks?
187
- fallbacks != false
188
- end
189
-
190
- def self.json_only
191
- config.fetch(:json_only) do
192
- # default value
193
- false
194
- end
195
- end
196
-
197
- def self.fallbacks
198
- config.fetch(:fallbacks) do
199
- # default value
200
- true
201
- end
202
- end
203
-
204
- def self.js_extend
205
- config.fetch(:js_extend) do
206
- # default value
207
- true
208
- end
209
- end
210
-
211
- def self.sort_translation_keys?
212
- @sort_translation_keys ||= (config[:sort_translation_keys]) if config.key?(:sort_translation_keys)
213
- @sort_translation_keys = true if @sort_translation_keys.nil?
214
- @sort_translation_keys
215
- end
216
-
217
- def self.sort_translation_keys=(value)
218
- @sort_translation_keys = !!value
219
- end
220
-
221
- def self.extract_segment_options(options)
222
- segment_options = Private::HashWithSymbolKeys.new({
223
- js_extend: js_extend,
224
- sort_translation_keys: sort_translation_keys?,
225
- json_only: json_only
226
- }).freeze
227
- segment_options.merge(options.slice(*Segment::OPTIONS))
228
- end
229
-
230
- ### Export i18n.js
231
- begin
232
-
233
- # Copy i18n.js
234
- def self.export_i18n_js
235
- return unless export_i18n_js_dir_path.is_a? String
236
-
237
- FileUtils.mkdir_p(export_i18n_js_dir_path)
238
-
239
- i18n_js_path = File.expand_path('../../../app/assets/javascripts/i18n.js', __FILE__)
240
- destination_path = File.expand_path("i18n.js", export_i18n_js_dir_path)
241
- return if File.exist?(destination_path) && FileUtils.identical?(i18n_js_path, destination_path)
242
-
243
- FileUtils.cp(i18n_js_path, export_i18n_js_dir_path)
244
- end
245
-
246
- def self.export_i18n_js_dir_path
247
- @export_i18n_js_dir_path ||= (config[:export_i18n_js] || :none) if config.key?(:export_i18n_js)
248
- @export_i18n_js_dir_path ||= DEFAULT_EXPORT_DIR_PATH
249
- @export_i18n_js_dir_path
250
- end
251
-
252
- # Setting this to nil would disable i18n.js exporting
253
- def self.export_i18n_js_dir_path=(new_path)
254
- new_path = :none unless new_path.is_a? String
255
- @export_i18n_js_dir_path = new_path
256
- end
257
- end
258
- end
259
- end
@@ -1,19 +0,0 @@
1
- module I18n
2
- module Js
3
- class ConfigGenerator < Rails::Generators::Base
4
- # Copied files come from templates folder
5
- source_root File.expand_path('../templates', __FILE__)
6
-
7
- # Generator desc
8
- desc <<-DESC
9
- Creates a default i18n-js.yml configuration file in your app's config
10
- folder. This file allows you to customize i18n:js:export rake task
11
- outputted files.
12
- DESC
13
-
14
- def copy_initializer_file
15
- copy_file "i18n-js.yml", "config/i18n-js.yml"
16
- end
17
- end
18
- end
19
- end
@@ -1,27 +0,0 @@
1
- # Split context in several files.
2
- #
3
- # By default only one file with all translations is exported and
4
- # no configuration is required. Your settings for asset pipeline
5
- # are automatically recognized.
6
- #
7
- # If you want to split translations into several files or specify
8
- # locale contexts that will be exported, just use this file to do
9
- # so.
10
- #
11
- # For more informations about the export options with this file, please
12
- # refer to the README
13
- #
14
- #
15
- # If you're going to use the Rails 3.1 asset pipeline, change
16
- # the following configuration to something like this:
17
- #
18
- # translations:
19
- # - file: "app/assets/javascripts/i18n/translations.js"
20
- #
21
- # If you're running an old version, you can use something
22
- # like this:
23
- #
24
- # translations:
25
- # - file: "app/assets/javascripts/i18n/translations.js"
26
- # only: "*"
27
- #
@@ -1,8 +0,0 @@
1
- namespace :i18n do
2
- namespace :js do
3
- desc "Export translations to JS file(s)"
4
- task :export => :environment do
5
- I18n::JS.export
6
- end
7
- end
8
- end
@@ -1,5 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/all.js"
5
- only: "*"
@@ -1,5 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/translations.js"
5
- only: "*"
@@ -1,5 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/translations.js"
5
- only: '<%= "*." + "date." + "formats" %>'
@@ -1,7 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/trimmed.js"
5
- except:
6
- - "active_admin"
7
- - "mailers"
@@ -1,7 +0,0 @@
1
- fallbacks: false
2
-
3
- export_i18n_js: 'tmp/i18n-js/foo'
4
-
5
- translations:
6
- - file: "tmp/i18n-js/%{locale}.js"
7
- only: '*'
@@ -1,6 +0,0 @@
1
- fallbacks: false
2
- export_i18n_js: false
3
-
4
- translations:
5
- - file: "tmp/i18n-js/%{locale}.js"
6
- only: '*'
@@ -1,6 +0,0 @@
1
- fallbacks: false
2
- js_extend: false
3
-
4
- translations:
5
- - file: "tmp/i18n-js/js_extend_parent.js"
6
- only: "*.date.formats"
@@ -1,6 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/js_extend_segment.js"
5
- js_extend: false
6
- only: "*.date.formats"
@@ -1,7 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/%{locale}.js"
5
- only:
6
- - '*.date.*'
7
- - '*.admin.*'
@@ -1,4 +0,0 @@
1
- fallbacks: :default_locale
2
-
3
- translations:
4
- - file: "tmp/i18n-js/%{locale}.js"
@@ -1,6 +0,0 @@
1
- fallbacks:
2
- fr: ["de", "en"]
3
- de: "en"
4
-
5
- translations:
6
- - file: "tmp/i18n-js/%{locale}.js"
@@ -1,4 +0,0 @@
1
- fallbacks: :de
2
-
3
- translations:
4
- - file: "tmp/i18n-js/%{locale}.js"
@@ -1,4 +0,0 @@
1
- fallbacks: :pirate
2
-
3
- translations:
4
- - file: "tmp/i18n-js/%{locale}.js"
@@ -1,4 +0,0 @@
1
- fallbacks: true
2
-
3
- translations:
4
- - file: "tmp/i18n-js/%{locale}.js"
@@ -1,4 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/%{locale}.js"
@@ -1,7 +0,0 @@
1
- fallbacks: false
2
-
3
- translations:
4
- - file: "tmp/i18n-js/%{locale}.js"
5
- only: '*'
6
- namespace: "Foo"
7
- pretty_print: true
@@ -1,6 +0,0 @@
1
-
2
- sort_translation_keys: false
3
-
4
- translations:
5
- - file: "tmp/i18n-js/%{locale}.js"
6
- only: '*'
@@ -1,6 +0,0 @@
1
-
2
- sort_translation_keys: true
3
-
4
- translations:
5
- - file: "tmp/i18n-js/%{locale}.js"
6
- only: '*'
@@ -1,18 +0,0 @@
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,95 +0,0 @@
1
- en:
2
- number:
3
- format:
4
- separator: "."
5
- delimiter: ","
6
- precision: 3
7
- currency:
8
- format:
9
- format: "%u%n"
10
- unit: "$"
11
- separator: "."
12
- delimiter: ","
13
- precision: 2
14
- date:
15
- formats:
16
- default: "%Y-%m-%d"
17
- short: "%b %d"
18
- long: "%B %d, %Y"
19
- day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
20
- abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
21
- month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
22
- abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
23
- # order: [ :year, :month, :day ]
24
- time:
25
- formats:
26
- default: "%a, %d %b %Y %H:%M:%S %z"
27
- short: "%d %b %H:%M"
28
- long: "%B %d, %Y %H:%M"
29
- am: "am"
30
- pm: "pm"
31
- admin:
32
- show:
33
- title: "Show"
34
- note: "more details"
35
- edit:
36
- title: "Edit"
37
- foo: "Foo"
38
- fallback_test: "Success"
39
- null_test: "fallback for null"
40
- merge_plurals:
41
- one: Apple
42
- other: Apples
43
-
44
- de:
45
- fallback_test: "Erfolg"
46
- null_test: ~
47
-
48
- fr:
49
- date:
50
- formats:
51
- default: "%d/%m/%Y"
52
- short: "%e %b"
53
- long: "%e %B %Y"
54
- long_ordinal: "%e %B %Y"
55
- only_day: "%e"
56
- day_names: [dimanche, lundi, mardi, mercredi, jeudi, vendredi, samedi]
57
- abbr_day_names: [dim, lun, mar, mer, jeu, ven, sam]
58
- month_names: [~, janvier, février, mars, avril, mai, juin, juillet, août, septembre, octobre, novembre, décembre]
59
- abbr_month_names: [~, jan., fév., mar., avr., mai, juin, juil., août, sept., oct., nov., déc.]
60
- # order: [ :day, :month, :year ]
61
- time:
62
- formats:
63
- default: "%d %B %Y %H:%M"
64
- time: "%H:%M"
65
- short: "%d %b %H:%M"
66
- long: "%A %d %B %Y %H:%M:%S %Z"
67
- long_ordinal: "%A %d %B %Y %H:%M:%S %Z"
68
- only_second: "%S"
69
- am: 'am'
70
- pm: 'pm'
71
- number:
72
- format:
73
- precision: 3
74
- separator: ','
75
- delimiter: ' '
76
- currency:
77
- format:
78
- unit: '€'
79
- precision: 2
80
- format: '%n %u'
81
- admin:
82
- show:
83
- title: "Visualiser"
84
- note: "plus de détails"
85
- edit:
86
- title: "Editer"
87
- merge_plurals:
88
- zero: Pomme
89
- one: Pomme
90
- other: Pommes
91
-
92
- ja:
93
- admin:
94
- show:
95
- 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,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
- });