handlebars-i18n 1.6.0 → 1.6.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,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.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": {
@@ -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",
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "author": "Florian Walzel",
37
37
  "license": "MIT",
38
- "homepage": "https://github.com/fwalzel/handlebars-i18n.git#readme",
38
+ "homepage": "https://github.com/aller-couleur/handlebars-i18n.git#readme",
39
39
  "peerDependencies": {
40
40
  "handlebars": "^4.7.7",
41
41
  "i18next": "^21.6.14",
package/readme.md CHANGED
@@ -2,7 +2,7 @@
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
8
  [![Build Status](https://travis-ci.org/fwalzel/handlebars-i18n.svg?branch=master)](https://travis-ci.org/fwalzel/handlebars-i18n)
@@ -52,6 +52,13 @@ Usage in web browser:
52
52
  </script>
53
53
  ```
54
54
 
55
+ With ES6 import syntax:
56
+
57
+ ```typescript
58
+ import * as HandlebarsI18n from "handlebars-i18n";
59
+ HandlebarsI18n.init();
60
+ ```
61
+
55
62
  ## Quick example
56
63
 
57
64
  Initialize i18next with your language strings and default settings: