i18n-js 3.0.0.rc15 → 3.0.0.rc16
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 +4 -4
- data/.travis.yml +8 -6
- data/Appraisals +4 -0
- data/CHANGELOG.md +14 -1
- data/README.md +21 -0
- data/app/assets/javascripts/i18n.js +17 -12
- data/app/assets/javascripts/i18n/filtered.js.erb +15 -10
- data/gemfiles/i18n_0_8.gemfile +7 -0
- data/i18n-js.gemspec +3 -2
- data/lib/i18n/js/version.rb +1 -1
- data/package.json +1 -1
- data/spec/js/translate.spec.js +5 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bdd993cc2123f7996d8770f22fbe77d083c4d16
|
4
|
+
data.tar.gz: e8d72e140dd4a56dd87125054bd14359d738b336
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
9
|
-
- 2.
|
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.
|
12
|
+
- 2.3.3
|
13
|
+
- 2.4.0
|
14
14
|
- ruby-head
|
15
|
-
before_install:
|
16
|
-
|
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
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.
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
// AMD
|
21
|
-
|
22
|
-
|
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
|
-
|
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,
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
// AMD
|
9
|
-
define([
|
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(
|
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 %>;
|
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", "~>
|
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.
|
28
|
+
s.required_ruby_version = ">= 2.1.0"
|
28
29
|
end
|
data/lib/i18n/js/version.rb
CHANGED
data/package.json
CHANGED
data/spec/js/translate.spec.js
CHANGED
@@ -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.
|
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:
|
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: '
|
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: '
|
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.
|
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.
|
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:
|