i18n-js 3.0.1 → 3.0.2

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: a6045fc4e7caf2df9308248a08c9a5f7f74d08a5
4
- data.tar.gz: 3ac4f6ee77a6afa9948a73758bfcb70ecf92a156
3
+ metadata.gz: 1ebec2528bae57b4e38d4fbf4fe2241197dfc36d
4
+ data.tar.gz: 5b5cc7647e6dabbd1fe607a438737f156b6e9e54
5
5
  SHA512:
6
- metadata.gz: 0b56080a8ec45da012f3a846d8d811ed80245f76f2c3905079cf7930b08b3775b2381757b20b2384ab91e17fcfd76586daf459c594b31f03aa04e31fc65a8fe0
7
- data.tar.gz: 9d093f0a6c62daee153bc8d9b7702f2aab193d660a752e17e1c0fe4595637f19748819dc7c45d4e46816adaf97342d56f3db1285a687f565fd87e74ac308cf58
6
+ metadata.gz: 1e9b528236405cf0d44016d62ecbc892bd9ffec07e8266bd2cbd5760c17a852f95d38dd230779b1eab7a9db25c80394d4aa36231522227c51e5b28e2222a7ce0
7
+ data.tar.gz: 2fd596c5e48d2e570a930bf714278571c49944251247217b93f65a192338bbb3f72cf41d1f80bc8136a173792f2af705f1a97887a3ea1f182809c9f8d134f362
data/.npmignore CHANGED
@@ -17,6 +17,7 @@ coverage
17
17
  .editorconfig
18
18
 
19
19
  # Ruby code
20
+ app/assets/javascripts/i18n/
20
21
  gemfiles
21
22
  lib
22
23
  Gemfile*
@@ -6,11 +6,11 @@ cache:
6
6
  - bundler
7
7
  rvm:
8
8
  - 2.1.10
9
- - 2.2.5
9
+ - 2.2.8
10
10
  # Since the Travis Build Env does not recognize `2.3` alias yet
11
11
  # We need to specify the version precisely
12
- - 2.3.3
13
- - 2.4.0
12
+ - 2.3.5
13
+ - 2.4.2
14
14
  - ruby-head
15
15
  before_install:
16
16
  # Need to install something extra to test JS
@@ -19,6 +19,7 @@ gemfile:
19
19
  - gemfiles/i18n_0_6.gemfile
20
20
  - gemfiles/i18n_0_7.gemfile
21
21
  - gemfiles/i18n_0_8.gemfile
22
+ - gemfiles/i18n_0_9.gemfile
22
23
  matrix:
23
24
  fast_finish: true
24
25
  allow_failures:
data/Appraisals CHANGED
@@ -10,3 +10,7 @@ end
10
10
  appraise "i18n_0_8" do
11
11
  gem "i18n", "~> 0.8.0"
12
12
  end
13
+
14
+ appraise "i18n_0_9" do
15
+ gem "i18n", "~> 0.9.0"
16
+ end
@@ -18,6 +18,25 @@ This project adheres to [Semantic Versioning](http://semver.org/).
18
18
  - Nothing
19
19
 
20
20
 
21
+ ## [3.0.2] - 2017-10-26
22
+
23
+ ### Added
24
+
25
+ - Nothing
26
+
27
+ ### Changed
28
+
29
+ - [Ruby] Avoid writing new file if a file with same content already exists
30
+ (PR: https://github.com/fnando/i18n-js/pull/473)
31
+ - [JS] Fix fallback when "3-part" locale like `zh-Hant-TW` is used
32
+ It was falling back to `zh` first instead of `zh-Hant` (see new test case added)
33
+ (PR: https://github.com/fnando/i18n-js/pull/475)
34
+
35
+ ### Fixed
36
+
37
+ - Nothing
38
+
39
+
21
40
  ## [3.0.1] - 2017-08-02
22
41
 
23
42
  ### Changed
@@ -251,7 +270,8 @@ And today is not April Fools' Day
251
270
 
252
271
 
253
272
 
254
- [Unreleased]: https://github.com/fnando/i18n-js/compare/v3.0.1...HEAD
273
+ [Unreleased]: https://github.com/fnando/i18n-js/compare/v3.0.2...HEAD
274
+ [3.0.2]: https://github.com/fnando/i18n-js/compare/v3.0.1...v3.0.2
255
275
  [3.0.1]: https://github.com/fnando/i18n-js/compare/v3.0.0...v3.0.1
256
276
  [3.0.0]: https://github.com/fnando/i18n-js/compare/v3.0.0.rc16...v3.0.0
257
277
  [3.0.0.rc16]: https://github.com/fnando/i18n-js/compare/v3.0.0.rc15...v3.0.0.rc16
data/README.md CHANGED
@@ -21,7 +21,7 @@ Features:
21
21
  - Lots more! :)
22
22
 
23
23
  ## Version Notice
24
- The `master` branch (including this README) is for latest `3.0.0.rc` instead of `2.x`.
24
+ The `master` branch (including this README) is for latest `3.0.0` instead of `2.x`.
25
25
 
26
26
 
27
27
  ## Usage
@@ -279,9 +279,15 @@ by hand or using your favorite programming language. More info below.
279
279
 
280
280
  #### Via NPM with webpack and CommonJS
281
281
 
282
- Add the following line to your package.json dependencies (where version is the version you want - n.b. npm install requires it to be the gzipped tarball, see [npm install](https://www.npmjs.org/doc/cli/npm-install.html))
282
+
283
+ Add the following line to your package.json dependencies
284
+ where version is the version you want
283
285
  ```javascript
284
- "i18n-js": "http://github.com/fnando/i18n-js/archive/v3.0.0.rc12.tar.gz"
286
+ "i18n-js": "{version_constraint}"
287
+
288
+ // Or if you want unreleased version
289
+ // npm install requires it to be the gzipped tarball, see [npm install](https://www.npmjs.org/doc/cli/npm-install.html)
290
+ "i18n-js": "https://github.com/fnando/i18n-js/archive/{tag_name_or_branch_name_or_commit_sha}.tar.gz"
285
291
  ```
286
292
  Run npm install then use via
287
293
  ```javascript
@@ -777,19 +783,20 @@ Due to the design of `sprockets`:
777
783
  This means that new locale files will not be detected, and so they will not trigger a i18n-js refresh. There are a few approaches to work around this:
778
784
 
779
785
  1. You can force i18n-js to update its translations by completely clearing the assets cache. Use one of the following:
786
+
787
+ ```bash
788
+ $ rake assets:clobber
789
+ # Or, with older versions of Rails:
790
+ $ rake tmp:cache:clear
791
+ ```
780
792
 
781
- ```bash
782
- $ rake assets:clobber
783
- # Or, with older versions of Rails:
784
- $ rake tmp:cache:clear
785
- ```
793
+ These commands will remove *all* fingerprinted assets, and you will have to recompile them with
786
794
 
787
- These commands will remove *all* fingerprinted assets, and you will have to recompile them with
795
+ ```bash
796
+ $ rake assets:precompile
797
+ ```
788
798
 
789
- ```
790
- $ rake assets:precompile
791
- ```
792
- or similar commands. If you are precompiling assets on the target machine(s), cached pages may be broken by this, so they will need to be refreshed.
799
+ or similar commands. If you are precompiling assets on the target machine(s), cached pages may be broken by this, so they will need to be refreshed.
793
800
 
794
801
  2. You can change something in a different locale file.
795
802
 
@@ -309,11 +309,11 @@
309
309
  var firstFallback = null;
310
310
  var secondFallback = null;
311
311
  if (localeParts.length === 3) {
312
- firstFallback = localeParts[0];
313
- secondFallback = [
312
+ firstFallback = [
314
313
  localeParts[0],
315
314
  localeParts[1]
316
315
  ].join("-");
316
+ secondFallback = localeParts[0];
317
317
  }
318
318
  else if (localeParts.length === 2) {
319
319
  firstFallback = localeParts[0];
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "i18n", "~> 0.9.0"
6
+
7
+ gemspec :path => "../"
@@ -219,6 +219,9 @@ module I18n
219
219
  FileUtils.mkdir_p(export_i18n_js_dir_path)
220
220
 
221
221
  i18n_js_path = File.expand_path('../../../app/assets/javascripts/i18n.js', __FILE__)
222
+ destination_path = File.expand_path("i18n.js", export_i18n_js_dir_path)
223
+ return if File.exist?(destination_path) && FileUtils.identical?(i18n_js_path, destination_path)
224
+
222
225
  FileUtils.cp(i18n_js_path, export_i18n_js_dir_path)
223
226
  end
224
227
 
@@ -40,11 +40,15 @@ module I18n
40
40
 
41
41
  def write_file(_file = @file, _translations = @translations)
42
42
  FileUtils.mkdir_p File.dirname(_file)
43
+ contents = js_header
44
+ _translations.each do |locale, translations_for_locale|
45
+ contents << js_translations(locale, translations_for_locale)
46
+ end
47
+
48
+ return if File.exist?(_file) && File.read(_file) == contents
49
+
43
50
  File.open(_file, "w+") do |f|
44
- f << js_header
45
- _translations.each do |locale, translations_for_locale|
46
- f << js_translations(locale, translations_for_locale)
47
- end
51
+ f << contents
48
52
  end
49
53
  end
50
54
 
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module JS
3
- VERSION = "3.0.1"
3
+ VERSION = "3.0.2"
4
4
  end
5
5
  end
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "name": "i18n-js",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
+ "description": "A javascript library similar to Ruby on Rails i18n gem",
5
+ "author": "Nando Vieira",
6
+ "license": "MIT",
7
+ "keywords": ["i18n"],
4
8
  "devDependencies": {
5
9
  "jasmine-node": "^1.14.5"
6
10
  },
@@ -8,6 +12,10 @@
8
12
  "scripts": {
9
13
  "test": "./node_modules/.bin/jasmine-node spec/js"
10
14
  },
15
+ "homepage": "https://github.com/fnando/i18n-js",
16
+ "bugs": {
17
+ "url": "https://github.com/fnando/i18n-js/issues"
18
+ },
11
19
  "repository": {
12
20
  "type": "git",
13
21
  "url": "https://github.com/fnando/i18n-js.git"
@@ -96,6 +96,10 @@ describe("Translate", function(){
96
96
  it("fallbacks to 1-part locale when 2-part missing requested translation", function(){
97
97
  expect(I18n.t("dog")).toEqual("狗");
98
98
  });
99
+
100
+ it("fallbacks to 2-part for the first time", function(){
101
+ expect(I18n.t("dragon")).toEqual("龍");
102
+ });
99
103
  });
100
104
 
101
105
  it("fallbacks using custom rules (function)", function(){
@@ -131,11 +131,13 @@ var DEBUG = false;
131
131
  };
132
132
 
133
133
  Translations["zh-Hant"] = {
134
- cat: "貓"
134
+ cat: "貓"
135
+ , dragon: "龍"
135
136
  };
136
137
 
137
138
  Translations["zh"] = {
138
- dog: "狗"
139
+ dog: "狗"
140
+ , dragon: "龙"
139
141
  };
140
142
 
141
143
  return Translations;
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.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-02 00:00:00.000000000 Z
11
+ date: 2017-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -109,6 +109,7 @@ files:
109
109
  - gemfiles/i18n_0_6.gemfile
110
110
  - gemfiles/i18n_0_7.gemfile
111
111
  - gemfiles/i18n_0_8.gemfile
112
+ - gemfiles/i18n_0_9.gemfile
112
113
  - i18n-js.gemspec
113
114
  - lib/i18n-js.rb
114
115
  - lib/i18n/js.rb
@@ -197,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
198
  version: '0'
198
199
  requirements: []
199
200
  rubyforge_project:
200
- rubygems_version: 2.6.12
201
+ rubygems_version: 2.6.13
201
202
  signing_key:
202
203
  specification_version: 4
203
204
  summary: It's a small library to provide the Rails I18n translations on the Javascript.