@n8n/i18n 1.1.0

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/index.js ADDED
@@ -0,0 +1,351 @@
1
+ import "./chunk-55J6XMHW.js";
2
+ import {
3
+ deriveMiddleKey,
4
+ insertOptionsAndValues,
5
+ isNestedInCollectionLike,
6
+ normalize
7
+ } from "./chunk-NITZKE2M.js";
8
+ import {
9
+ en_default
10
+ } from "./chunk-RS3BJEPE.js";
11
+ import {
12
+ __glob
13
+ } from "./chunk-QKQ47GQZ.js";
14
+
15
+ // src/index.ts
16
+ import { createI18n } from "vue-i18n";
17
+
18
+ // import("./locales/**/*.json") in src/index.ts
19
+ var globImport_locales_json = __glob({
20
+ "./locales/en.json": () => import("./en-NYQRJQJM.js")
21
+ });
22
+
23
+ // src/index.ts
24
+ var i18nInstance = createI18n({
25
+ locale: "en",
26
+ fallbackLocale: "en",
27
+ messages: { en: en_default },
28
+ warnHtmlInMessage: "off"
29
+ });
30
+ var I18nClass = class {
31
+ baseTextCache = /* @__PURE__ */ new Map();
32
+ get i18n() {
33
+ return i18nInstance.global;
34
+ }
35
+ // ----------------------------------
36
+ // helper methods
37
+ // ----------------------------------
38
+ exists(key) {
39
+ return this.i18n.te(key);
40
+ }
41
+ shortNodeType(longNodeType) {
42
+ return longNodeType.replace("n8n-nodes-base.", "");
43
+ }
44
+ get locale() {
45
+ return i18nInstance.global.locale;
46
+ }
47
+ // ----------------------------------
48
+ // render methods
49
+ // ----------------------------------
50
+ /**
51
+ * Render a string of base text, i.e. a string with a fixed path to the localized value. Optionally allows for [interpolation](https://kazupon.github.io/vue-i18n/guide/formatting.html#named-formatting) when the localized value contains a string between curly braces.
52
+ */
53
+ baseText(key, options) {
54
+ const cacheKey = `${key}-${JSON.stringify(options)}`;
55
+ if (this.baseTextCache.has(cacheKey)) {
56
+ return this.baseTextCache.get(cacheKey) ?? key;
57
+ }
58
+ const interpolate = { ...options?.interpolate };
59
+ let result;
60
+ if (options?.adjustToNumber !== void 0) {
61
+ result = this.i18n.t(key, interpolate, options.adjustToNumber).toString();
62
+ } else {
63
+ result = this.i18n.t(key, interpolate).toString();
64
+ }
65
+ this.baseTextCache.set(cacheKey, result);
66
+ return result;
67
+ }
68
+ /**
69
+ * Render a string of dynamic text, i.e. a string with a constructed path to the localized value.
70
+ */
71
+ dynamicRender({ key, fallback }) {
72
+ return this.i18n.te(key) ? this.i18n.t(key).toString() : fallback ?? "";
73
+ }
74
+ displayTimer(msPassed, showMs = false) {
75
+ if (msPassed < 6e4) {
76
+ if (!showMs) {
77
+ return `${Math.floor(msPassed / 1e3)}${this.baseText("genericHelpers.secShort")}`;
78
+ }
79
+ if (msPassed > 0 && msPassed < 1e3) {
80
+ return `${msPassed}${this.baseText("genericHelpers.millis")}`;
81
+ }
82
+ return `${msPassed / 1e3}${this.baseText("genericHelpers.secShort")}`;
83
+ }
84
+ const secondsPassed = Math.floor(msPassed / 1e3);
85
+ const minutesPassed = Math.floor(secondsPassed / 60);
86
+ const secondsLeft = (secondsPassed - minutesPassed * 60).toString().padStart(2, "0");
87
+ return `${minutesPassed}:${secondsLeft}${this.baseText("genericHelpers.minShort")}`;
88
+ }
89
+ /**
90
+ * Render a string of header text (a node's name and description),
91
+ * used variously in the nodes panel, under the node icon, etc.
92
+ */
93
+ headerText(arg) {
94
+ return this.dynamicRender(arg);
95
+ }
96
+ /**
97
+ * Namespace for methods to render text in the credentials details modal.
98
+ */
99
+ credText(credentialType) {
100
+ const credentialPrefix = `n8n-nodes-base.credentials.${credentialType}`;
101
+ const context = this;
102
+ return {
103
+ /**
104
+ * Display name for a top-level param.
105
+ */
106
+ inputLabelDisplayName({ name: parameterName, displayName }) {
107
+ if (["clientId", "clientSecret"].includes(parameterName)) {
108
+ return context.dynamicRender({
109
+ key: `_reusableDynamicText.oauth2.${parameterName}`,
110
+ fallback: displayName
111
+ });
112
+ }
113
+ return context.dynamicRender({
114
+ key: `${credentialPrefix}.${parameterName}.displayName`,
115
+ fallback: displayName
116
+ });
117
+ },
118
+ /**
119
+ * Hint for a top-level param.
120
+ */
121
+ hint({ name: parameterName, hint }) {
122
+ return context.dynamicRender({
123
+ key: `${credentialPrefix}.${parameterName}.hint`,
124
+ fallback: hint
125
+ });
126
+ },
127
+ /**
128
+ * Description (tooltip text) for an input label param.
129
+ */
130
+ inputLabelDescription({ name: parameterName, description }) {
131
+ return context.dynamicRender({
132
+ key: `${credentialPrefix}.${parameterName}.description`,
133
+ fallback: description
134
+ });
135
+ },
136
+ /**
137
+ * Display name for an option inside an `options` or `multiOptions` param.
138
+ */
139
+ optionsOptionDisplayName({ name: parameterName }, { value: optionName, name: displayName }) {
140
+ return context.dynamicRender({
141
+ key: `${credentialPrefix}.${parameterName}.options.${optionName}.displayName`,
142
+ fallback: displayName
143
+ });
144
+ },
145
+ /**
146
+ * Description for an option inside an `options` or `multiOptions` param.
147
+ */
148
+ optionsOptionDescription({ name: parameterName }, { value: optionName, description }) {
149
+ return context.dynamicRender({
150
+ key: `${credentialPrefix}.${parameterName}.options.${optionName}.description`,
151
+ fallback: description
152
+ });
153
+ },
154
+ /**
155
+ * Placeholder for a `string` param.
156
+ */
157
+ placeholder({ name: parameterName, placeholder }) {
158
+ return context.dynamicRender({
159
+ key: `${credentialPrefix}.${parameterName}.placeholder`,
160
+ fallback: placeholder
161
+ });
162
+ }
163
+ };
164
+ }
165
+ /**
166
+ * Namespace for methods to render text in the node details view,
167
+ * except for `eventTriggerDescription`.
168
+ */
169
+ nodeText(activeNodeType) {
170
+ const nodeType = activeNodeType ? this.shortNodeType(activeNodeType) : "";
171
+ const initialKey = `n8n-nodes-base.nodes.${nodeType}.nodeView`;
172
+ const context = this;
173
+ return {
174
+ /**
175
+ * Display name for an input label, whether top-level or nested.
176
+ */
177
+ inputLabelDisplayName(parameter, path) {
178
+ const middleKey = deriveMiddleKey(path, parameter);
179
+ return context.dynamicRender({
180
+ key: `${initialKey}.${middleKey}.displayName`,
181
+ fallback: parameter.displayName
182
+ });
183
+ },
184
+ /**
185
+ * Description (tooltip text) for an input label, whether top-level or nested.
186
+ */
187
+ inputLabelDescription(parameter, path) {
188
+ const middleKey = deriveMiddleKey(path, parameter);
189
+ return context.dynamicRender({
190
+ key: `${initialKey}.${middleKey}.description`,
191
+ fallback: parameter.description
192
+ });
193
+ },
194
+ /**
195
+ * Hint for an input, whether top-level or nested.
196
+ */
197
+ hint(parameter, path) {
198
+ const middleKey = deriveMiddleKey(path, parameter);
199
+ return context.dynamicRender({
200
+ key: `${initialKey}.${middleKey}.hint`,
201
+ fallback: parameter.hint
202
+ });
203
+ },
204
+ /**
205
+ * Placeholder for an input label or `collection` or `fixedCollection` param,
206
+ * whether top-level or nested.
207
+ * - For an input label, the placeholder is unselectable greyed-out sample text.
208
+ * - For a `collection` or `fixedCollection`, the placeholder is the button text.
209
+ */
210
+ placeholder(parameter, path) {
211
+ let middleKey = parameter.name;
212
+ if (isNestedInCollectionLike(path)) {
213
+ const pathSegments = normalize(path).split(".");
214
+ middleKey = insertOptionsAndValues(pathSegments).join(".");
215
+ }
216
+ return context.dynamicRender({
217
+ key: `${initialKey}.${middleKey}.placeholder`,
218
+ fallback: parameter.placeholder
219
+ });
220
+ },
221
+ /**
222
+ * Display name for an option inside an `options` or `multiOptions` param,
223
+ * whether top-level or nested.
224
+ */
225
+ optionsOptionDisplayName(parameter, { value: optionName, name: displayName }, path) {
226
+ let middleKey = parameter.name;
227
+ if (isNestedInCollectionLike(path)) {
228
+ const pathSegments = normalize(path).split(".");
229
+ middleKey = insertOptionsAndValues(pathSegments).join(".");
230
+ }
231
+ return context.dynamicRender({
232
+ key: `${initialKey}.${middleKey}.options.${optionName}.displayName`,
233
+ fallback: displayName
234
+ });
235
+ },
236
+ /**
237
+ * Description for an option inside an `options` or `multiOptions` param,
238
+ * whether top-level or nested.
239
+ */
240
+ optionsOptionDescription(parameter, { value: optionName, description }, path) {
241
+ let middleKey = parameter.name;
242
+ if (isNestedInCollectionLike(path)) {
243
+ const pathSegments = normalize(path).split(".");
244
+ middleKey = insertOptionsAndValues(pathSegments).join(".");
245
+ }
246
+ return context.dynamicRender({
247
+ key: `${initialKey}.${middleKey}.options.${optionName}.description`,
248
+ fallback: description
249
+ });
250
+ },
251
+ /**
252
+ * Display name for an option in the dropdown menu of a `collection` or
253
+ * fixedCollection` param. No nesting support since `collection` cannot
254
+ * be nested in a `collection` or in a `fixedCollection`.
255
+ */
256
+ collectionOptionDisplayName(parameter, { name: optionName, displayName }, path) {
257
+ let middleKey = parameter.name;
258
+ if (isNestedInCollectionLike(path)) {
259
+ const pathSegments = normalize(path).split(".");
260
+ middleKey = insertOptionsAndValues(pathSegments).join(".");
261
+ }
262
+ return context.dynamicRender({
263
+ key: `${initialKey}.${middleKey}.options.${optionName}.displayName`,
264
+ fallback: displayName
265
+ });
266
+ },
267
+ /**
268
+ * Text for a button to add another option inside a `collection` or
269
+ * `fixedCollection` param having `multipleValues: true`.
270
+ */
271
+ multipleValueButtonText({ name: parameterName, typeOptions }) {
272
+ return context.dynamicRender({
273
+ key: `${initialKey}.${parameterName}.multipleValueButtonText`,
274
+ fallback: typeOptions?.multipleValueButtonText
275
+ });
276
+ },
277
+ eventTriggerDescription(nodeType2, eventTriggerDescription) {
278
+ return context.dynamicRender({
279
+ key: `n8n-nodes-base.nodes.${nodeType2}.nodeView.eventTriggerDescription`,
280
+ fallback: eventTriggerDescription
281
+ });
282
+ }
283
+ };
284
+ }
285
+ localizeNodeName(language, nodeName, type) {
286
+ if (language === "en") return nodeName;
287
+ const nodeTypeName = this.shortNodeType(type);
288
+ return this.headerText({
289
+ key: `headers.${nodeTypeName}.displayName`,
290
+ fallback: nodeName
291
+ });
292
+ }
293
+ autocompleteUIValues = {
294
+ docLinkLabel: this.baseText("expressionEdit.learnMore")
295
+ };
296
+ };
297
+ var loadedLanguages = ["en"];
298
+ async function setLanguage(language) {
299
+ i18nInstance.global.locale = language;
300
+ document.querySelector("html").setAttribute("lang", language);
301
+ return language;
302
+ }
303
+ async function loadLanguage(language) {
304
+ if (i18nInstance.global.locale === language) {
305
+ return await setLanguage(language);
306
+ }
307
+ if (loadedLanguages.includes(language)) {
308
+ return await setLanguage(language);
309
+ }
310
+ const { numberFormats, ...rest } = (await globImport_locales_json(`./locales/${language}.json`)).default;
311
+ i18nInstance.global.setLocaleMessage(language, rest);
312
+ if (numberFormats) {
313
+ i18nInstance.global.setNumberFormat(language, numberFormats);
314
+ }
315
+ loadedLanguages.push(language);
316
+ return await setLanguage(language);
317
+ }
318
+ function addNodeTranslation(nodeTranslation, language) {
319
+ const newMessages = {
320
+ "n8n-nodes-base": {
321
+ nodes: nodeTranslation
322
+ }
323
+ };
324
+ i18nInstance.global.mergeLocaleMessage(language, newMessages);
325
+ }
326
+ function addCredentialTranslation(nodeCredentialTranslation, language) {
327
+ const newMessages = {
328
+ "n8n-nodes-base": {
329
+ credentials: nodeCredentialTranslation
330
+ }
331
+ };
332
+ i18nInstance.global.mergeLocaleMessage(language, newMessages);
333
+ }
334
+ function addHeaders(headers, language) {
335
+ i18nInstance.global.mergeLocaleMessage(language, { headers });
336
+ }
337
+ var i18n = new I18nClass();
338
+ function useI18n() {
339
+ return i18n;
340
+ }
341
+ export {
342
+ I18nClass,
343
+ addCredentialTranslation,
344
+ addHeaders,
345
+ addNodeTranslation,
346
+ i18n,
347
+ i18nInstance,
348
+ loadLanguage,
349
+ useI18n
350
+ };
351
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-this-alias */\nimport type { INodeProperties, INodePropertyCollection, INodePropertyOptions } from 'n8n-workflow';\nimport { createI18n } from 'vue-i18n';\n\nimport englishBaseText from './locales/en.json';\nimport type { BaseTextKey, INodeTranslationHeaders } from './types';\nimport {\n\tderiveMiddleKey,\n\tisNestedInCollectionLike,\n\tnormalize,\n\tinsertOptionsAndValues,\n} from './utils';\n\nexport * from './types';\n\nexport const i18nInstance = createI18n({\n\tlocale: 'en',\n\tfallbackLocale: 'en',\n\tmessages: { en: englishBaseText },\n\twarnHtmlInMessage: 'off',\n});\n\ntype BaseTextOptions = {\n\tadjustToNumber?: number;\n\tinterpolate?: Record<string, string | number>;\n};\n\nexport class I18nClass {\n\tprivate baseTextCache = new Map<string, string>();\n\n\tprivate get i18n() {\n\t\treturn i18nInstance.global;\n\t}\n\n\t// ----------------------------------\n\t// helper methods\n\t// ----------------------------------\n\n\texists(key: string) {\n\t\treturn this.i18n.te(key);\n\t}\n\n\tshortNodeType(longNodeType: string) {\n\t\treturn longNodeType.replace('n8n-nodes-base.', '');\n\t}\n\n\tget locale() {\n\t\treturn i18nInstance.global.locale;\n\t}\n\n\t// ----------------------------------\n\t// render methods\n\t// ----------------------------------\n\n\t/**\n\t * Render a string of base text, i.e. a string with a fixed path to the localized value. Optionally allows for [interpolation](https://kazupon.github.io/vue-i18n/guide/formatting.html#named-formatting) when the localized value contains a string between curly braces.\n\t */\n\tbaseText(key: BaseTextKey, options?: BaseTextOptions): string {\n\t\t// Create a unique cache key\n\t\tconst cacheKey = `${key}-${JSON.stringify(options)}`;\n\n\t\t// Check if the result is already cached\n\t\tif (this.baseTextCache.has(cacheKey)) {\n\t\t\treturn this.baseTextCache.get(cacheKey) ?? key;\n\t\t}\n\n\t\tconst interpolate = { ...options?.interpolate };\n\t\tlet result: string;\n\t\tif (options?.adjustToNumber !== undefined) {\n\t\t\tresult = this.i18n.t(key, interpolate, options.adjustToNumber).toString();\n\t\t} else {\n\t\t\tresult = this.i18n.t(key, interpolate).toString();\n\t\t}\n\n\t\t// Store the result in the cache\n\t\tthis.baseTextCache.set(cacheKey, result);\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Render a string of dynamic text, i.e. a string with a constructed path to the localized value.\n\t */\n\tprivate dynamicRender({ key, fallback }: { key: string; fallback?: string }) {\n\t\treturn this.i18n.te(key) ? this.i18n.t(key).toString() : (fallback ?? '');\n\t}\n\n\tdisplayTimer(msPassed: number, showMs = false): string {\n\t\tif (msPassed < 60000) {\n\t\t\tif (!showMs) {\n\t\t\t\treturn `${Math.floor(msPassed / 1000)}${this.baseText('genericHelpers.secShort')}`;\n\t\t\t}\n\n\t\t\tif (msPassed > 0 && msPassed < 1000) {\n\t\t\t\treturn `${msPassed}${this.baseText('genericHelpers.millis')}`;\n\t\t\t}\n\n\t\t\treturn `${msPassed / 1000}${this.baseText('genericHelpers.secShort')}`;\n\t\t}\n\n\t\tconst secondsPassed = Math.floor(msPassed / 1000);\n\t\tconst minutesPassed = Math.floor(secondsPassed / 60);\n\t\tconst secondsLeft = (secondsPassed - minutesPassed * 60).toString().padStart(2, '0');\n\n\t\treturn `${minutesPassed}:${secondsLeft}${this.baseText('genericHelpers.minShort')}`;\n\t}\n\n\t/**\n\t * Render a string of header text (a node's name and description),\n\t * used variously in the nodes panel, under the node icon, etc.\n\t */\n\theaderText(arg: { key: string; fallback: string }) {\n\t\treturn this.dynamicRender(arg);\n\t}\n\n\t/**\n\t * Namespace for methods to render text in the credentials details modal.\n\t */\n\tcredText(credentialType: string | null) {\n\t\tconst credentialPrefix = `n8n-nodes-base.credentials.${credentialType}`;\n\t\tconst context = this;\n\n\t\treturn {\n\t\t\t/**\n\t\t\t * Display name for a top-level param.\n\t\t\t */\n\t\t\tinputLabelDisplayName({ name: parameterName, displayName }: INodeProperties) {\n\t\t\t\tif (['clientId', 'clientSecret'].includes(parameterName)) {\n\t\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\t\tkey: `_reusableDynamicText.oauth2.${parameterName}`,\n\t\t\t\t\t\tfallback: displayName,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${credentialPrefix}.${parameterName}.displayName`,\n\t\t\t\t\tfallback: displayName,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Hint for a top-level param.\n\t\t\t */\n\t\t\thint({ name: parameterName, hint }: INodeProperties) {\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${credentialPrefix}.${parameterName}.hint`,\n\t\t\t\t\tfallback: hint,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Description (tooltip text) for an input label param.\n\t\t\t */\n\t\t\tinputLabelDescription({ name: parameterName, description }: INodeProperties) {\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${credentialPrefix}.${parameterName}.description`,\n\t\t\t\t\tfallback: description,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Display name for an option inside an `options` or `multiOptions` param.\n\t\t\t */\n\t\t\toptionsOptionDisplayName(\n\t\t\t\t{ name: parameterName }: INodeProperties,\n\t\t\t\t{ value: optionName, name: displayName }: INodePropertyOptions,\n\t\t\t) {\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${credentialPrefix}.${parameterName}.options.${optionName}.displayName`,\n\t\t\t\t\tfallback: displayName,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Description for an option inside an `options` or `multiOptions` param.\n\t\t\t */\n\t\t\toptionsOptionDescription(\n\t\t\t\t{ name: parameterName }: INodeProperties,\n\t\t\t\t{ value: optionName, description }: INodePropertyOptions,\n\t\t\t) {\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${credentialPrefix}.${parameterName}.options.${optionName}.description`,\n\t\t\t\t\tfallback: description,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Placeholder for a `string` param.\n\t\t\t */\n\t\t\tplaceholder({ name: parameterName, placeholder }: INodeProperties) {\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${credentialPrefix}.${parameterName}.placeholder`,\n\t\t\t\t\tfallback: placeholder,\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Namespace for methods to render text in the node details view,\n\t * except for `eventTriggerDescription`.\n\t */\n\tnodeText(activeNodeType?: string | null) {\n\t\tconst nodeType = activeNodeType ? this.shortNodeType(activeNodeType) : ''; // unused in eventTriggerDescription\n\t\tconst initialKey = `n8n-nodes-base.nodes.${nodeType}.nodeView`;\n\t\tconst context = this;\n\n\t\treturn {\n\t\t\t/**\n\t\t\t * Display name for an input label, whether top-level or nested.\n\t\t\t */\n\t\t\tinputLabelDisplayName(parameter: INodeProperties | INodePropertyCollection, path: string) {\n\t\t\t\tconst middleKey = deriveMiddleKey(path, parameter);\n\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${initialKey}.${middleKey}.displayName`,\n\t\t\t\t\tfallback: parameter.displayName,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Description (tooltip text) for an input label, whether top-level or nested.\n\t\t\t */\n\t\t\tinputLabelDescription(parameter: INodeProperties, path: string) {\n\t\t\t\tconst middleKey = deriveMiddleKey(path, parameter);\n\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${initialKey}.${middleKey}.description`,\n\t\t\t\t\tfallback: parameter.description,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Hint for an input, whether top-level or nested.\n\t\t\t */\n\t\t\thint(parameter: INodeProperties, path: string) {\n\t\t\t\tconst middleKey = deriveMiddleKey(path, parameter);\n\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${initialKey}.${middleKey}.hint`,\n\t\t\t\t\tfallback: parameter.hint,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Placeholder for an input label or `collection` or `fixedCollection` param,\n\t\t\t * whether top-level or nested.\n\t\t\t * - For an input label, the placeholder is unselectable greyed-out sample text.\n\t\t\t * - For a `collection` or `fixedCollection`, the placeholder is the button text.\n\t\t\t */\n\t\t\tplaceholder(parameter: INodeProperties, path: string) {\n\t\t\t\tlet middleKey = parameter.name;\n\n\t\t\t\tif (isNestedInCollectionLike(path)) {\n\t\t\t\t\tconst pathSegments = normalize(path).split('.');\n\t\t\t\t\tmiddleKey = insertOptionsAndValues(pathSegments).join('.');\n\t\t\t\t}\n\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${initialKey}.${middleKey}.placeholder`,\n\t\t\t\t\tfallback: parameter.placeholder,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Display name for an option inside an `options` or `multiOptions` param,\n\t\t\t * whether top-level or nested.\n\t\t\t */\n\t\t\toptionsOptionDisplayName(\n\t\t\t\tparameter: INodeProperties,\n\t\t\t\t{ value: optionName, name: displayName }: INodePropertyOptions,\n\t\t\t\tpath: string,\n\t\t\t) {\n\t\t\t\tlet middleKey = parameter.name;\n\n\t\t\t\tif (isNestedInCollectionLike(path)) {\n\t\t\t\t\tconst pathSegments = normalize(path).split('.');\n\t\t\t\t\tmiddleKey = insertOptionsAndValues(pathSegments).join('.');\n\t\t\t\t}\n\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${initialKey}.${middleKey}.options.${optionName}.displayName`,\n\t\t\t\t\tfallback: displayName,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Description for an option inside an `options` or `multiOptions` param,\n\t\t\t * whether top-level or nested.\n\t\t\t */\n\t\t\toptionsOptionDescription(\n\t\t\t\tparameter: INodeProperties,\n\t\t\t\t{ value: optionName, description }: INodePropertyOptions,\n\t\t\t\tpath: string,\n\t\t\t) {\n\t\t\t\tlet middleKey = parameter.name;\n\n\t\t\t\tif (isNestedInCollectionLike(path)) {\n\t\t\t\t\tconst pathSegments = normalize(path).split('.');\n\t\t\t\t\tmiddleKey = insertOptionsAndValues(pathSegments).join('.');\n\t\t\t\t}\n\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${initialKey}.${middleKey}.options.${optionName}.description`,\n\t\t\t\t\tfallback: description,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Display name for an option in the dropdown menu of a `collection` or\n\t\t\t * fixedCollection` param. No nesting support since `collection` cannot\n\t\t\t * be nested in a `collection` or in a `fixedCollection`.\n\t\t\t */\n\t\t\tcollectionOptionDisplayName(\n\t\t\t\tparameter: INodeProperties,\n\t\t\t\t{ name: optionName, displayName }: INodePropertyCollection,\n\t\t\t\tpath: string,\n\t\t\t) {\n\t\t\t\tlet middleKey = parameter.name;\n\n\t\t\t\tif (isNestedInCollectionLike(path)) {\n\t\t\t\t\tconst pathSegments = normalize(path).split('.');\n\t\t\t\t\tmiddleKey = insertOptionsAndValues(pathSegments).join('.');\n\t\t\t\t}\n\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${initialKey}.${middleKey}.options.${optionName}.displayName`,\n\t\t\t\t\tfallback: displayName,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Text for a button to add another option inside a `collection` or\n\t\t\t * `fixedCollection` param having `multipleValues: true`.\n\t\t\t */\n\t\t\tmultipleValueButtonText({ name: parameterName, typeOptions }: INodeProperties) {\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `${initialKey}.${parameterName}.multipleValueButtonText`,\n\t\t\t\t\tfallback: typeOptions?.multipleValueButtonText,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\teventTriggerDescription(nodeType: string, eventTriggerDescription: string) {\n\t\t\t\treturn context.dynamicRender({\n\t\t\t\t\tkey: `n8n-nodes-base.nodes.${nodeType}.nodeView.eventTriggerDescription`,\n\t\t\t\t\tfallback: eventTriggerDescription,\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t}\n\n\tlocalizeNodeName(language: string, nodeName: string, type: string) {\n\t\tif (language === 'en') return nodeName;\n\n\t\tconst nodeTypeName = this.shortNodeType(type);\n\n\t\treturn this.headerText({\n\t\t\tkey: `headers.${nodeTypeName}.displayName`,\n\t\t\tfallback: nodeName,\n\t\t});\n\t}\n\n\tautocompleteUIValues: Record<string, string | undefined> = {\n\t\tdocLinkLabel: this.baseText('expressionEdit.learnMore'),\n\t};\n}\n\nconst loadedLanguages = ['en'];\n\nasync function setLanguage(language: string) {\n\ti18nInstance.global.locale = language as 'en';\n\tdocument!.querySelector('html')!.setAttribute('lang', language);\n\n\treturn language;\n}\n\nexport async function loadLanguage(language: string) {\n\tif (i18nInstance.global.locale === language) {\n\t\treturn await setLanguage(language);\n\t}\n\n\tif (loadedLanguages.includes(language)) {\n\t\treturn await setLanguage(language);\n\t}\n\n\tconst { numberFormats, ...rest } = (await import(`./locales/${language}.json`)).default;\n\n\ti18nInstance.global.setLocaleMessage(language, rest);\n\n\tif (numberFormats) {\n\t\ti18nInstance.global.setNumberFormat(language, numberFormats);\n\t}\n\n\tloadedLanguages.push(language);\n\n\treturn await setLanguage(language);\n}\n\n/**\n * Add a node translation to the i18n instance's `messages` object.\n */\nexport function addNodeTranslation(\n\tnodeTranslation: { [nodeType: string]: object },\n\tlanguage: string,\n) {\n\tconst newMessages = {\n\t\t'n8n-nodes-base': {\n\t\t\tnodes: nodeTranslation,\n\t\t},\n\t};\n\n\ti18nInstance.global.mergeLocaleMessage(language, newMessages);\n}\n\n/**\n * Add a credential translation to the i18n instance's `messages` object.\n */\nexport function addCredentialTranslation(\n\tnodeCredentialTranslation: { [credentialType: string]: object },\n\tlanguage: string,\n) {\n\tconst newMessages = {\n\t\t'n8n-nodes-base': {\n\t\t\tcredentials: nodeCredentialTranslation,\n\t\t},\n\t};\n\n\ti18nInstance.global.mergeLocaleMessage(language, newMessages);\n}\n\n/**\n * Add a node's header strings to the i18n instance's `messages` object.\n */\nexport function addHeaders(headers: INodeTranslationHeaders, language: string) {\n\ti18nInstance.global.mergeLocaleMessage(language, { headers });\n}\n\nexport const i18n: I18nClass = new I18nClass();\n\nexport function useI18n() {\n\treturn i18n;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEA,SAAS,kBAAkB;;;;;;;;AAapB,IAAM,eAAe,WAAW;AAAA,EACtC,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,UAAU,EAAE,IAAI,WAAgB;AAA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version":3,"sources":["/home/runner/work/n8n/n8n/packages/frontend/@n8n/i18n/dist/types.cjs"],"names":[],"mappings":"AAAA,6CAA6B","file":"/home/runner/work/n8n/n8n/packages/frontend/@n8n/i18n/dist/types.cjs"}