i18n-js 3.5.1 → 3.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62051e50266fb55f81099456051f21393aba9a4ecabda1bf2739ae181bf64ec6
4
- data.tar.gz: 517cc9090a03e060781be401588b00495a18ccf934fd155ec838d1334b349d7c
3
+ metadata.gz: 29ffee5ef86025eb985994d60c97d8cd88d915993faa3c5016ee441151dd5d2c
4
+ data.tar.gz: 208ed897a249121db4fabb69344f362afbe716888f5f8e7a7fae0857fc5f3764
5
5
  SHA512:
6
- metadata.gz: e88fc0e5f91b673a401310c1b8db1bc5f04a3d3cf5379d978fda9a1030cb5bedb897175577301b5cd4ef86cd025f03c17250c1d5953c7779a48a0911339e7307
7
- data.tar.gz: b7caf39eff008a7817a512f60edffc515a3baa41ff8c7388d54f8fcd59f42e9247ee28567f58c264a319fd9f7049712fc8d0a76a85ca778dad4d70144fb4124f
6
+ metadata.gz: 3f3c3cf2649ae0d92fb9eb641c500a198f4228842f96e39948a9aaddcef01f8a5c2cd1967f83b6f2a7d70766d59f95c82da91a20bcecccc2ccd8c0a5ff1f19db
7
+ data.tar.gz: fa583dcd0070426fec841dc5a699837703ec3fa511fa1155e5d154909e733aba915cc6caf7543166652eab26ac64dfe7a9329d42e46238f784bc9ed18f144660
@@ -12,6 +12,7 @@ rvm:
12
12
  - 2.4
13
13
  - 2.5
14
14
  - 2.6
15
+ - 2.7
15
16
  - ruby-head
16
17
  before_install:
17
18
  # Needed to test JS
@@ -29,6 +30,7 @@ gemfile:
29
30
  - gemfiles/i18n_1_5.gemfile
30
31
  - gemfiles/i18n_1_6.gemfile
31
32
  - gemfiles/i18n_1_7.gemfile
33
+ - gemfiles/i18n_1_8.gemfile
32
34
  matrix:
33
35
  fast_finish: true
34
36
  allow_failures:
data/Appraisals CHANGED
@@ -38,3 +38,7 @@ end
38
38
  appraise "i18n_1_7" do
39
39
  gem "i18n", "~> 1.7.0"
40
40
  end
41
+
42
+ appraise "i18n_1_8" do
43
+ gem "i18n", "~> 1.8.0"
44
+ end
@@ -18,6 +18,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
18
18
  - Nothing
19
19
 
20
20
 
21
+ ## [3.6.0] - 2020-02-14
22
+
23
+ ### Added
24
+
25
+ - [Ruby] Allow `suffix` to be added to generated translations files
26
+ (PR: https://github.com/fnando/i18n-js/pull/561)
27
+
28
+
21
29
  ## [3.5.1] - 2019-12-21
22
30
 
23
31
  ### Changed
@@ -441,7 +449,8 @@ And today is not April Fools' Day
441
449
 
442
450
 
443
451
 
444
- [Unreleased]: https://github.com/fnando/i18n-js/compare/v3.5.1...HEAD
452
+ [Unreleased]: https://github.com/fnando/i18n-js/compare/v3.6.0...HEAD
453
+ [3.6.0]: https://github.com/fnando/i18n-js/compare/v3.5.1...v3.6.0
445
454
  [3.5.1]: https://github.com/fnando/i18n-js/compare/v3.5.0...v3.5.1
446
455
  [3.5.0]: https://github.com/fnando/i18n-js/compare/v3.4.2...v3.5.0
447
456
  [3.4.2]: https://github.com/fnando/i18n-js/compare/v3.4.1...v3.4.2
data/README.md CHANGED
@@ -248,9 +248,9 @@ MyNamespace.translations["en"] = { ... }
248
248
  ```
249
249
 
250
250
 
251
- ### Adding a line at the beginning of the translations file (useful for imports)
251
+ ### Adding prefix & suffix to the translations file(s)
252
252
 
253
- Setting the `prefix: "import I18n from 'i18n-js';\n"` option will add the line at the beggining of the resultant translation file.
253
+ Setting the `prefix: "import I18n from 'i18n-js';\n"` option will add the line at the beginning of the resultant translation file.
254
254
  This can be useful to use this gem with the [i18n-js](https://www.npmjs.com/package/i18n-js) npm package, which is quite useful to use it with webpack.
255
255
  The user should provide the semi-colon and the newline character if needed.
256
256
 
@@ -267,6 +267,11 @@ will create:
267
267
  ```
268
268
  import I18n from 'i18n-js';
269
269
  I18n.translations || (I18n.translations = {});
270
+ ```
271
+
272
+
273
+ `suffix` option is added in https://github.com/fnando/i18n-js/pull/561.
274
+ It's similar to `prefix` so won't explain it in details.
270
275
 
271
276
 
272
277
  #### Pretty Print
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "i18n", "~> 1.8.0"
6
+
7
+ gemspec path: "../"
@@ -2,11 +2,12 @@ module I18n
2
2
  module JS
3
3
  module Formatters
4
4
  class Base
5
- def initialize(js_extend: false, namespace: nil, pretty_print: false, prefix: nil)
5
+ def initialize(js_extend: false, namespace: nil, pretty_print: false, prefix: nil, suffix: nil)
6
6
  @js_extend = js_extend
7
7
  @namespace = namespace
8
8
  @pretty_print = pretty_print
9
9
  @prefix = prefix
10
+ @suffix = suffix
10
11
  end
11
12
 
12
13
  protected
@@ -9,7 +9,7 @@ module I18n
9
9
  translations.each do |locale, translations_for_locale|
10
10
  contents << line(locale, format_json(translations_for_locale))
11
11
  end
12
- contents
12
+ contents << (@suffix || '')
13
13
  end
14
14
 
15
15
  protected
@@ -7,7 +7,7 @@ module I18n
7
7
 
8
8
  # Class which enscapulates a translations hash and outputs a single JSON translation file
9
9
  class Segment
10
- OPTIONS = [:namespace, :pretty_print, :js_extend, :prefix, :sort_translation_keys, :json_only].freeze
10
+ OPTIONS = [:namespace, :pretty_print, :js_extend, :prefix, :suffix, :sort_translation_keys, :json_only].freeze
11
11
  LOCALE_INTERPOLATOR = /%\{locale\}/
12
12
 
13
13
  attr_reader *([:file, :translations] | OPTIONS)
@@ -25,6 +25,7 @@ module I18n
25
25
  @pretty_print = !!options[:pretty_print]
26
26
  @js_extend = options.key?(:js_extend) ? !!options[:js_extend] : true
27
27
  @prefix = options.key?(:prefix) ? options[:prefix] : nil
28
+ @suffix = options.key?(:suffix) ? options[:suffix] : nil
28
29
  @sort_translation_keys = options.key?(:sort_translation_keys) ? !!options[:sort_translation_keys] : true
29
30
  @json_only = options.key?(:json_only) ? !!options[:json_only] : false
30
31
  end
@@ -70,7 +71,9 @@ module I18n
70
71
  { js_extend: @js_extend,
71
72
  namespace: @namespace,
72
73
  pretty_print: @pretty_print,
73
- prefix: @prefix }
74
+ prefix: @prefix,
75
+ suffix: @suffix
76
+ }
74
77
  end
75
78
  end
76
79
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module I18n
4
4
  module JS
5
- VERSION = "3.5.1"
5
+ VERSION = "3.6.0"
6
6
  end
7
7
  end
@@ -6,3 +6,4 @@ translations:
6
6
  namespace: "Foo"
7
7
  pretty_print: true
8
8
  prefix: "import random from 'random-library';\n"
9
+ suffix: "//test"
@@ -351,7 +351,7 @@ EOS
351
351
  end
352
352
  end
353
353
 
354
- context "namespace, prefix and pretty_print options" do
354
+ context "namespace, prefix, suffix, and pretty_print options" do
355
355
 
356
356
  before do
357
357
  stub_const('I18n::JS::DEFAULT_EXPORT_DIR_PATH', temp_path)
@@ -379,6 +379,7 @@ EOS
379
379
  "foo": "Foo",
380
380
  "fallback_test": "Success"
381
381
  };
382
+ //test
382
383
  EOS
383
384
  }$/)
384
385
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-js
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-21 00:00:00.000000000 Z
11
+ date: 2020-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -126,6 +126,7 @@ files:
126
126
  - gemfiles/i18n_1_5.gemfile
127
127
  - gemfiles/i18n_1_6.gemfile
128
128
  - gemfiles/i18n_1_7.gemfile
129
+ - gemfiles/i18n_1_8.gemfile
129
130
  - i18n-js.gemspec
130
131
  - lib/i18n-js.rb
131
132
  - lib/i18n/js.rb