i18n-js 3.0.0.rc15 → 3.0.0.rc16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cb04a52e869d4da0331db74c65512cae5c19abc
4
- data.tar.gz: 6522e5f84e73ca868c2054a2d67946c3d798a672
3
+ metadata.gz: 2bdd993cc2123f7996d8770f22fbe77d083c4d16
4
+ data.tar.gz: e8d72e140dd4a56dd87125054bd14359d738b336
5
5
  SHA512:
6
- metadata.gz: a500c069fd37898516080b518c313f8cb3cc7e0d3acc8cf9cd0a0f0b82f6f2c5f751ea777868d6de14f88fda66797f60e37246aedfbfc73942558ca648149dad
7
- data.tar.gz: ce0941d24100dd6c414f4699de4db0fac4725c2f995129cc19cec35847e7693503570e5ca8262aa7cda7da93e8ac5712bdd94c82db58271fcbc5687c3d89128a
6
+ metadata.gz: bbeea2c099c506bdceb373085e054e408caf5f1d662968c33595cc9e5b65aafdd117826ace1a55da9a68b18ff670f48e71649737ff31ba2df197868e04992868
7
+ data.tar.gz: 617d9be3db375c09d69d332053f29d391c49a4e8a6939dc89cf938b0de2f927b52d7cf29af1dcfbcd50911ef7970420c1fdca63721f182890bc0c4eff8c69f16
data/.travis.yml CHANGED
@@ -5,18 +5,20 @@ language: ruby
5
5
  cache:
6
6
  - bundler
7
7
  rvm:
8
- - 2.0
9
- - 2.1
10
- - 2.2
8
+ - 2.1.10
9
+ - 2.2.5
11
10
  # Since the Travis Build Env does not recognize `2.3` alias yet
12
11
  # We need to specify the version precisely
13
- - 2.3.0
12
+ - 2.3.3
13
+ - 2.4.0
14
14
  - ruby-head
15
- before_install: # Need to install something extra to test JS
16
- - npm install jasmine-node@1.14.2
15
+ before_install:
16
+ # Need to install something extra to test JS
17
+ - npm install
17
18
  gemfile:
18
19
  - gemfiles/i18n_0_6.gemfile
19
20
  - gemfiles/i18n_0_7.gemfile
21
+ - gemfiles/i18n_0_8.gemfile
20
22
  matrix:
21
23
  fast_finish: true
22
24
  allow_failures:
data/Appraisals CHANGED
@@ -6,3 +6,7 @@ end
6
6
  appraise "i18n_0_7" do
7
7
  gem "i18n", "~> 0.7.0"
8
8
  end
9
+
10
+ appraise "i18n_0_8" do
11
+ gem "i18n", "~> 0.8.0"
12
+ end
data/CHANGELOG.md CHANGED
@@ -18,6 +18,18 @@ This project adheres to [Semantic Versioning](http://semver.org/).
18
18
  - Nothing
19
19
 
20
20
 
21
+ ## [3.0.0.rc16] - 2017-03-13
22
+
23
+ ### Changed
24
+
25
+ - [Ruby] Drop support for Ruby < `2.1.0`
26
+
27
+ ### Fixed
28
+
29
+ - [JS] Make defaultValue works on plural translation
30
+ - [JS] Fix UMD pattern so the global/root won’t be undefined
31
+
32
+
21
33
  ## [3.0.0.rc15] - 2016-12-07
22
34
 
23
35
  ### Added
@@ -217,7 +229,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
217
229
 
218
230
 
219
231
 
220
- [Unreleased]: https://github.com/fnando/i18n-js/compare/v3.0.0.rc15...HEAD
232
+ [Unreleased]: https://github.com/fnando/i18n-js/compare/v3.0.0.rc16...HEAD
233
+ [3.0.0.rc16]: https://github.com/fnando/i18n-js/compare/v3.0.0.rc15...v3.0.0.rc16
221
234
  [3.0.0.rc15]: https://github.com/fnando/i18n-js/compare/v3.0.0.rc14...v3.0.0.rc15
222
235
  [3.0.0.rc14]: https://github.com/fnando/i18n-js/compare/v3.0.0.rc13...v3.0.0.rc14
223
236
  [3.0.0.rc13]: https://github.com/fnando/i18n-js/compare/v3.0.0.rc12...v3.0.0.rc13
data/README.md CHANGED
@@ -603,6 +603,27 @@ The accepted formats are:
603
603
 
604
604
  Check out `spec/*.spec.js` files for more examples!
605
605
 
606
+ #### Using pluralization and number formatting together
607
+ Sometimes you might want to display translation with formatted number, like adding thousand delimiters to displayed number
608
+ You can do this:
609
+ ```json
610
+ {
611
+ "en": {
612
+ "point": {
613
+ "one": "1 Point",
614
+ "other": "{{formatted_number}} Points",
615
+ "zero": "0 Points"
616
+ }
617
+ }
618
+ }
619
+ ```
620
+ ```js
621
+ var point_in_number = 1000;
622
+ I18n.t('point', { count: point_in_number, formatted_number: I18n.toNumber(point_in_number) });
623
+ ```
624
+ Output should be `1,000 points`
625
+
626
+
606
627
  ## Using multiple exported translation files on a page.
607
628
  This method is useful for very large apps where a single contained translations.js file is not desirable. Examples would be a global translations file and a more specific route translation file.
608
629
 
@@ -12,19 +12,23 @@
12
12
  // See tests for specific formatting like numbers and dates.
13
13
  //
14
14
 
15
- ;(function(factory) {
16
- if (typeof module !== 'undefined' && module.exports) {
17
- // Node/CommonJS
18
- module.exports = factory(this);
19
- } else if (typeof define === 'function' && define.amd) {
20
- // AMD
21
- var global=this;
22
- define('i18n', function(){ return factory(global);});
15
+ // Using UMD pattern from
16
+ // https://github.com/umdjs/umd#regular-module
17
+ // `returnExports.js` version
18
+ ;(function (root, factory) {
19
+ if (typeof define === 'function' && define.amd) {
20
+ // AMD. Register as an anonymous module.
21
+ define("i18n", function(){ return factory(root);});
22
+ } else if (typeof module === 'object' && module.exports) {
23
+ // Node. Does not work with strict CommonJS, but
24
+ // only CommonJS-like environments that support module.exports,
25
+ // like Node.
26
+ module.exports = factory(root);
23
27
  } else {
24
- // Browser globals
25
- this.I18n = factory(this);
28
+ // Browser globals (root is window)
29
+ root.I18n = factory(root);
26
30
  }
27
- }(function(global) {
31
+ }(this, function(global) {
28
32
  "use strict";
29
33
 
30
34
  // Use previously defined object if exists in current scope
@@ -525,6 +529,7 @@
525
529
  I18n.translate = function(scope, options) {
526
530
  options = this.prepareOptions(options);
527
531
 
532
+ var copiedOptions = this.prepareOptions(options);
528
533
  var translationOptions = this.createTranslationOptions(scope, options);
529
534
 
530
535
  var translation;
@@ -550,7 +555,7 @@
550
555
  if (typeof(translation) === "string") {
551
556
  translation = this.interpolate(translation, options);
552
557
  } else if (isObject(translation) && this.isSet(options.count)) {
553
- translation = this.pluralize(options.count, scope, options);
558
+ translation = this.pluralize(options.count, scope, copiedOptions);
554
559
  }
555
560
 
556
561
  return translation;
@@ -1,17 +1,22 @@
1
1
  <%# encoding: utf-8 %>
2
2
 
3
- ;(function(factory) {
4
- if (typeof module !== 'undefined' && module.exports) {
5
- // Node/CommonJS
6
- factory(require('i18n'));
7
- } else if (typeof define === 'function' && define.amd) {
8
- // AMD
9
- define(['i18n'], factory);
3
+ // Using UMD pattern from
4
+ // https://github.com/umdjs/umd#regular-module
5
+ // `returnExports.js` version
6
+ ;(function (root, factory) {
7
+ if (typeof define === 'function' && define.amd) {
8
+ // AMD. Register as an anonymous module.
9
+ define(["i18n"], factory);
10
+ } else if (typeof module === 'object' && module.exports) {
11
+ // Node. Does not work with strict CommonJS, but
12
+ // only CommonJS-like environments that support module.exports,
13
+ // like Node.
14
+ factory(require("i18n"));
10
15
  } else {
11
- // Browser globals
12
- factory(this.I18n);
16
+ // Browser globals (root is window)
17
+ factory(root.I18n);
13
18
  }
14
- }(function(I18n) {
19
+ }(this, function(I18n) {
15
20
  "use strict";
16
21
 
17
22
  I18n.translations = <%= I18n::JS.filtered_translations.to_json %>;
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "i18n", "~> 0.8.0"
6
+
7
+ gemspec :path => "../"
data/i18n-js.gemspec CHANGED
@@ -19,10 +19,11 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_dependency "i18n", "~> 0.6", ">= 0.6.6"
22
+
22
23
  s.add_development_dependency "appraisal", "~> 2.0"
23
24
  s.add_development_dependency "rspec", "~> 3.0"
24
- s.add_development_dependency "rake", "~> 10.0"
25
+ s.add_development_dependency "rake", "~> 12.0"
25
26
  s.add_development_dependency "gem-release", ">= 0.7"
26
27
 
27
- s.required_ruby_version = ">= 1.9.3"
28
+ s.required_ruby_version = ">= 2.1.0"
28
29
  end
@@ -4,7 +4,7 @@ module I18n
4
4
  MAJOR = 3
5
5
  MINOR = 0
6
6
  PATCH = 0
7
- STRING = "#{MAJOR}.#{MINOR}.#{PATCH}.rc15"
7
+ STRING = "#{MAJOR}.#{MINOR}.#{PATCH}.rc16"
8
8
  end
9
9
  end
10
10
  end
data/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "i18n-js",
3
3
  "version": "0.0.0",
4
4
  "devDependencies": {
5
- "jasmine-node": "*"
5
+ "jasmine-node": "^1.14.5"
6
6
  },
7
7
  "main": "app/assets/javascripts/i18n.js",
8
8
  "scripts": {
@@ -152,6 +152,11 @@ describe("Translate", function(){
152
152
  expect(actual).toEqual("Warning!");
153
153
  });
154
154
 
155
+ it("uses default value for plural translation", function(){
156
+ actual = I18n.t("message", {defaultValue: { one: '%{count} message', other: '%{count} messages'}, count: 1});
157
+ expect(actual).toEqual("1 message");
158
+ });
159
+
155
160
  it("uses default value for unknown locale", function(){
156
161
  I18n.locale = "fr";
157
162
  actual = I18n.t("warning", {defaultValue: "Warning!"});
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.0.0.rc15
4
+ version: 3.0.0.rc16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-07 00:00:00.000000000 Z
11
+ date: 2017-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '10.0'
67
+ version: '12.0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '10.0'
74
+ version: '12.0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: gem-release
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -106,6 +106,7 @@ files:
106
106
  - app/assets/javascripts/i18n/translations.js
107
107
  - gemfiles/i18n_0_6.gemfile
108
108
  - gemfiles/i18n_0_7.gemfile
109
+ - gemfiles/i18n_0_8.gemfile
109
110
  - i18n-js.gemspec
110
111
  - lib/i18n-js.rb
111
112
  - lib/i18n/js.rb
@@ -187,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
188
  requirements:
188
189
  - - ">="
189
190
  - !ruby/object:Gem::Version
190
- version: 1.9.3
191
+ version: 2.1.0
191
192
  required_rubygems_version: !ruby/object:Gem::Requirement
192
193
  requirements:
193
194
  - - ">"
@@ -195,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
196
  version: 1.3.1
196
197
  requirements: []
197
198
  rubyforge_project:
198
- rubygems_version: 2.6.7
199
+ rubygems_version: 2.6.8
199
200
  signing_key:
200
201
  specification_version: 4
201
202
  summary: It's a small library to provide the Rails I18n translations on the Javascript.
@@ -254,4 +255,3 @@ test_files:
254
255
  - spec/ruby/i18n/js/utils_spec.rb
255
256
  - spec/ruby/i18n/js_spec.rb
256
257
  - spec/spec_helper.rb
257
- has_rdoc: