@vendure/core 3.6.5-master-202606100308 → 3.6.5-master-202606130308
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.
|
@@ -31,6 +31,13 @@ export interface I18nRequest extends Request {
|
|
|
31
31
|
*/
|
|
32
32
|
export declare class I18nService implements OnModuleInit {
|
|
33
33
|
private configService;
|
|
34
|
+
/**
|
|
35
|
+
* The set of language codes we have translation resources for. Used as the i18next
|
|
36
|
+
* `supportedLngs` allow-list. Without this, `i18next-http-middleware` appends every
|
|
37
|
+
* distinct request language code to `options.preload` forever, which is then re-walked
|
|
38
|
+
* (via `Intl.getCanonicalLocales`) on every request — degrading performance over time.
|
|
39
|
+
*/
|
|
40
|
+
private readonly supportedLanguages;
|
|
34
41
|
/**
|
|
35
42
|
* @internal
|
|
36
43
|
* @param configService
|
|
@@ -40,6 +47,19 @@ export declare class I18nService implements OnModuleInit {
|
|
|
40
47
|
* @internal
|
|
41
48
|
*/
|
|
42
49
|
onModuleInit(): Promise<TFunction<"translation", undefined>>;
|
|
50
|
+
/**
|
|
51
|
+
* Reads the language codes for which we ship message files, derived from the filenames
|
|
52
|
+
* in the `messages` directory (e.g. `en.json` -> `en`, `pt_BR.json` -> `pt_BR`). Falls
|
|
53
|
+
* back to a static list if the directory cannot be read.
|
|
54
|
+
*/
|
|
55
|
+
private getBundledLanguageCodes;
|
|
56
|
+
/**
|
|
57
|
+
* Registers a language code as supported, extending the i18next `supportedLngs` allow-list
|
|
58
|
+
* at runtime. Needed because plugins may add translations for new languages after init via
|
|
59
|
+
* {@link addTranslation}. `supportedLngs` is cached inside i18next's `languageUtils` at init
|
|
60
|
+
* time, so both the cached copy and `options` must be updated for the change to take effect.
|
|
61
|
+
*/
|
|
62
|
+
private registerSupportedLanguage;
|
|
43
63
|
/**
|
|
44
64
|
* @internal
|
|
45
65
|
*/
|
|
@@ -73,18 +73,29 @@ let I18nService = class I18nService {
|
|
|
73
73
|
*/
|
|
74
74
|
constructor(configService) {
|
|
75
75
|
this.configService = configService;
|
|
76
|
+
/**
|
|
77
|
+
* The set of language codes we have translation resources for. Used as the i18next
|
|
78
|
+
* `supportedLngs` allow-list. Without this, `i18next-http-middleware` appends every
|
|
79
|
+
* distinct request language code to `options.preload` forever, which is then re-walked
|
|
80
|
+
* (via `Intl.getCanonicalLocales`) on every request — degrading performance over time.
|
|
81
|
+
*/
|
|
82
|
+
this.supportedLanguages = new Set();
|
|
76
83
|
}
|
|
77
84
|
/**
|
|
78
85
|
* @internal
|
|
79
86
|
*/
|
|
80
87
|
onModuleInit() {
|
|
88
|
+
for (const langKey of this.getBundledLanguageCodes()) {
|
|
89
|
+
this.supportedLanguages.add(langKey);
|
|
90
|
+
}
|
|
81
91
|
return i18next_1.default
|
|
82
92
|
.use(i18next_http_middleware_1.default.LanguageDetector)
|
|
83
93
|
.use(i18next_fs_backend_1.default)
|
|
84
94
|
.use(i18next_icu_1.default)
|
|
85
95
|
.init({
|
|
86
96
|
nsSeparator: false,
|
|
87
|
-
preload:
|
|
97
|
+
preload: Array.from(this.supportedLanguages),
|
|
98
|
+
supportedLngs: Array.from(this.supportedLanguages),
|
|
88
99
|
fallbackLng: 'en',
|
|
89
100
|
detection: {
|
|
90
101
|
lookupQuerystring: 'languageCode',
|
|
@@ -95,6 +106,45 @@ let I18nService = class I18nService {
|
|
|
95
106
|
},
|
|
96
107
|
});
|
|
97
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Reads the language codes for which we ship message files, derived from the filenames
|
|
111
|
+
* in the `messages` directory (e.g. `en.json` -> `en`, `pt_BR.json` -> `pt_BR`). Falls
|
|
112
|
+
* back to a static list if the directory cannot be read.
|
|
113
|
+
*/
|
|
114
|
+
getBundledLanguageCodes() {
|
|
115
|
+
const fallback = ['en', 'de', 'es', 'fr', 'pt_BR', 'pt_PT', 'ru', 'uk'];
|
|
116
|
+
try {
|
|
117
|
+
const messagesDir = path_1.default.join(__dirname, 'messages');
|
|
118
|
+
const codes = fs
|
|
119
|
+
.readdirSync(messagesDir)
|
|
120
|
+
.filter(file => file.endsWith('.json'))
|
|
121
|
+
.map(file => path_1.default.basename(file, '.json'));
|
|
122
|
+
return codes.length ? codes : fallback;
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
config_1.Logger.warn(`Could not read i18n messages directory, falling back to default language list: ${e.message}`, 'I18nService');
|
|
126
|
+
return fallback;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Registers a language code as supported, extending the i18next `supportedLngs` allow-list
|
|
131
|
+
* at runtime. Needed because plugins may add translations for new languages after init via
|
|
132
|
+
* {@link addTranslation}. `supportedLngs` is cached inside i18next's `languageUtils` at init
|
|
133
|
+
* time, so both the cached copy and `options` must be updated for the change to take effect.
|
|
134
|
+
*/
|
|
135
|
+
registerSupportedLanguage(langKey) {
|
|
136
|
+
var _a;
|
|
137
|
+
if (this.supportedLanguages.has(langKey)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.supportedLanguages.add(langKey);
|
|
141
|
+
const supportedLngs = [...this.supportedLanguages, 'cimode'];
|
|
142
|
+
i18next_1.default.options.supportedLngs = supportedLngs;
|
|
143
|
+
const languageUtils = (_a = i18next_1.default.services) === null || _a === void 0 ? void 0 : _a.languageUtils;
|
|
144
|
+
if (languageUtils) {
|
|
145
|
+
languageUtils.supportedLngs = supportedLngs;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
98
148
|
/**
|
|
99
149
|
* @internal
|
|
100
150
|
*/
|
|
@@ -128,6 +178,7 @@ let I18nService = class I18nService {
|
|
|
128
178
|
* @param resources key-value translations
|
|
129
179
|
*/
|
|
130
180
|
addTranslation(langKey, resources) {
|
|
181
|
+
this.registerSupportedLanguage(langKey);
|
|
131
182
|
i18next_1.default.addResourceBundle(langKey, 'translation', resources, true, true);
|
|
132
183
|
}
|
|
133
184
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.service.js","sourceRoot":"","sources":["../../src/i18n/i18n.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0D;AAE1D,uCAAyB;AAEzB,sDAA6C;AAC7C,4EAAyC;AACzC,sFAAwD;AACxD,8DAA8B;AAC9B,gDAAwB;AAGxB,sCAAmC;AACnC,6DAAyD;AAEzD,6CAAyC;AAmBzC;;;;;;;;;GASG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAW;
|
|
1
|
+
{"version":3,"file":"i18n.service.js","sourceRoot":"","sources":["../../src/i18n/i18n.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0D;AAE1D,uCAAyB;AAEzB,sDAA6C;AAC7C,4EAAyC;AACzC,sFAAwD;AACxD,8DAA8B;AAC9B,gDAAwB;AAGxB,sCAAmC;AACnC,6DAAyD;AAEzD,6CAAyC;AAmBzC;;;;;;;;;GASG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAW;IASpB;;;OAGG;IACH,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAZhD;;;;;WAKG;QACc,uBAAkB,GAAG,IAAI,GAAG,EAAU,CAAC;IAML,CAAC;IAEpD;;OAEG;IACH,YAAY;QACR,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC;YACnD,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,iBAAO;aACT,GAAG,CAAC,iCAAiB,CAAC,gBAAgB,CAAC;aACvC,GAAG,CAAC,4BAAc,CAAC;aACnB,GAAG,CAAC,qBAAG,CAAC;aACR,IAAI,CAAC;YACF,WAAW,EAAE,KAAK;YAClB,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC;YAC5C,a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K,CAAC,OAAO,GAAG,WAAW,CAAC;IAChC,CAAC;CACJ,CAAA;AAnKY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAc0B,8BAAa;GAbvC,WAAW,CAmKvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure/core",
|
|
3
|
-
"version": "3.6.5-master-
|
|
3
|
+
"version": "3.6.5-master-202606130308",
|
|
4
4
|
"description": "A modern, headless ecommerce framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@nestjs/platform-express": "^11.0.12",
|
|
50
50
|
"@nestjs/terminus": "^11.0.0",
|
|
51
51
|
"@nestjs/typeorm": "^11.0.0",
|
|
52
|
-
"@vendure/common": "^3.6.5-master-
|
|
52
|
+
"@vendure/common": "^3.6.5-master-202606130308",
|
|
53
53
|
"bcrypt": "^6.0.0",
|
|
54
54
|
"body-parser": "^1.20.2",
|
|
55
55
|
"cookie-session": "^2.1.0",
|