@stamhoofd/backend-i18n 2.1.3 → 2.10.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.
- package/dist/I18n.d.ts +26 -0
- package/dist/I18n.d.ts.map +1 -0
- package/dist/I18n.js +178 -0
- package/dist/I18n.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +4 -4
package/dist/I18n.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DecodedRequest, Request } from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Country } from '@stamhoofd/structures';
|
|
3
|
+
export declare class I18n {
|
|
4
|
+
static loadedLocales: Map<string, Map<string, string>>;
|
|
5
|
+
static defaultLanguage: string;
|
|
6
|
+
static defaultCountry: Country;
|
|
7
|
+
static load(): Promise<void>;
|
|
8
|
+
static loadRecursive(messages: any, prefix?: string | null): Map<string, string>;
|
|
9
|
+
static isValidLocale(locale: string): boolean;
|
|
10
|
+
language: string;
|
|
11
|
+
country: string;
|
|
12
|
+
messages: Map<string, string>;
|
|
13
|
+
get locale(): string;
|
|
14
|
+
constructor(language: string, country: string);
|
|
15
|
+
correctLanguageCountryCombination(): void;
|
|
16
|
+
switchToLocale(options: {
|
|
17
|
+
language?: string;
|
|
18
|
+
country?: string;
|
|
19
|
+
}): void;
|
|
20
|
+
static fromRequest(request: Request | DecodedRequest<any, any, any>): I18n;
|
|
21
|
+
t(key: string, replace?: Record<string, string>): string;
|
|
22
|
+
$t(key: string, replace?: Record<string, string>): string;
|
|
23
|
+
escapeRegex(string: any): any;
|
|
24
|
+
replace(text: string, replace?: Record<string, string>): string;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=I18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18n.d.ts","sourceRoot":"","sources":["../src/I18n.ts"],"names":[],"mappings":"AAAA,OAA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|
package/dist/I18n.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.I18n = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const locales_1 = require("@stamhoofd/locales");
|
|
7
|
+
const structures_1 = require("@stamhoofd/structures");
|
|
8
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
|
+
const simple_logging_1 = require("@simonbackx/simple-logging");
|
|
10
|
+
class I18n {
|
|
11
|
+
static async load() {
|
|
12
|
+
await simple_logging_1.logger.setContext({
|
|
13
|
+
prefixes: [
|
|
14
|
+
new simple_logging_1.StyledText('[I18n] ').addClass('i18n', 'tag')
|
|
15
|
+
],
|
|
16
|
+
tags: ['i18n']
|
|
17
|
+
}, async () => {
|
|
18
|
+
console.log("Loading locales...");
|
|
19
|
+
const directory = path_1.default.dirname(require.resolve("@stamhoofd/locales")) + "/" + STAMHOOFD.translationNamespace;
|
|
20
|
+
const files = (await fs_1.promises.readdir(directory, { withFileTypes: true }))
|
|
21
|
+
.filter((dirent) => !dirent.isDirectory());
|
|
22
|
+
for (const file of files) {
|
|
23
|
+
const locale = file.name.substr(0, file.name.length - 5);
|
|
24
|
+
console.log("Loaded:" + locale);
|
|
25
|
+
const messages = await Promise.resolve(`${directory + "/" + file.name}`).then(s => tslib_1.__importStar(require(s)));
|
|
26
|
+
this.loadedLocales.set(locale, this.loadRecursive(messages.default));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
static loadRecursive(messages, prefix = null) {
|
|
31
|
+
const map = new Map();
|
|
32
|
+
for (const key in messages) {
|
|
33
|
+
const element = messages[key];
|
|
34
|
+
if (typeof (element) != "string") {
|
|
35
|
+
const map2 = this.loadRecursive(element, (prefix ? prefix + "." : "") + key);
|
|
36
|
+
map2.forEach((val, key) => map.set(key, val));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
map.set((prefix ? prefix + "." : "") + key, element);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return map;
|
|
43
|
+
}
|
|
44
|
+
static isValidLocale(locale) {
|
|
45
|
+
if (locale.length == 5 && locale.substr(2, 1) == "-") {
|
|
46
|
+
const l = locale.substr(0, 2).toLowerCase();
|
|
47
|
+
const c = locale.substr(3, 2).toUpperCase();
|
|
48
|
+
return locales_1.languages.includes(l) && locales_1.countries.includes(c);
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
get locale() {
|
|
53
|
+
return this.language + "-" + this.country;
|
|
54
|
+
}
|
|
55
|
+
constructor(language, country) {
|
|
56
|
+
this.language = "";
|
|
57
|
+
this.country = "";
|
|
58
|
+
this.language = language;
|
|
59
|
+
this.country = country;
|
|
60
|
+
this.correctLanguageCountryCombination();
|
|
61
|
+
const m = I18n.loadedLocales.get(this.locale);
|
|
62
|
+
if (!m) {
|
|
63
|
+
throw new Error("Locale not loaded when creating I18n for " + language + "-" + country);
|
|
64
|
+
}
|
|
65
|
+
this.messages = m;
|
|
66
|
+
}
|
|
67
|
+
correctLanguageCountryCombination() {
|
|
68
|
+
if (I18n.isValidLocale(this.locale)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Check language is valid
|
|
72
|
+
if (!locales_1.languages.includes(this.language)) {
|
|
73
|
+
this.language = I18n.defaultLanguage;
|
|
74
|
+
if (I18n.isValidLocale(this.locale)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.country = I18n.defaultCountry;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Loop countries until valid
|
|
81
|
+
this.country = I18n.defaultCountry;
|
|
82
|
+
while (!I18n.isValidLocale(this.locale)) {
|
|
83
|
+
const index = locales_1.countries.indexOf(this.country);
|
|
84
|
+
if (index == locales_1.countries.length - 1) {
|
|
85
|
+
// Last country
|
|
86
|
+
this.language = I18n.defaultLanguage;
|
|
87
|
+
this.country = I18n.defaultCountry;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this.country = locales_1.countries[index + 1];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
switchToLocale(options) {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
this.country = (_a = options.country) !== null && _a !== void 0 ? _a : this.country;
|
|
96
|
+
this.language = (_b = options.language) !== null && _b !== void 0 ? _b : this.language;
|
|
97
|
+
this.correctLanguageCountryCombination();
|
|
98
|
+
const m = I18n.loadedLocales.get(this.locale);
|
|
99
|
+
if (!m) {
|
|
100
|
+
throw new Error("Locale not loaded, when switching to locale " + this.language + "-" + this.country);
|
|
101
|
+
}
|
|
102
|
+
this.messages = m;
|
|
103
|
+
}
|
|
104
|
+
static fromRequest(request) {
|
|
105
|
+
if (request._cached_i18n) {
|
|
106
|
+
return request._cached_i18n;
|
|
107
|
+
}
|
|
108
|
+
// Try using custom property
|
|
109
|
+
const localeHeader = request.headers["x-locale"];
|
|
110
|
+
if (localeHeader && typeof localeHeader === "string" && this.isValidLocale(localeHeader)) {
|
|
111
|
+
const l = localeHeader.substr(0, 2).toLowerCase();
|
|
112
|
+
const c = localeHeader.substr(3, 2).toUpperCase();
|
|
113
|
+
const i18n = new I18n(l, c);
|
|
114
|
+
request._cached_i18n = i18n;
|
|
115
|
+
return i18n;
|
|
116
|
+
}
|
|
117
|
+
// Try using accept-language defaults
|
|
118
|
+
const acceptLanguage = request.headers["accept-language"];
|
|
119
|
+
if (acceptLanguage) {
|
|
120
|
+
const splitted = acceptLanguage.split(",");
|
|
121
|
+
// Loop all countries and languages in the header, until we find a valid one
|
|
122
|
+
for (const item of splitted) {
|
|
123
|
+
const trimmed = item.trim();
|
|
124
|
+
const localeSplit = trimmed.split(";");
|
|
125
|
+
const locale = localeSplit[0];
|
|
126
|
+
if (locale.length == 2) {
|
|
127
|
+
// Language
|
|
128
|
+
if (locales_1.languages.includes(locale)) {
|
|
129
|
+
// Use a default country
|
|
130
|
+
// Country can get overriden when matching a organization
|
|
131
|
+
// using .setCountry(country) method
|
|
132
|
+
const i18n = new I18n(locale, structures_1.Country.Belgium);
|
|
133
|
+
request._cached_i18n = i18n;
|
|
134
|
+
return i18n;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (locale.length === 5 && this.isValidLocale(locale)) {
|
|
138
|
+
const l = locale.substr(0, 2).toLowerCase();
|
|
139
|
+
const c = locale.substr(3, 2).toUpperCase();
|
|
140
|
+
// Lang + country
|
|
141
|
+
const i18n = new I18n(l, c);
|
|
142
|
+
request._cached_i18n = i18n;
|
|
143
|
+
return i18n;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const i18n = new I18n(this.defaultLanguage, this.defaultCountry);
|
|
148
|
+
request._cached_i18n = i18n;
|
|
149
|
+
return i18n;
|
|
150
|
+
}
|
|
151
|
+
t(key, replace) {
|
|
152
|
+
return this.$t(key, replace);
|
|
153
|
+
}
|
|
154
|
+
$t(key, replace) {
|
|
155
|
+
var _a;
|
|
156
|
+
return this.replace((_a = this.messages.get(key)) !== null && _a !== void 0 ? _a : key, replace);
|
|
157
|
+
}
|
|
158
|
+
escapeRegex(string) {
|
|
159
|
+
return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
160
|
+
}
|
|
161
|
+
replace(text, replace) {
|
|
162
|
+
if (!replace) {
|
|
163
|
+
return text;
|
|
164
|
+
}
|
|
165
|
+
for (const key in replace) {
|
|
166
|
+
if (replace.hasOwnProperty(key)) {
|
|
167
|
+
const value = replace[key];
|
|
168
|
+
text = text.replace(new RegExp("{" + this.escapeRegex(key) + "}", "g"), value);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return text;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.I18n = I18n;
|
|
175
|
+
I18n.loadedLocales = new Map();
|
|
176
|
+
I18n.defaultLanguage = "nl";
|
|
177
|
+
I18n.defaultCountry = structures_1.Country.Belgium;
|
|
178
|
+
//# sourceMappingURL=I18n.js.map
|
package/dist/I18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18n.js","sourceRoot":"","sources":["../src/I18n.ts"],"names":[],"mappings":";;;;AACA,2BAAoC;AACpC,gDAAyD;AACzD,sDAAgD;AAChD,wDAAuB;AACvB,+DAA8D;AAE9D,MAAa,IAAI;IAKb,MAAM,CAAC,KAAK,CAAC,IAAI;QACb,MAAM,uBAAM,CAAC,UAAU,CAAC;YACpB,QAAQ,EAAE;gBACN,IAAI,2BAAU,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;aACpD;YACD,IAAI,EAAE,CAAC,MAAM,CAAC;SACjB,EAAE,KAAK,IAAI,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;YACjC,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,GAAC,GAAG,GAAG,SAAS,CAAC,oBAAoB,CAAA;YAC1G,MAAM,KAAK,GAAG,CAAC,MAAM,aAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;iBAC/D,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;YAE9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAG,CAAC;gBACxB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBACzD,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,CAAA;gBAE/B,MAAM,QAAQ,GAAG,yBAAa,SAAS,GAAC,GAAG,GAAC,IAA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C,OAAO,EAAE,CAAC;YACX,OAAO,IAAI,CAAA;QACf,CAAC;QACD,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YACxB,IAAI,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;gBAC3B,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,GAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAC,GAAG,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;YAC9E,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAA;IACf,CAAC;;AArML,oBAsMC;AArMU,kBAAa,GAAqC,IAAI,GAAG,EAAE,AAA9C,CAA8C;AAC3D,oBAAe,GAAG,IAAI,AAAP,CAAO;AACtB,mBAAc,GAAG,oBAAO,CAAC,OAAO,AAAlB,CAAkB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { I18n } from "./I18n";
|
|
2
|
+
export * from "./I18n";
|
|
3
|
+
declare module '@simonbackx/simple-endpoints/dist/src/DecodedRequest' {
|
|
4
|
+
interface DecodedRequest<Params, Query, Body> {
|
|
5
|
+
get i18n(): I18n;
|
|
6
|
+
$t(key: string, replace?: Record<string, string>): string;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,cAAc,QAAQ,CAAA;AAGtB,OAAO,QAAQ,sDAAsD,CAAC;IAElE,UAAU,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI;QACxC,IAAI,IAAI,IAAI,IAAI,CAAA;QAChB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;KAC5D;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yFAAsF;AACtF,iCAA8B;AAE9B,iDAAsB;AAWtB,MAAM,CAAC,cAAc,CAAC,+BAAc,CAAC,SAAS,EAAE,MAAM,EAAE;IACpD,GAAG;QACC,OAAO,WAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IACjC,CAAC;CACJ,CAAC,CAAA;AAEF,+BAAc,CAAC,SAAS,CAAC,EAAE,GAAG,UAAyE,GAAW,EAAE,OAAgC;IAChJ,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;AACrC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend-i18n",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.2",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"license": "UNLICENCED",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"files": [
|
|
9
|
+
"dist",
|
|
9
10
|
"src"
|
|
10
11
|
],
|
|
11
12
|
"scripts": {
|
|
12
|
-
"build": "tsc -b"
|
|
13
|
-
"build:full": "rm -rf ./dist && yarn build"
|
|
13
|
+
"build": "tsc -b"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@simonbackx/simple-endpoints": "*"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "07413822cace1cd39c94c24b8ebef2dda9a89ff9"
|
|
19
19
|
}
|