handlebars-i18n 1.6.0 → 1.6.2

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.
@@ -0,0 +1,30 @@
1
+ # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3
+
4
+ name: Node.js CI
5
+
6
+ on:
7
+ push:
8
+ branches: [ "master" ]
9
+ pull_request:
10
+ branches: [ "master" ]
11
+
12
+ jobs:
13
+ build:
14
+
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ matrix:
19
+ node-version: [14.x, 16.x, 18.x]
20
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21
+
22
+ steps:
23
+ - uses: actions/checkout@v3
24
+ - name: Use Node.js ${{ matrix.node-version }}
25
+ uses: actions/setup-node@v3
26
+ with:
27
+ node-version: ${{ matrix.node-version }}
28
+ cache: 'npm'
29
+ - run: npm ci
30
+ - run: npm run build --if-present
@@ -1,5 +1,5 @@
1
1
  import * as handlebars from "handlebars";
2
- import type { i18n } from "i18next";
2
+ import * as i18n from "i18next";
3
3
 
4
4
  type Handlebars = typeof handlebars;
5
5
 
@@ -38,7 +38,7 @@ export type DateTimeFormatConfiguration = [
38
38
 
39
39
  type Configuration = NumberFormatConfiguration | PriceFormatConfiguration | DateTimeFormatConfiguration;
40
40
 
41
- export function init(overrideHndlbrs?: Handlebars, overrideI18n?: i18n): Handlebars;
41
+ export function init(overrideHndlbrs?: Handlebars, overrideI18n?: i18n.i18n): Handlebars;
42
42
  export function reset(): true;
43
43
  export function configure(configArray: Configuration[]): boolean;
44
44
  export function configure(
@@ -16,7 +16,8 @@ import { readFileSync } from "fs";
16
16
 
17
17
 
18
18
  // -- The translation phrases for i18next
19
- i18next
19
+ const myI18nInstance = i18next.createInstance();
20
+ myI18nInstance
20
21
  .init({
21
22
  resources: {
22
23
  "en-GB": {
@@ -55,8 +56,11 @@ const data = {
55
56
  myDate: "2020-03-11T03:24:00"
56
57
  };
57
58
 
59
+
60
+ const myHandlebarsInstance = handlebars.create();
61
+
58
62
  // -- Init and configure handlebars-i18n
59
- HandlebarsI18n.init();
63
+ HandlebarsI18n.init(myHandlebarsInstance, myI18nInstance);
60
64
 
61
65
  HandlebarsI18n.configure([
62
66
  // generic configuration for all languages for number representation:
@@ -80,7 +84,7 @@ HandlebarsI18n.configure([
80
84
  ]);
81
85
 
82
86
  const template = readFileSync(__dirname + "/test.hbs", { encoding: "utf-8" });
83
- const compiled = handlebars.compile(template);
84
- i18next.changeLanguage("de-DE"); // --> Test the changes by replacing "de-DE" with "en-GB"
87
+ const compiled = myHandlebarsInstance.compile(template);
88
+ myI18nInstance.changeLanguage("de-DE"); // --> Test the changes by replacing "de-DE" with "en-GB"
85
89
 
86
90
  console.log("\x1b[36m%s\x1b[0m", compiled(data));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "handlebars-i18n",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "handlebars-i18n adds internationlization to handlebars.js using i18next and Intl",
5
5
  "main": "dist/handlebars-i18n.js",
6
6
  "scripts": {
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "git+https://github.com/fwalzel/handlebars-i18n.git"
17
+ "url": "https://github.com/aller-couleur/handlebars-i18n.git"
18
18
  },
19
19
  "keywords": [
20
20
  "handlebars-i18n",
@@ -31,18 +31,19 @@
31
31
  "i18n",
32
32
  "Intl",
33
33
  "Helper",
34
+ "Typescript",
34
35
  "handlebars-i18next"
35
36
  ],
36
37
  "author": "Florian Walzel",
37
38
  "license": "MIT",
38
- "homepage": "https://github.com/fwalzel/handlebars-i18n.git#readme",
39
+ "homepage": "https://github.com/aller-couleur/handlebars-i18n.git#readme",
39
40
  "peerDependencies": {
40
41
  "handlebars": "^4.7.7",
41
42
  "i18next": "^21.6.14",
42
43
  "intl": "^1.2.5"
43
44
  },
44
45
  "devDependencies": {
45
- "@commitlint/cli": "16.2.3",
46
+ "@commitlint/cli": "17.6.1",
46
47
  "@commitlint/config-conventional": "16.2.1",
47
48
  "@types/intl": "^1.2.0",
48
49
  "@types/node": "^18.13.0",
package/readme.md CHANGED
@@ -2,12 +2,13 @@
2
2
 
3
3
  `handlebars-i18n` adds the internationalization features of [i18next](https://www.i18next.com/) to [handlebars.js](https://handlebarsjs.com/). It also provides **date**, **number**, and **currency formatting** via [Intl](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Intl). Use as node module or in the web browser.
4
4
 
5
- Handlebars-i18n is listed amongst i18next’s [framework helpers](https://www.i18next.com/overview/supported-frameworks). Now supports Typescript thanks to [@DiefBell](DiefBell).
5
+ Handlebars-i18n is listed amongst i18next’s [framework helpers](https://www.i18next.com/overview/supported-frameworks). Now supports Typescript thanks to [@DiefBell](https://github.com/DiefBell).
6
6
 
7
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)
8
+ ![Node.js Version](https://img.shields.io/badge/Node.js-14.x-green)
9
+ [![Build](https://github.com/fwalzel/handlebars-i18n/actions/workflows/node.js.yml/badge.svg)](https://github.com/fwalzel/handlebars-i18n/actions/workflows/node.js.yml/badge.svg)
9
10
  [![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
+ [![Code Climate](https://codeclimate.com/github/Aller-Couleur/handlebars-i18n/badges/gpa.svg)](https://codeclimate.com/github/Aller-Couleur/handlebars-i18n)
11
12
  [![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
13
  ![npm](https://img.shields.io/npm/dm/handlebars-i18n)
13
14
 
@@ -52,6 +53,13 @@ Usage in web browser:
52
53
  </script>
53
54
  ```
54
55
 
56
+ With ES6 import syntax:
57
+
58
+ ```typescript
59
+ import * as HandlebarsI18n from "handlebars-i18n";
60
+ HandlebarsI18n.init();
61
+ ```
62
+
55
63
  ## Quick example
56
64
 
57
65
  Initialize i18next with your language strings and default settings: