handlebars-i18n 1.6.4 → 1.7.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.
- package/.github/workflows/ci.yml +15 -15
- package/.github/workflows/coveralls.yml +44 -0
- package/LICENSE +2 -1
- package/dist/handlebars-i18n.d.ts +187 -3
- package/dist/handlebars-i18n.js +229 -95
- package/dist/handlebars-i18n.min.js +1 -1
- package/examples/browser-example/index.html +109 -86
- package/examples/node-example/simple-example.js +89 -35
- package/examples/typescript/index.ts +11 -8
- package/examples/typescript/test.hbs +25 -7
- package/package.json +14 -9
- package/readme.md +136 -38
- package/test/handlebars-i18n.test.js +623 -185
package/.github/workflows/ci.yml
CHANGED
|
@@ -20,21 +20,21 @@ jobs:
|
|
|
20
20
|
run: |
|
|
21
21
|
npm i
|
|
22
22
|
npm run test
|
|
23
|
-
semantic-release:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
# semantic-release:
|
|
24
|
+
# if: github.ref == 'refs/heads/master'
|
|
25
|
+
# name: Semantic Release
|
|
26
|
+
# runs-on: ubuntu-latest
|
|
27
|
+
# needs: build
|
|
28
|
+
# steps:
|
|
29
|
+
# - uses: actions/checkout@v3
|
|
30
|
+
# with:
|
|
31
|
+
# token: ${{ secrets.GITHUB_TOKEN }}
|
|
32
|
+
# - name: Semantic Release
|
|
33
|
+
# uses: cycjimmy/semantic-release-action@v3
|
|
34
|
+
# with:
|
|
35
|
+
# extra_plugins: |
|
|
36
|
+
# @semantic-release/changelog
|
|
37
|
+
# @semantic-release/git
|
|
38
38
|
env:
|
|
39
39
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
40
40
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: Test and Coverage
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "master" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "master" ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
|
|
14
|
+
- uses: actions/checkout@v3
|
|
15
|
+
|
|
16
|
+
- name: Use Node.js 16.x
|
|
17
|
+
uses: actions/setup-node@v3
|
|
18
|
+
with:
|
|
19
|
+
node-version: 16.x
|
|
20
|
+
|
|
21
|
+
- name: npm install, make test-coverage
|
|
22
|
+
run: |
|
|
23
|
+
npm install
|
|
24
|
+
npm run test:coverage
|
|
25
|
+
sleep 2
|
|
26
|
+
|
|
27
|
+
- name: Report Coveralls (Linux)
|
|
28
|
+
if: startsWith(runner.os, 'Linux')
|
|
29
|
+
run: curl -sL https://coveralls.io/coveralls-linux.tar.gz | tar -xz && ./coveralls
|
|
30
|
+
env:
|
|
31
|
+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
32
|
+
|
|
33
|
+
- name: Report Coveralls (Windows)
|
|
34
|
+
if: startsWith(runner.os, 'Windows')
|
|
35
|
+
run: curl -sL https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-windows.zip | zcat > ./coveralls.exe && ./coveralls.exe
|
|
36
|
+
env:
|
|
37
|
+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
38
|
+
|
|
39
|
+
- name: Report Coveralls (macOS)
|
|
40
|
+
if: startsWith(runner.os, 'macOS')
|
|
41
|
+
run: |
|
|
42
|
+
brew tap coverallsapp/coveralls --quiet
|
|
43
|
+
brew install coveralls --quiet
|
|
44
|
+
coveralls
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
|
+
for handlebars-i18n
|
|
2
3
|
|
|
3
|
-
Copyright (c)
|
|
4
|
+
Copyright (c) 2020-24 Florian Walzel
|
|
4
5
|
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -5,17 +5,178 @@ type Handlebars = typeof handlebars;
|
|
|
5
5
|
|
|
6
6
|
type CustomFormatName = string;
|
|
7
7
|
|
|
8
|
+
type style = "decimal" | "currency" | "percent" | "unit";
|
|
9
|
+
|
|
10
|
+
type localeMatcher = "lookup" | "best fit";
|
|
11
|
+
|
|
12
|
+
type currencyDisplay = "code" | "symbol" | "narrowSymbol" | "name";
|
|
13
|
+
|
|
14
|
+
type currencySign = "standard" | "accounting";
|
|
15
|
+
|
|
16
|
+
type unitDisplay = "short" | "narrow" | "long";
|
|
17
|
+
|
|
18
|
+
type roundingPriority = "auto" | "morePrecision" | "lessPrecision";
|
|
19
|
+
|
|
20
|
+
type roundingMode =
|
|
21
|
+
"ceil"
|
|
22
|
+
| "floor"
|
|
23
|
+
| "expand"
|
|
24
|
+
| "trunc"
|
|
25
|
+
| "halfCeil"
|
|
26
|
+
| "halfFloor"
|
|
27
|
+
| "halfExpand"
|
|
28
|
+
| "halfTrunc"
|
|
29
|
+
| "halfEven";
|
|
30
|
+
|
|
31
|
+
type trailingZeroDisplay = "auto" | "stripIfInteger";
|
|
32
|
+
|
|
33
|
+
type notation = "standard" | "scientific" | "engineering" | "compact";
|
|
34
|
+
|
|
35
|
+
type compactDisplay = "short" | "long";
|
|
36
|
+
|
|
37
|
+
type useGrouping = "always" | "auto" | "min2" | true | false;
|
|
38
|
+
|
|
39
|
+
type signDisplay = "auto" | "always" | "exceptZero" | "negative" | "never";
|
|
40
|
+
|
|
41
|
+
type numberingSystem =
|
|
42
|
+
| "adlm"
|
|
43
|
+
| "ahom"
|
|
44
|
+
| "arab"
|
|
45
|
+
| "arabext"
|
|
46
|
+
| "armn"
|
|
47
|
+
| "armnlow"
|
|
48
|
+
| "bali"
|
|
49
|
+
| "beng"
|
|
50
|
+
| "bhks"
|
|
51
|
+
| "brah"
|
|
52
|
+
| "cakm"
|
|
53
|
+
| "cham"
|
|
54
|
+
| "cyrl"
|
|
55
|
+
| "deva"
|
|
56
|
+
| "diak"
|
|
57
|
+
| "ethi"
|
|
58
|
+
| "finance"
|
|
59
|
+
| "fullwide"
|
|
60
|
+
| "geor"
|
|
61
|
+
| "gonm"
|
|
62
|
+
| "grek"
|
|
63
|
+
| "greklow"
|
|
64
|
+
| "gujr"
|
|
65
|
+
| "guru"
|
|
66
|
+
| "hanidays"
|
|
67
|
+
| "hanidec"
|
|
68
|
+
| "hans"
|
|
69
|
+
| "hansfin"
|
|
70
|
+
| "hant"
|
|
71
|
+
| "hantfin"
|
|
72
|
+
| "hebr"
|
|
73
|
+
| "hmng"
|
|
74
|
+
| "hmnp"
|
|
75
|
+
| "java"
|
|
76
|
+
| "jpan"
|
|
77
|
+
| "jpanfin"
|
|
78
|
+
| "jpanyear"
|
|
79
|
+
| "kali"
|
|
80
|
+
| "knda"
|
|
81
|
+
| "lana"
|
|
82
|
+
| "lanatham"
|
|
83
|
+
| "laoo"
|
|
84
|
+
| "latn"
|
|
85
|
+
| "lepc"
|
|
86
|
+
| "limb"
|
|
87
|
+
| "mathbold"
|
|
88
|
+
| "mathdbl"
|
|
89
|
+
| "mathmono"
|
|
90
|
+
| "mathsanb"
|
|
91
|
+
| "mathsans"
|
|
92
|
+
| "mlym"
|
|
93
|
+
| "modi"
|
|
94
|
+
| "mong"
|
|
95
|
+
| "mroo"
|
|
96
|
+
| "mtei"
|
|
97
|
+
| "mymr"
|
|
98
|
+
| "mymrshan"
|
|
99
|
+
| "mymrtlng"
|
|
100
|
+
| "native"
|
|
101
|
+
| "newa"
|
|
102
|
+
| "nkoo"
|
|
103
|
+
| "olck"
|
|
104
|
+
| "orya"
|
|
105
|
+
| "osma"
|
|
106
|
+
| "rohg"
|
|
107
|
+
| "roman"
|
|
108
|
+
| "romanlow"
|
|
109
|
+
| "saur"
|
|
110
|
+
| "segment"
|
|
111
|
+
| "shrd"
|
|
112
|
+
| "sind"
|
|
113
|
+
| "sinh"
|
|
114
|
+
| "sora"
|
|
115
|
+
| "sund"
|
|
116
|
+
| "takr"
|
|
117
|
+
| "talu"
|
|
118
|
+
| "taml"
|
|
119
|
+
| "tamldec"
|
|
120
|
+
| "telu"
|
|
121
|
+
| "thai"
|
|
122
|
+
| "tibt"
|
|
123
|
+
| "tirh"
|
|
124
|
+
| "traditio"
|
|
125
|
+
| "vaii"
|
|
126
|
+
| "wara"
|
|
127
|
+
| "wcho";
|
|
128
|
+
|
|
129
|
+
|
|
8
130
|
export type NumberFormatConfiguration = [
|
|
9
131
|
"all" | LocaleCode | LanguageCode,
|
|
10
132
|
"NumberFormat",
|
|
11
|
-
{
|
|
133
|
+
{
|
|
134
|
+
localeMatcher?: localeMatcher,
|
|
135
|
+
style?: style,
|
|
136
|
+
numberingSystem?: numberingSystem,
|
|
137
|
+
unitDisplay?: unitDisplay,
|
|
138
|
+
roundingPriority?: roundingPriority,
|
|
139
|
+
roundingMode?: roundingMode,
|
|
140
|
+
trailingZeroDisplay?: trailingZeroDisplay,
|
|
141
|
+
notation?: notation;
|
|
142
|
+
compactDisplay?: compactDisplay,
|
|
143
|
+
useGrouping?: useGrouping,
|
|
144
|
+
signDisplay?: signDisplay,
|
|
145
|
+
minimumIntegerDigits?: number,
|
|
146
|
+
maximumFractionDigits?: number,
|
|
147
|
+
minimumFractionDigits?: number,
|
|
148
|
+
maximumSignificantDigits?: number,
|
|
149
|
+
minimumSignificantDigits?: number,
|
|
150
|
+
roundingIncrement?: number
|
|
151
|
+
},
|
|
12
152
|
CustomFormatName?
|
|
13
153
|
];
|
|
14
154
|
|
|
15
155
|
export type PriceFormatConfiguration = [
|
|
16
156
|
"all" | LocaleCode | LanguageCode,
|
|
17
157
|
"PriceFormat",
|
|
18
|
-
{
|
|
158
|
+
{
|
|
159
|
+
currency: CurrencyCode
|
|
160
|
+
currencyDisplay?: currencyDisplay,
|
|
161
|
+
currencySign?: currencySign,
|
|
162
|
+
localeMatcher?: localeMatcher,
|
|
163
|
+
style?: style,
|
|
164
|
+
numberingSystem?: numberingSystem,
|
|
165
|
+
unitDisplay?: unitDisplay,
|
|
166
|
+
roundingPriority?: roundingPriority,
|
|
167
|
+
roundingMode?: roundingMode,
|
|
168
|
+
trailingZeroDisplay?: trailingZeroDisplay,
|
|
169
|
+
notation?: notation;
|
|
170
|
+
compactDisplay?: compactDisplay,
|
|
171
|
+
useGrouping?: useGrouping,
|
|
172
|
+
signDisplay?: signDisplay,
|
|
173
|
+
minimumIntegerDigits?: number,
|
|
174
|
+
maximumFractionDigits?: number,
|
|
175
|
+
minimumFractionDigits?: number,
|
|
176
|
+
maximumSignificantDigits?: number,
|
|
177
|
+
minimumSignificantDigits?: number,
|
|
178
|
+
roundingIncrement?: number
|
|
179
|
+
},
|
|
19
180
|
CustomFormatName?
|
|
20
181
|
];
|
|
21
182
|
|
|
@@ -36,7 +197,24 @@ export type DateTimeFormatConfiguration = [
|
|
|
36
197
|
CustomFormatName?
|
|
37
198
|
];
|
|
38
199
|
|
|
39
|
-
type
|
|
200
|
+
type DateRelFormatOptions = {
|
|
201
|
+
localeMatcher?: localeMatcher,
|
|
202
|
+
numberingSystem?: numberingSystem,
|
|
203
|
+
numeric?: "always" | "auto",
|
|
204
|
+
style?: "long" | "short" | "narrow",
|
|
205
|
+
timeZone?: TimeZone,
|
|
206
|
+
unit?: "second" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year"
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export type RelativeTimeFormatConfiguration = [
|
|
210
|
+
"all" | LocaleCode | LanguageCode,
|
|
211
|
+
"RelativeTimeFormat",
|
|
212
|
+
DateRelFormatOptions,
|
|
213
|
+
CustomFormatName?
|
|
214
|
+
];
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
type Configuration = NumberFormatConfiguration | PriceFormatConfiguration | DateTimeFormatConfiguration | RelativeTimeFormatConfiguration;
|
|
40
218
|
|
|
41
219
|
export function init(overrideHndlbrs?: Handlebars, overrideI18n?: i18n.i18n): Handlebars;
|
|
42
220
|
export function reset(): true;
|
|
@@ -59,6 +237,12 @@ export function configure(
|
|
|
59
237
|
options: DateTimeFormatConfiguration[2],
|
|
60
238
|
customFormatname: DateTimeFormatConfiguration[3]
|
|
61
239
|
): boolean;
|
|
240
|
+
export function configure(
|
|
241
|
+
lang: RelativeTimeFormatConfiguration[0],
|
|
242
|
+
typeOfFormat: RelativeTimeFormatConfiguration[1],
|
|
243
|
+
options: RelativeTimeFormatConfiguration[2],
|
|
244
|
+
customFormatname: RelativeTimeFormatConfiguration[3]
|
|
245
|
+
): boolean;
|
|
62
246
|
|
|
63
247
|
// #region TimeZone type
|
|
64
248
|
export type TimeZone =
|