handlebars-i18n 1.3.0 → 1.4.1

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.
@@ -1,6 +1,10 @@
1
1
  name: CI
2
2
 
3
- on: [create, pull_request, push]
3
+ on:
4
+ pull_request:
5
+ push:
6
+ release:
7
+ types: [published]
4
8
 
5
9
  env:
6
10
  IMAGE_ID: ${{ github.repository }}
@@ -17,16 +21,16 @@ jobs:
17
21
  npm i
18
22
  npm run test
19
23
  semantic-release:
20
- if: github.event_name != 'pull_request'
24
+ if: github.ref == 'refs/heads/master'
21
25
  name: Semantic Release
22
26
  runs-on: ubuntu-latest
23
27
  needs: build
24
28
  steps:
25
- - uses: actions/checkout@v2.3.4
29
+ - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # renovate: tag=v2.4.0
26
30
  with:
27
31
  token: ${{ secrets.GITHUB_TOKEN }}
28
32
  - name: Semantic Release
29
- uses: cycjimmy/semantic-release-action@v2.5.3
33
+ uses: cycjimmy/semantic-release-action@5982a02995853159735cb838992248c4f0f16166 # renovate: tag=v2.7.0
30
34
  with:
31
35
  extra_plugins: |
32
36
  @semantic-release/changelog
@@ -1,8 +1,8 @@
1
- name: Scheduled Release
1
+ name: 'Release: Scheduled'
2
2
 
3
3
  on:
4
4
  schedule:
5
- - cron: '0 0 * * 1' # Every Monday at 00:00 AM UTC on the default branch
5
+ - cron: '0 0 * * 1' # Every Monday at 00:00 AM UTC on the default branch
6
6
 
7
7
  jobs:
8
8
  analyze-tags:
@@ -11,12 +11,12 @@ jobs:
11
11
  previous-tag: ${{ steps.previoustag.outputs.tag }}
12
12
  timestamp-diff: ${{ steps.diff.outputs.timestamp-diff }}
13
13
  steps:
14
- - uses: actions/checkout@v2.3.4
14
+ - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # renovate: tag=v2.4.0
15
15
  with:
16
16
  fetch-depth: 0
17
17
  - name: Get previous tag
18
18
  id: previoustag
19
- uses: "WyriHaximus/github-action-get-previous-tag@1.0.0"
19
+ uses: WyriHaximus/github-action-get-previous-tag@v1.1.0
20
20
  - name: Get seconds from previous tag to now
21
21
  id: diff
22
22
  shell: bash
@@ -30,20 +30,20 @@ jobs:
30
30
  needs: analyze-tags
31
31
  if: needs.analyze-tags.outputs.timestamp-diff > 604800 # 604800 equal one week.
32
32
  steps:
33
- - uses: actions/checkout@v2.3.4
33
+ - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # renovate: tag=v2.4.0
34
34
  with:
35
35
  token: ${{ secrets.GITHUB_TOKEN }}
36
36
  - name: Get next minor version
37
37
  id: semvers
38
- uses: "WyriHaximus/github-action-next-semvers@v1"
38
+ uses: WyriHaximus/github-action-next-semvers@v1
39
39
  with:
40
40
  version: ${{ needs.analyze-tags.outputs.previous-tag }}
41
41
  - name: manifest Version
42
- uses: deef0000dragon1/json-edit-action/@v1
42
+ uses: deef0000dragon1/json-edit-action@cb3f7455e89d659879ab7e4a55cbc9b10c36a713 # renovate: tag=v1
43
43
  env:
44
44
  KEY: scheduleVersion
45
45
  VALUE: ${{ steps.semvers.outputs.patch }}
46
- FILE: package.json
47
- - uses: stefanzweifel/git-auto-commit-action@v4.10.0
46
+ FILE: ${{ inputs.PACKAGE_JSON_PATH || 'package.json' }}
47
+ - uses: stefanzweifel/git-auto-commit-action@5804e42f86b1891093b151b6c4e78e759c746c4d # renovate: tag=v4.13.1
48
48
  with:
49
- commit_message: 'fix(release): schedule release'
49
+ commit_message: 'fix(release): schedule release'
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## [1.4.1](https://github.com/fwalzel/handlebars-i18n/compare/1.4.0...1.4.1) (2022-03-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * code quality badge in readme.md, unstashing falsely included .idea folder ([650b6c8](https://github.com/fwalzel/handlebars-i18n/commit/650b6c81ae796ad56c3ac59310273f4cf154e2c0))
7
+
8
+ # [1.4.0](https://github.com/fwalzel/handlebars-i18n/compare/1.3.1...1.4.0) (2022-03-22)
9
+
10
+
11
+ ### Features
12
+
13
+ * **deps:** upgrade gulp-uglify-es to v3 ([9c918a5](https://github.com/fwalzel/handlebars-i18n/commit/9c918a5b2bb9d6575c106abff5b57922e208f9ac))
14
+ * **deps:** upgrade mocha to v9 ([2de5e75](https://github.com/fwalzel/handlebars-i18n/commit/2de5e75862467e32a2f5ce65ba520520844d3b53))
15
+
16
+ ## [1.3.1](https://github.com/fwalzel/handlebars-i18n/compare/1.3.0...1.3.1) (2021-09-22)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * typo in readme.md ([41f554a](https://github.com/fwalzel/handlebars-i18n/commit/41f554a4aa1ed83b63a458dc1ef84b5692733d8b))
22
+
1
23
  # [1.3.0](https://github.com/fwalzel/handlebars-i18n/compare/1.2.1...1.3.0) (2021-09-17)
2
24
 
3
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "handlebars-i18n",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "handlebars-i18n adds internationlization to handlebars.js using i18next and Intl",
5
5
  "main": "dist/handlebars-i18n.js",
6
6
  "scripts": {
@@ -35,28 +35,28 @@
35
35
  "license": "MIT",
36
36
  "homepage": "https://github.com/fwalzel/handlebars-i18n.git#readme",
37
37
  "peerDependencies": {
38
- "handlebars": "^4.7.6",
39
- "i18next": "^20.2.1",
38
+ "handlebars": "^4.7.7",
39
+ "i18next": "^21.6.14",
40
40
  "intl": "^1.2.5"
41
41
  },
42
42
  "devDependencies": {
43
- "@commitlint/cli": "12.1.1",
44
- "@commitlint/config-conventional": "12.1.1",
45
- "chai": "4.3.4",
46
- "coveralls": "3.1.0",
43
+ "@commitlint/cli": "16.2.3",
44
+ "@commitlint/config-conventional": "16.2.1",
45
+ "chai": "4.3.6",
46
+ "coveralls": "3.1.1",
47
47
  "gulp": "4.0.2",
48
48
  "gulp-rename": "2.0.0",
49
49
  "gulp-uglify": "3.0.2",
50
- "gulp-uglify-es": "2.0.0",
50
+ "gulp-uglify-es": "3.0.0",
51
+ "husky": "7.0.4",
51
52
  "istanbul": "0.4.5",
52
- "mocha": "8.3.2",
53
+ "mocha": "9.2.2",
53
54
  "nyc": "15.1.0"
54
55
  },
55
56
  "dependencies": {
56
- "handlebars": "^4.7.6",
57
- "husky": "^7.0.2",
58
- "i18next": "^20.2.1",
59
- "intl": "^1.2.5"
57
+ "handlebars": "4.7.7",
58
+ "i18next": "21.6.14",
59
+ "intl": "1.2.5"
60
60
  },
61
61
  "husky": {
62
62
  "hooks": {
package/readme.md CHANGED
@@ -4,7 +4,12 @@
4
4
 
5
5
  Handlebars-i18n is listed amongst i18next’s [framework helpers](https://www.i18next.com/overview/supported-frameworks).
6
6
 
7
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Build Status](https://travis-ci.org/fwalzel/handlebars-i18n.svg?branch=master)](https://travis-ci.org/fwalzel/handlebars-i18n) [![Coverage Status](https://coveralls.io/repos/github/fwalzel/handlebars-i18next/badge.svg?branch=master)](https://coveralls.io/github/fwalzel/handlebars-i18next?branch=master) [![Code Quality](https://www.code-inspector.com/project/29087/status/svg)](https://www.code-inspector.com/project/29087/status/svg) [![Known Vulnerabilities](https://snyk.io/test/github/Aller-Couleur/handlebars-i18n/badge.svg)]
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
8
+ [![Build Status](https://travis-ci.org/fwalzel/handlebars-i18n.svg?branch=master)](https://travis-ci.org/fwalzel/handlebars-i18n)
9
+ [![Coverage Status](https://coveralls.io/repos/github/fwalzel/handlebars-i18next/badge.svg?branch=master)](https://coveralls.io/github/fwalzel/handlebars-i18next?branch=master)
10
+ [![Code Quality](https://api.codiga.io/project/29087/score/svg)](https://api.codiga.io/project/29087/score/svg)
11
+ [![Known Vulnerabilities](https://snyk.io/test/github/Aller-Couleur/handlebars-i18n/badge.svg)](https://snyk.io/test/github/Aller-Couleur/handlebars-i18n/badge.svg)
12
+
8
13
 
9
14
  ## License
10
15
 
@@ -13,10 +18,17 @@ MIT License
13
18
 
14
19
  ## Install
15
20
 
21
+ If you use version npm >= 7:
22
+
23
+ ```bash
24
+ $ npm i handlebars-i18n
16
25
  ```
17
- $ npm install handlebars-i18n handlebars i18next intl
18
- ```
19
26
 
27
+ For older versions do:
28
+
29
+ ```bash
30
+ $ npm i handlebars-i18n handlebars@4.7.6 i18next@20.2.1 intl@1.2.5
31
+ ```
20
32
 
21
33
  ## Usage
22
34
 
@@ -51,13 +63,13 @@ i18next.init({
51
63
  "en" : {
52
64
  translation : {
53
65
  "phrase1": "What is good?",
54
- "phrase2": "{{what}} is good."
66
+ "phrase2": "{{thing}} is good."
55
67
  }
56
68
  },
57
69
  "de" : {
58
70
  translation: {
59
71
  "phrase1": "Was ist gut?",
60
- "phrase2": "{{what}} ist gut."
72
+ "phrase2": "{{thing}} ist gut."
61
73
  }
62
74
  }
63
75
  },
@@ -69,9 +81,9 @@ Set your Handlebars.js data object:
69
81
 
70
82
  ```javascript
71
83
  let data = {
72
- myItem: "handlebars-i18n",
73
- myPrice: 1200.99,
74
- myDate: "2020-03-11T03:24:00"
84
+ myItem: "handlebars-i18n",
85
+ myPrice: 1200.99,
86
+ myDate: "2020-03-11T03:24:00"
75
87
  }
76
88
 
77
89
  ```
@@ -85,9 +97,9 @@ HandlebarsI18n.init();
85
97
  Optionally configure your language specific number, currency, and date-time defaults:
86
98
 
87
99
  ```javascript
88
- HandlebarsI18n.configure([
89
- ["en", "PriceFormat", {currency: "USD"}],
90
- ["de", "PriceFormat", {currency: "EUR"}]
100
+ HandlebarsI18n.configure([
101
+ ["en", "PriceFormat", {currency: "USD"}],
102
+ ["de", "PriceFormat", {currency: "EUR"}]
91
103
  ]);
92
104
  ```
93
105
 
@@ -99,7 +111,7 @@ Finally use in template:
99
111
  * returns for "en" → **What is good?**
100
112
 
101
113
  ```
102
- <p> {{__ "phrase2" what=myItem}} </p>
114
+ <p> {{__ "phrase2" thing=myItem}} </p>
103
115
  ```
104
116
  * returns for "en" &#x2192; **handlebars-i18n is good.**
105
117
 
@@ -120,7 +132,7 @@ Finally use in template:
120
132
 
121
133
  ## Run tests
122
134
 
123
- ```
135
+ ```bash
124
136
  $ npm test
125
137
  ```
126
138
 
@@ -166,12 +178,12 @@ The i18next resource:
166
178
  {{__ "keyWithCount" count=8}}
167
179
  ```
168
180
 
169
- ```
181
+ ```javascript
170
182
  'en' : {
171
- translation : {
172
- 'keyWithCount': '{{count}} item',
173
- 'keyWithCount_plural': '{{count}} items',
174
- }
183
+ translation : {
184
+ 'keyWithCount': '{{count}} item',
185
+ 'keyWithCount_plural': '{{count}} items',
186
+ }
175
187
  },
176
188
  ```
177
189
 
@@ -290,8 +302,8 @@ You can add multiple arguments for individual currency formatting. See [Intl Num
290
302
 
291
303
  Instead of defining the formatting options for each date, number or price anew, you can configure global settings for all languages or only for specific languages.
292
304
 
293
- ```
294
- HandlebarsI18n.configure("all", "DateTimeFormat", {timeZone: "America/Los_Angeles"});
305
+ ```javascript
306
+ HandlebarsI18n.configure("all", "DateTimeFormat", {timeZone: "America/Los_Angeles"});
295
307
  ```
296
308
 
297
309
  First argument is the language shortcode or "**all**" for all languages. Second is the format option you want to address (DateTimeFormat, NumberFormat, or PriceFormat). Third argument ist the options object with the specific settings.
@@ -300,18 +312,18 @@ First argument is the language shortcode or "**all**" for all languages. Second
300
312
 
301
313
  You can define specific subsets to be used in the template, i.e. if you want the date in different formatts such as:
302
314
 
303
- * **2020** (year-only)
304
- * **11.3.2020** (standard-date)
305
- * **7:24:02** (time-only)
315
+ - **2020** (year-only)
316
+ - **11.3.2020** (standard-date)
317
+ - **7:24:02** (time-only)
306
318
 
307
319
  To do this define a 4th parameter with a custom name:
308
320
 
309
321
 
310
322
  ```javascript
311
- HandlebarsI18n.configure([
312
- ["en", "DateTimeFormat", {year:'numeric'}, "year-only"],
313
- ["en", "DateTimeFormat", {year:'numeric', month:'numeric', day:'numeric'}, "standard-date"],
314
- ['en', 'DateTimeFormat', { hour:'numeric', minute:'numeric', second:'numeric', hour12:false}, "time-only"]
323
+ HandlebarsI18n.configure([
324
+ ["en", "DateTimeFormat", {year:'numeric'}, "year-only"],
325
+ ["en", "DateTimeFormat", {year:'numeric', month:'numeric', day:'numeric'}, "standard-date"],
326
+ ['en', 'DateTimeFormat', { hour:'numeric', minute:'numeric', second:'numeric', hour12:false}, "time-only"]
315
327
  ]);
316
328
  ```
317
329
 
@@ -327,26 +339,26 @@ Call a subset in template wit the parameter "format", like:
327
339
 
328
340
  The general lookup cascade is:
329
341
 
330
- * `1st Priority`: The argument given in the template for custom configurations by the key "format", i.e. `{{_date format="my-custom-format"}}`
331
- * `2nd Priority`: The extra argument(s) given in the template, e.g. `{{_date timeZone="America/Los_Angeles" year="2-digit"}}`
332
- * `3rd Priority`: The global setting configured for the current language, such as "**en**"
333
- * `4th Priority`: The global setting configured for **all** languages
334
- * `Default`: The **Intl** default setting
342
+ - **1st Priority**: The argument given in the template for custom configurations by the key "format", i.e. `{{_date format="my-custom-format"}}`
343
+ - **2nd Priority**: The extra argument(s) given in the template, e.g. `{{_date timeZone="America/Los_Angeles" year="2-digit"}}`
344
+ - **3rd Priority**: The global setting configured for the current language, such as "**en**"
345
+ - **4th Priority**: The global setting configured for **all** languages
346
+ - **Default**: The **Intl** default setting
335
347
 
336
348
  **Example:**
337
349
 
338
350
  This defines that all prices for all languages are represented as Dollar:
339
351
 
340
- ```
341
- HandlebarsI18n.configure("all", "PriceFormat", {currency: "USD"});
352
+ ```javascript
353
+ HandlebarsI18n.configure("all", "PriceFormat", {currency: "USD"});
342
354
  ```
343
355
 
344
356
  This defines that all prices for all languages are represented as Dollar, but that for language French the currency is Euro:
345
357
 
346
- ```
347
- HandlebarsI18n.configure([
348
- ["all", "PriceFormat", {currency: "USD"}],
349
- ["fr", "PriceFormat", {currency: "EUR"}]
358
+ ```javascript
359
+ HandlebarsI18n.configure([
360
+ ["all", "PriceFormat", {currency: "USD"}],
361
+ ["fr", "PriceFormat", {currency: "EUR"}]
350
362
  ]);
351
363
  ```
352
364
 
@@ -355,20 +367,20 @@ This defines that all prices for all languages are represented as Dollar, but th
355
367
  Dismiss all existing configurations:
356
368
 
357
369
  ```javascript
358
- HandlebarsI18n.reset();
370
+ HandlebarsI18n.reset();
359
371
  ```
360
372
 
361
373
  ## Using custom instances of Handlebars
362
374
 
363
- Sometimes you may want to use a Handlebars Object you have already modified before, or you may want to use muliple descrete instances of Handlebars. In this case you can pass you custom Handlebars instance to the init function to use it instead of the generic Handebars object. like so:
375
+ Sometimes you may want to use a Handlebars Object you have already modified before, or you may want to use multiple discrete instances of Handlebars. In this case you can pass you custom Handlebars instance to the init function to use it instead of the generic Handlebars object like so:
364
376
 
365
377
  ```javascript
366
378
  const HandlebarsModified = require('handlebars');
367
379
  HandlebarsModified.registerHelper('foo', function() { return 'what you want' });
368
- HandlebarsI18n.init(HandlebarsModified)
380
+ HandlebarsI18n.init(HandlebarsModified);
369
381
  ```
370
382
 
371
- HandlebarsI18n will have the method **foo()** by now.
383
+ HandlebarsI18n will have your previously defined method **foo()** by now.
372
384
 
373
385
 
374
386
  ## Note
@@ -13,7 +13,6 @@ const Handlebars = require('handlebars');
13
13
  const i18next = require('i18next');
14
14
  const HandlebarsI18n = require('../dist/handlebars-i18n');
15
15
 
16
-
17
16
  describe('handlebars-i18n Test', function() {
18
17
 
19
18
  const i18nInitObj = {
@@ -36,7 +35,6 @@ describe('handlebars-i18n Test', function() {
36
35
 
37
36
  const hI18n = HandlebarsI18n.init();
38
37
 
39
-
40
38
  // -- Tests for method init() -- //
41
39
 
42
40
  it('after method call init() should return an object (HandlebarsEnvironment)', function() {
@@ -116,7 +114,7 @@ describe('handlebars-i18n Test', function() {
116
114
  // -- Tests for function __ -- //
117
115
 
118
116
  it('expecting __ to throw error when called with no parameter', function() {
119
- expect(function() { hI18n.helpers.__() }).to.throw("Cannot read property 'hash' of undefined");
117
+ expect(function() { hI18n.helpers.__() }).to.throw();
120
118
  });
121
119
 
122
120
  it('function __ should return a SafeString object with property "string" where "string" returns the first argument given to __', function() {
package/.idea/.name DELETED
@@ -1 +0,0 @@
1
- handlebars-i18n
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$" />
5
- <orderEntry type="inheritedJdk" />
6
- <orderEntry type="sourceFolder" forTests="false" />
7
- </component>
8
- </module>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptLibraryMappings">
4
- <includedPredefinedLibrary name="ECMAScript 6" />
5
- </component>
6
- </project>
package/.idea/misc.xml DELETED
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectLevelVcsManager" settingsEditedManually="false">
4
- <OptionsSetting value="true" id="Add" />
5
- <OptionsSetting value="true" id="Remove" />
6
- <OptionsSetting value="true" id="Checkout" />
7
- <OptionsSetting value="true" id="Update" />
8
- <OptionsSetting value="true" id="Status" />
9
- <OptionsSetting value="true" id="Edit" />
10
- <ConfirmationsSetting value="0" id="Add" />
11
- <ConfirmationsSetting value="0" id="Remove" />
12
- </component>
13
- <component name="ProjectRootManager" version="2" />
14
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/handlebars-i18n.iml" filepath="$PROJECT_DIR$/.idea/handlebars-i18n.iml" />
6
- </modules>
7
- </component>
8
- </project>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectTasksOptions" suppressed-tasks="Traceur compiler;Babel" />
4
- </project>