@powerlines/plugin-i18next 0.1.260 → 0.1.263
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/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/_virtual/_rolldown/runtime.mjs +3 -0
- package/dist/helpers/config-utils.cjs +31 -0
- package/dist/helpers/config-utils.mjs +31 -0
- package/dist/helpers/config-utils.mjs.map +1 -0
- package/dist/index.cjs +129 -0
- package/dist/index.d.cts +25 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +25 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +126 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/i18n.cjs +0 -0
- package/dist/types/i18n.d.cts +23 -0
- package/dist/types/i18n.d.cts.map +1 -0
- package/dist/types/i18n.d.mts +23 -0
- package/dist/types/i18n.d.mts.map +1 -0
- package/dist/types/i18n.mjs +1 -0
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.mts +3 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/plugin.cjs +0 -0
- package/dist/types/plugin.d.cts +24 -0
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.mts +24 -0
- package/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/plugin.mjs +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let _stryke_path_correct_path = require("@stryke/path/correct-path");
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/config-utils.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolve an output template (string or function) into an actual path string.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* - If `outputTemplate` is a function, call it with (language, namespace)
|
|
10
|
+
* - If it's a string, replace placeholders:
|
|
11
|
+
* - \{\{language\}\} or \{\{lng\}\} -\> language
|
|
12
|
+
* - \{\{namespace\}\} -\> namespace (or removed if namespace is undefined)
|
|
13
|
+
* - Normalizes duplicate slashes and returns a platform-correct path.
|
|
14
|
+
*/
|
|
15
|
+
function getOutputPath(outputTemplate, language, namespace) {
|
|
16
|
+
if (!outputTemplate) return (0, _stryke_path_correct_path.correctPath)(`locales/${language}/${namespace ?? "translation"}.json`);
|
|
17
|
+
if (typeof outputTemplate === "function") try {
|
|
18
|
+
return (0, _stryke_path_correct_path.correctPath)(String(outputTemplate(language, namespace)).replace(/\/{2,}/g, "/"));
|
|
19
|
+
} catch {
|
|
20
|
+
return (0, _stryke_path_correct_path.correctPath)(`locales/${language}/${namespace ?? "translation"}.json`);
|
|
21
|
+
}
|
|
22
|
+
let out = String(outputTemplate);
|
|
23
|
+
out = out.replace(/\{\{language\}\}|\{\{lng\}\}/g, language);
|
|
24
|
+
if (namespace !== void 0 && namespace !== null) out = out.replace(/\{\{namespace\}\}/g, namespace);
|
|
25
|
+
else out = out.replace(/\/?\{\{namespace\}\}/g, "");
|
|
26
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
27
|
+
return (0, _stryke_path_correct_path.correctPath)(out);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.getOutputPath = getOutputPath;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { correctPath } from "@stryke/path/correct-path";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/config-utils.ts
|
|
4
|
+
/**
|
|
5
|
+
* Resolve an output template (string or function) into an actual path string.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* - If `outputTemplate` is a function, call it with (language, namespace)
|
|
9
|
+
* - If it's a string, replace placeholders:
|
|
10
|
+
* - \{\{language\}\} or \{\{lng\}\} -\> language
|
|
11
|
+
* - \{\{namespace\}\} -\> namespace (or removed if namespace is undefined)
|
|
12
|
+
* - Normalizes duplicate slashes and returns a platform-correct path.
|
|
13
|
+
*/
|
|
14
|
+
function getOutputPath(outputTemplate, language, namespace) {
|
|
15
|
+
if (!outputTemplate) return correctPath(`locales/${language}/${namespace ?? "translation"}.json`);
|
|
16
|
+
if (typeof outputTemplate === "function") try {
|
|
17
|
+
return correctPath(String(outputTemplate(language, namespace)).replace(/\/{2,}/g, "/"));
|
|
18
|
+
} catch {
|
|
19
|
+
return correctPath(`locales/${language}/${namespace ?? "translation"}.json`);
|
|
20
|
+
}
|
|
21
|
+
let out = String(outputTemplate);
|
|
22
|
+
out = out.replace(/\{\{language\}\}|\{\{lng\}\}/g, language);
|
|
23
|
+
if (namespace !== void 0 && namespace !== null) out = out.replace(/\{\{namespace\}\}/g, namespace);
|
|
24
|
+
else out = out.replace(/\/?\{\{namespace\}\}/g, "");
|
|
25
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
26
|
+
return correctPath(out);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { getOutputPath };
|
|
31
|
+
//# sourceMappingURL=config-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-utils.mjs","names":[],"sources":["../../src/helpers/config-utils.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { correctPath } from \"@stryke/path/correct-path\";\n\n/**\n * Resolve an output template (string or function) into an actual path string.\n *\n * @remarks\n * - If `outputTemplate` is a function, call it with (language, namespace)\n * - If it's a string, replace placeholders:\n * - \\{\\{language\\}\\} or \\{\\{lng\\}\\} -\\> language\n * - \\{\\{namespace\\}\\} -\\> namespace (or removed if namespace is undefined)\n * - Normalizes duplicate slashes and returns a platform-correct path.\n */\nexport function getOutputPath(\n outputTemplate:\n | string\n | ((language: string, namespace?: string) => string)\n | undefined,\n language: string,\n namespace?: string\n): string {\n if (!outputTemplate) {\n // Fallback to a sensible default\n return correctPath(\n `locales/${language}/${namespace ?? \"translation\"}.json`\n );\n }\n\n if (typeof outputTemplate === \"function\") {\n try {\n const result = String(outputTemplate(language, namespace));\n\n return correctPath(result.replace(/\\/{2,}/g, \"/\"));\n } catch {\n // If user function throws, fallback to default path\n return correctPath(\n `locales/${language}/${namespace ?? \"translation\"}.json`\n );\n }\n }\n\n // It's a string template\n let out = String(outputTemplate);\n out = out.replace(/\\{\\{language\\}\\}|\\{\\{lng\\}\\}/g, language);\n\n if (namespace !== undefined && namespace !== null) {\n out = out.replace(/\\{\\{namespace\\}\\}/g, namespace);\n } else {\n // remove any occurrences of /{{namespace}} or {{namespace}} (keeping surrounding slashes tidy)\n out = out.replace(/\\/?\\{\\{namespace\\}\\}/g, \"\");\n }\n\n // collapse duplicate slashes and normalize to platform-specific separators\n out = out.replace(/\\/{2,}/g, \"/\");\n return correctPath(out);\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,cACd,gBAIA,UACA,WACQ;AACR,KAAI,CAAC,eAEH,QAAO,YACL,WAAW,SAAS,GAAG,aAAa,cAAc,OACnD;AAGH,KAAI,OAAO,mBAAmB,WAC5B,KAAI;AAGF,SAAO,YAFQ,OAAO,eAAe,UAAU,UAAU,CAAC,CAEhC,QAAQ,WAAW,IAAI,CAAC;SAC5C;AAEN,SAAO,YACL,WAAW,SAAS,GAAG,aAAa,cAAc,OACnD;;CAKL,IAAI,MAAM,OAAO,eAAe;AAChC,OAAM,IAAI,QAAQ,iCAAiC,SAAS;AAE5D,KAAI,cAAc,UAAa,cAAc,KAC3C,OAAM,IAAI,QAAQ,sBAAsB,UAAU;KAGlD,OAAM,IAAI,QAAQ,yBAAyB,GAAG;AAIhD,OAAM,IAAI,QAAQ,WAAW,IAAI;AACjC,QAAO,YAAY,IAAI"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_config_utils = require('./helpers/config-utils.cjs');
|
|
4
|
+
let _stryke_fs_list_files = require("@stryke/fs/list-files");
|
|
5
|
+
let _stryke_path_append = require("@stryke/path/append");
|
|
6
|
+
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
7
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
8
|
+
let _stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
9
|
+
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
10
|
+
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
11
|
+
let defu = require("defu");
|
|
12
|
+
defu = require_runtime.__toESM(defu);
|
|
13
|
+
let i18next_cli = require("i18next-cli");
|
|
14
|
+
let i18next_resources_for_ts = require("i18next-resources-for-ts");
|
|
15
|
+
|
|
16
|
+
//#region src/index.ts
|
|
17
|
+
/**
|
|
18
|
+
* i18next Plugin
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* A Powerlines plugin to use the i18next internationalization framework during the prepare task.
|
|
22
|
+
*
|
|
23
|
+
* @see https://i18next.com
|
|
24
|
+
*
|
|
25
|
+
* @param options - The plugin options.
|
|
26
|
+
* @returns A Powerlines plugin instance.
|
|
27
|
+
*/
|
|
28
|
+
const plugin = (options = {}) => {
|
|
29
|
+
return {
|
|
30
|
+
name: "i18next",
|
|
31
|
+
async config() {
|
|
32
|
+
const i18next = (0, defu.default)(options, { extract: {
|
|
33
|
+
output: (language, namespace = "translation") => (0, _stryke_path_join.joinPaths)(this.config.root, `locales/${language}/${namespace}.json`),
|
|
34
|
+
primaryLanguage: this.workspaceConfig.locale
|
|
35
|
+
} }, {
|
|
36
|
+
extract: {
|
|
37
|
+
input: [
|
|
38
|
+
"src/**/*.ts",
|
|
39
|
+
"src/**/*.tsx",
|
|
40
|
+
"src/**/*.js",
|
|
41
|
+
"src/**/*.jsx"
|
|
42
|
+
],
|
|
43
|
+
indentation: 2,
|
|
44
|
+
defaultNS: "translation",
|
|
45
|
+
mergeNamespaces: true,
|
|
46
|
+
nsSeparator: ":",
|
|
47
|
+
keySeparator: ".",
|
|
48
|
+
primaryLanguage: options.locales && options.locales.length > 0 ? options.locales[0] : "en"
|
|
49
|
+
},
|
|
50
|
+
types: { enableSelector: false },
|
|
51
|
+
locales: []
|
|
52
|
+
});
|
|
53
|
+
if (!i18next.locales || i18next.locales.length === 0) i18next.locales = [i18next.extract.primaryLanguage || "en"];
|
|
54
|
+
if (!(0, _stryke_type_checks_is_set.isSet)(i18next.types.indentation)) i18next.types.indentation = i18next.extract.indentation;
|
|
55
|
+
return { i18next };
|
|
56
|
+
},
|
|
57
|
+
async configResolved() {},
|
|
58
|
+
async prepare() {
|
|
59
|
+
await (0, i18next_cli.runExtractor)(this.config.i18next, {
|
|
60
|
+
isWatchMode: false,
|
|
61
|
+
isDryRun: false,
|
|
62
|
+
syncAll: true,
|
|
63
|
+
syncPrimaryWithDefaults: true,
|
|
64
|
+
logger: {
|
|
65
|
+
info: (message) => {
|
|
66
|
+
this.info(message);
|
|
67
|
+
},
|
|
68
|
+
warn: (message, _more) => {
|
|
69
|
+
this.warn(message);
|
|
70
|
+
},
|
|
71
|
+
error: (message) => {
|
|
72
|
+
this.error(message);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
async types(code) {
|
|
78
|
+
const resources = [];
|
|
79
|
+
for (const file of await (0, _stryke_fs_list_files.listFiles)(require_config_utils.getOutputPath(this.config.i18next.extract.output, this.config.i18next.extract.primaryLanguage, "*"))) {
|
|
80
|
+
const namespace = (0, _stryke_path_file_path_fns.findFileName)(file, { withExtension: false });
|
|
81
|
+
const parsedContent = await this.resolver.import(file);
|
|
82
|
+
if (this.config.i18next.extract.mergeNamespaces && (0, _stryke_type_checks_is_set_object.isSetObject)(parsedContent)) {
|
|
83
|
+
if (Object.keys(parsedContent).filter((k) => (0, _stryke_type_checks_is_set_object.isSetObject)(parsedContent[k])).length > 0) {
|
|
84
|
+
for (const nsName of Object.keys(parsedContent).filter((k) => (0, _stryke_type_checks_is_set_object.isSetObject)(parsedContent[k]))) resources.push({
|
|
85
|
+
name: nsName,
|
|
86
|
+
resources: parsedContent[nsName]
|
|
87
|
+
});
|
|
88
|
+
if (Object.keys(parsedContent).filter((k) => !(0, _stryke_type_checks_is_set_object.isSetObject)(parsedContent[k])).length > 0) this.warn(`The file ${file} contains top-level keys that are not objects (${Object.keys(parsedContent).filter((k) => !(0, _stryke_type_checks_is_set_object.isSetObject)(parsedContent[k])).join(", ")}). When 'mergeNamespaces' is enabled, top-level keys are treated as namespaces. These keys will be ignored.`);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
resources.push({
|
|
93
|
+
name: namespace,
|
|
94
|
+
resources: parsedContent
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
let result;
|
|
98
|
+
if (this.config.i18next.types.resourcesFile) await this.fs.write((0, _stryke_path_append.appendPath)(this.config.i18next.types.resourcesFile, this.config.i18next.types.output || this.config.root), (0, i18next_resources_for_ts.mergeResourcesAsInterface)(resources, {
|
|
99
|
+
optimize: !!this.config.i18next.types.enableSelector,
|
|
100
|
+
indentation: this.config.i18next.types.indentation
|
|
101
|
+
}));
|
|
102
|
+
else result = `${code}
|
|
103
|
+
|
|
104
|
+
${(0, i18next_resources_for_ts.mergeResourcesAsInterface)(resources, {
|
|
105
|
+
optimize: !!this.config.i18next.types.enableSelector,
|
|
106
|
+
indentation: this.config.i18next.types.indentation
|
|
107
|
+
})}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* i18next Custom Type Options
|
|
111
|
+
*
|
|
112
|
+
* @see https://www.i18next.com/overview/typescript#custom-type-options
|
|
113
|
+
*/
|
|
114
|
+
declare module 'i18next' {
|
|
115
|
+
interface CustomTypeOptions {
|
|
116
|
+
enableSelector: ${(0, _stryke_type_checks_is_string.isString)(this.config.i18next.types.enableSelector) ? `"${this.config.i18next.types.enableSelector}"` : this.config.i18next.types.enableSelector};
|
|
117
|
+
defaultNS: ${this.config.i18next.extract.defaultNS === false ? "false" : `'${this.config.i18next.extract.defaultNS || "translation"}'`};
|
|
118
|
+
resources: Resources;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
exports.default = plugin;
|
|
129
|
+
exports.plugin = plugin;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig } from "./types/plugin.cjs";
|
|
2
|
+
import { Resource, ResourceContent } from "./types/i18n.cjs";
|
|
3
|
+
import { Plugin } from "powerlines";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
declare module "powerlines" {
|
|
7
|
+
interface Config {
|
|
8
|
+
i18next?: I18NextPluginOptions;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* i18next Plugin
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* A Powerlines plugin to use the i18next internationalization framework during the prepare task.
|
|
16
|
+
*
|
|
17
|
+
* @see https://i18next.com
|
|
18
|
+
*
|
|
19
|
+
* @param options - The plugin options.
|
|
20
|
+
* @returns A Powerlines plugin instance.
|
|
21
|
+
*/
|
|
22
|
+
declare const plugin: <TContext extends I18NextPluginContext = I18NextPluginContext>(options?: I18NextPluginOptions) => Plugin<TContext>;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig, Resource, ResourceContent, plugin as default, plugin };
|
|
25
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YAwCY,MAAA;IACR,OAAA,GAAU,oBAAA;EAAA;AAAA;;;;;;;;;AAed;;;cAAa,MAAA,oBACM,oBAAA,GAAuB,oBAAA,EAExC,OAAA,GAAS,oBAAA,KACR,MAAA,CAAO,QAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig } from "./types/plugin.mjs";
|
|
2
|
+
import { Resource, ResourceContent } from "./types/i18n.mjs";
|
|
3
|
+
import { Plugin } from "powerlines";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
declare module "powerlines" {
|
|
7
|
+
interface Config {
|
|
8
|
+
i18next?: I18NextPluginOptions;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* i18next Plugin
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* A Powerlines plugin to use the i18next internationalization framework during the prepare task.
|
|
16
|
+
*
|
|
17
|
+
* @see https://i18next.com
|
|
18
|
+
*
|
|
19
|
+
* @param options - The plugin options.
|
|
20
|
+
* @returns A Powerlines plugin instance.
|
|
21
|
+
*/
|
|
22
|
+
declare const plugin: <TContext extends I18NextPluginContext = I18NextPluginContext>(options?: I18NextPluginOptions) => Plugin<TContext>;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig, Resource, ResourceContent, plugin as default, plugin };
|
|
25
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YAwCY,MAAA;IACR,OAAA,GAAU,oBAAA;EAAA;AAAA;;;;;;;;;AAed;;;cAAa,MAAA,oBACM,oBAAA,GAAuB,oBAAA,EAExC,OAAA,GAAS,oBAAA,KACR,MAAA,CAAO,QAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { getOutputPath } from "./helpers/config-utils.mjs";
|
|
2
|
+
import { listFiles } from "@stryke/fs/list-files";
|
|
3
|
+
import { appendPath } from "@stryke/path/append";
|
|
4
|
+
import { findFileName } from "@stryke/path/file-path-fns";
|
|
5
|
+
import { joinPaths } from "@stryke/path/join";
|
|
6
|
+
import { isSet } from "@stryke/type-checks/is-set";
|
|
7
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
8
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
9
|
+
import defu from "defu";
|
|
10
|
+
import { runExtractor } from "i18next-cli";
|
|
11
|
+
import { mergeResourcesAsInterface } from "i18next-resources-for-ts";
|
|
12
|
+
|
|
13
|
+
//#region src/index.ts
|
|
14
|
+
/**
|
|
15
|
+
* i18next Plugin
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* A Powerlines plugin to use the i18next internationalization framework during the prepare task.
|
|
19
|
+
*
|
|
20
|
+
* @see https://i18next.com
|
|
21
|
+
*
|
|
22
|
+
* @param options - The plugin options.
|
|
23
|
+
* @returns A Powerlines plugin instance.
|
|
24
|
+
*/
|
|
25
|
+
const plugin = (options = {}) => {
|
|
26
|
+
return {
|
|
27
|
+
name: "i18next",
|
|
28
|
+
async config() {
|
|
29
|
+
const i18next = defu(options, { extract: {
|
|
30
|
+
output: (language, namespace = "translation") => joinPaths(this.config.root, `locales/${language}/${namespace}.json`),
|
|
31
|
+
primaryLanguage: this.workspaceConfig.locale
|
|
32
|
+
} }, {
|
|
33
|
+
extract: {
|
|
34
|
+
input: [
|
|
35
|
+
"src/**/*.ts",
|
|
36
|
+
"src/**/*.tsx",
|
|
37
|
+
"src/**/*.js",
|
|
38
|
+
"src/**/*.jsx"
|
|
39
|
+
],
|
|
40
|
+
indentation: 2,
|
|
41
|
+
defaultNS: "translation",
|
|
42
|
+
mergeNamespaces: true,
|
|
43
|
+
nsSeparator: ":",
|
|
44
|
+
keySeparator: ".",
|
|
45
|
+
primaryLanguage: options.locales && options.locales.length > 0 ? options.locales[0] : "en"
|
|
46
|
+
},
|
|
47
|
+
types: { enableSelector: false },
|
|
48
|
+
locales: []
|
|
49
|
+
});
|
|
50
|
+
if (!i18next.locales || i18next.locales.length === 0) i18next.locales = [i18next.extract.primaryLanguage || "en"];
|
|
51
|
+
if (!isSet(i18next.types.indentation)) i18next.types.indentation = i18next.extract.indentation;
|
|
52
|
+
return { i18next };
|
|
53
|
+
},
|
|
54
|
+
async configResolved() {},
|
|
55
|
+
async prepare() {
|
|
56
|
+
await runExtractor(this.config.i18next, {
|
|
57
|
+
isWatchMode: false,
|
|
58
|
+
isDryRun: false,
|
|
59
|
+
syncAll: true,
|
|
60
|
+
syncPrimaryWithDefaults: true,
|
|
61
|
+
logger: {
|
|
62
|
+
info: (message) => {
|
|
63
|
+
this.info(message);
|
|
64
|
+
},
|
|
65
|
+
warn: (message, _more) => {
|
|
66
|
+
this.warn(message);
|
|
67
|
+
},
|
|
68
|
+
error: (message) => {
|
|
69
|
+
this.error(message);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
async types(code) {
|
|
75
|
+
const resources = [];
|
|
76
|
+
for (const file of await listFiles(getOutputPath(this.config.i18next.extract.output, this.config.i18next.extract.primaryLanguage, "*"))) {
|
|
77
|
+
const namespace = findFileName(file, { withExtension: false });
|
|
78
|
+
const parsedContent = await this.resolver.import(file);
|
|
79
|
+
if (this.config.i18next.extract.mergeNamespaces && isSetObject(parsedContent)) {
|
|
80
|
+
if (Object.keys(parsedContent).filter((k) => isSetObject(parsedContent[k])).length > 0) {
|
|
81
|
+
for (const nsName of Object.keys(parsedContent).filter((k) => isSetObject(parsedContent[k]))) resources.push({
|
|
82
|
+
name: nsName,
|
|
83
|
+
resources: parsedContent[nsName]
|
|
84
|
+
});
|
|
85
|
+
if (Object.keys(parsedContent).filter((k) => !isSetObject(parsedContent[k])).length > 0) this.warn(`The file ${file} contains top-level keys that are not objects (${Object.keys(parsedContent).filter((k) => !isSetObject(parsedContent[k])).join(", ")}). When 'mergeNamespaces' is enabled, top-level keys are treated as namespaces. These keys will be ignored.`);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
resources.push({
|
|
90
|
+
name: namespace,
|
|
91
|
+
resources: parsedContent
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
let result;
|
|
95
|
+
if (this.config.i18next.types.resourcesFile) await this.fs.write(appendPath(this.config.i18next.types.resourcesFile, this.config.i18next.types.output || this.config.root), mergeResourcesAsInterface(resources, {
|
|
96
|
+
optimize: !!this.config.i18next.types.enableSelector,
|
|
97
|
+
indentation: this.config.i18next.types.indentation
|
|
98
|
+
}));
|
|
99
|
+
else result = `${code}
|
|
100
|
+
|
|
101
|
+
${mergeResourcesAsInterface(resources, {
|
|
102
|
+
optimize: !!this.config.i18next.types.enableSelector,
|
|
103
|
+
indentation: this.config.i18next.types.indentation
|
|
104
|
+
})}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* i18next Custom Type Options
|
|
108
|
+
*
|
|
109
|
+
* @see https://www.i18next.com/overview/typescript#custom-type-options
|
|
110
|
+
*/
|
|
111
|
+
declare module 'i18next' {
|
|
112
|
+
interface CustomTypeOptions {
|
|
113
|
+
enableSelector: ${isString(this.config.i18next.types.enableSelector) ? `"${this.config.i18next.types.enableSelector}"` : this.config.i18next.types.enableSelector};
|
|
114
|
+
defaultNS: ${this.config.i18next.extract.defaultNS === false ? "false" : `'${this.config.i18next.extract.defaultNS || "translation"}'`};
|
|
115
|
+
resources: Resources;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
export { plugin as default, plugin };
|
|
126
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { I18nextToolkitConfig, runExtractor } from \"i18next-cli\";\nimport { mergeResourcesAsInterface } from \"i18next-resources-for-ts\";\nimport { Plugin } from \"powerlines\";\nimport { getOutputPath } from \"./helpers/config-utils\";\nimport { Resource, ResourceContent } from \"./types/i18n\";\nimport {\n I18NextPluginContext,\n I18NextPluginOptions,\n I18NextPluginResolvedConfig\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n i18next?: I18NextPluginOptions;\n }\n}\n\n/**\n * i18next Plugin\n *\n * @remarks\n * A Powerlines plugin to use the i18next internationalization framework during the prepare task.\n *\n * @see https://i18next.com\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends I18NextPluginContext = I18NextPluginContext\n>(\n options: I18NextPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"i18next\",\n async config() {\n const i18next = defu<\n I18NextPluginResolvedConfig[\"i18next\"],\n I18NextPluginOptions[]\n >(\n options,\n {\n extract: {\n output: (language: string, namespace = \"translation\") =>\n joinPaths(\n this.config.root,\n `locales/${language}/${namespace}.json`\n ),\n primaryLanguage: this.workspaceConfig.locale\n }\n },\n {\n extract: {\n input: [\n \"src/**/*.ts\",\n \"src/**/*.tsx\",\n \"src/**/*.js\",\n \"src/**/*.jsx\"\n ],\n indentation: 2,\n defaultNS: \"translation\",\n mergeNamespaces: true,\n nsSeparator: \":\",\n keySeparator: \".\",\n primaryLanguage:\n options.locales && options.locales.length > 0\n ? options.locales[0]\n : \"en\"\n },\n types: {\n enableSelector: false\n },\n locales: [] as string[]\n }\n );\n\n if (!i18next.locales || i18next.locales.length === 0) {\n i18next.locales = [i18next.extract.primaryLanguage || \"en\"];\n }\n\n if (!isSet(i18next.types.indentation)) {\n i18next.types.indentation = i18next.extract.indentation;\n }\n\n return {\n i18next\n };\n },\n async configResolved() {},\n async prepare() {\n await runExtractor(this.config.i18next as I18nextToolkitConfig, {\n isWatchMode: false,\n isDryRun: false,\n syncAll: true,\n syncPrimaryWithDefaults: true,\n logger: {\n info: (message: string) => {\n this.info(message);\n },\n warn: (message: string, _more?: any) => {\n this.warn(message);\n },\n error: (message: string | any) => {\n this.error(message);\n }\n }\n });\n },\n async types(code: string) {\n const resources: Resource[] = [];\n for (const file of await listFiles(\n getOutputPath(\n this.config.i18next.extract.output,\n this.config.i18next.extract.primaryLanguage,\n \"*\"\n )\n )) {\n const namespace = findFileName(file, { withExtension: false });\n const parsedContent = await this.resolver.import<ResourceContent>(file);\n\n // If mergeNamespaces is used, a single file can contain multiple namespaces\n // (e.g. { \"translation\": { ... }, \"common\": { ... } } in a per-language file).\n // In that case, expose each top-level key as a namespace entry so the type\n // generator will produce top-level namespace interfaces (not a language wrapper).\n if (\n this.config.i18next.extract.mergeNamespaces &&\n isSetObject(parsedContent)\n ) {\n // If we have at least one object and we are in mergeNamespaces mode, assume it's a merged file\n if (\n Object.keys(parsedContent).filter(k =>\n isSetObject(parsedContent[k])\n ).length > 0\n ) {\n for (const nsName of Object.keys(parsedContent).filter(k =>\n isSetObject(parsedContent[k])\n )) {\n resources.push({\n name: nsName,\n resources: parsedContent[nsName] as ResourceContent\n });\n }\n\n if (\n Object.keys(parsedContent).filter(\n k => !isSetObject(parsedContent[k])\n ).length > 0\n ) {\n this.warn(\n `The file ${file} contains top-level keys that are not objects (${Object.keys(\n parsedContent\n )\n .filter(k => !isSetObject(parsedContent[k]))\n .join(\n \", \"\n )}). When 'mergeNamespaces' is enabled, top-level keys are treated as namespaces. These keys will be ignored.`\n );\n }\n\n continue;\n }\n }\n\n resources.push({ name: namespace, resources: parsedContent });\n }\n\n let result!: string;\n if (this.config.i18next.types.resourcesFile) {\n await this.fs.write(\n appendPath(\n this.config.i18next.types.resourcesFile,\n this.config.i18next.types.output || this.config.root\n ),\n mergeResourcesAsInterface(resources, {\n optimize: !!this.config.i18next.types.enableSelector,\n indentation: this.config.i18next.types.indentation\n })\n );\n } else {\n result = `${code}\n\n${mergeResourcesAsInterface(resources, {\n optimize: !!this.config.i18next.types.enableSelector,\n indentation: this.config.i18next.types.indentation\n})}\n\n/**\n * i18next Custom Type Options\n *\n * @see https://www.i18next.com/overview/typescript#custom-type-options\n */\ndeclare module 'i18next' {\n interface CustomTypeOptions {\n enableSelector: ${isString(this.config.i18next.types.enableSelector) ? `\"${this.config.i18next.types.enableSelector}\"` : this.config.i18next.types.enableSelector};\n defaultNS: ${\n this.config.i18next.extract.defaultNS === false\n ? \"false\"\n : `'${this.config.i18next.extract.defaultNS || \"translation\"}'`\n };\n resources: Resources;\n }\n}\n`;\n }\n\n return result;\n }\n };\n};\n\nexport default plugin;\n"],"mappings":"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"}
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/types/i18n.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Represents a translation resource with its namespace name and content
|
|
4
|
+
*/
|
|
5
|
+
interface ResourceContent {
|
|
6
|
+
[key: string]: string | ResourceContent;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Represents a translation resource with its namespace name and content
|
|
10
|
+
*/
|
|
11
|
+
interface Resource {
|
|
12
|
+
/**
|
|
13
|
+
* The namespace name (filename without extension)
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* The parsed JSON resources object
|
|
18
|
+
*/
|
|
19
|
+
resources: ResourceContent;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Resource, ResourceContent };
|
|
23
|
+
//# sourceMappingURL=i18n.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.cts","names":[],"sources":["../../src/types/i18n.ts"],"mappings":";;AAqBA;;UAAiB,eAAA;EAAA,CACd,GAAA,oBAAuB,eAAA;AAAA;AAM1B;;;AAAA,UAAiB,QAAA;EAIf;;;EAAA,IAAA;EAK0B;;;EAA1B,SAAA,EAAW,eAAA;AAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/types/i18n.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Represents a translation resource with its namespace name and content
|
|
4
|
+
*/
|
|
5
|
+
interface ResourceContent {
|
|
6
|
+
[key: string]: string | ResourceContent;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Represents a translation resource with its namespace name and content
|
|
10
|
+
*/
|
|
11
|
+
interface Resource {
|
|
12
|
+
/**
|
|
13
|
+
* The namespace name (filename without extension)
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* The parsed JSON resources object
|
|
18
|
+
*/
|
|
19
|
+
resources: ResourceContent;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Resource, ResourceContent };
|
|
23
|
+
//# sourceMappingURL=i18n.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.mts","names":[],"sources":["../../src/types/i18n.ts"],"mappings":";;AAqBA;;UAAiB,eAAA;EAAA,CACd,GAAA,oBAAuB,eAAA;AAAA;AAM1B;;;AAAA,UAAiB,QAAA;EAIf;;;EAAA,IAAA;EAK0B;;;EAA1B,SAAA,EAAW,eAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
File without changes
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig } from "./plugin.cjs";
|
|
2
|
+
import { Resource, ResourceContent } from "./i18n.cjs";
|
|
3
|
+
export { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig, Resource, ResourceContent };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig } from "./plugin.mjs";
|
|
2
|
+
import { Resource, ResourceContent } from "./i18n.mjs";
|
|
3
|
+
export { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig, Resource, ResourceContent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
|
|
2
|
+
import { DeepPartial } from "@stryke/types/base";
|
|
3
|
+
import { I18nextToolkitConfig } from "i18next-cli";
|
|
4
|
+
|
|
5
|
+
//#region src/types/plugin.d.ts
|
|
6
|
+
type I18NextPluginOptions = DeepPartial<I18nextToolkitConfig>;
|
|
7
|
+
type I18NextPluginUserConfig = UserConfig & {
|
|
8
|
+
i18next?: I18NextPluginOptions;
|
|
9
|
+
};
|
|
10
|
+
type I18NextPluginResolvedConfig = ResolvedConfig & {
|
|
11
|
+
i18next: Omit<I18nextToolkitConfig, "extract" | "types"> & {
|
|
12
|
+
extract: Omit<I18nextToolkitConfig["extract"], "output" | "primaryLanguage" | "indentation"> & Required<Pick<I18nextToolkitConfig["extract"], "output" | "primaryLanguage" | "indentation">>;
|
|
13
|
+
types: Omit<NonNullable<I18nextToolkitConfig["types"]>, "input" | "output" | "enableSelector" | "indentation"> & {
|
|
14
|
+
input?: string;
|
|
15
|
+
output?: string;
|
|
16
|
+
enableSelector: boolean | "optimize";
|
|
17
|
+
indentation: number | string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type I18NextPluginContext<TResolvedConfig extends I18NextPluginResolvedConfig = I18NextPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig };
|
|
24
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;KAsBY,oBAAA,GAAuB,WAAA,CAAY,oBAAA;AAAA,KAEnC,uBAAA,GAA0B,UAAA;EACpC,OAAA,GAAU,oBAAA;AAAA;AAAA,KAGA,2BAAA,GAA8B,cAAA;EACxC,OAAA,EAAS,IAAA,CAAK,oBAAA;IACZ,OAAA,EAAS,IAAA,CACP,oBAAA,6DAGA,QAAA,CACE,IAAA,CACE,oBAAA;IAIN,KAAA,EAAO,IAAA,CACL,WAAA,CAAY,oBAAA;MAGZ,KAAA;MACA,MAAA;MACA,cAAA;MACA,WAAA;IAAA;EAAA;AAAA;AAAA,KAKM,oBAAA,yBACc,2BAAA,GACtB,2BAAA,IACA,aAAA,CAAc,eAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { I18nextToolkitConfig } from "i18next-cli";
|
|
2
|
+
import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
|
|
3
|
+
import { DeepPartial } from "@stryke/types/base";
|
|
4
|
+
|
|
5
|
+
//#region src/types/plugin.d.ts
|
|
6
|
+
type I18NextPluginOptions = DeepPartial<I18nextToolkitConfig>;
|
|
7
|
+
type I18NextPluginUserConfig = UserConfig & {
|
|
8
|
+
i18next?: I18NextPluginOptions;
|
|
9
|
+
};
|
|
10
|
+
type I18NextPluginResolvedConfig = ResolvedConfig & {
|
|
11
|
+
i18next: Omit<I18nextToolkitConfig, "extract" | "types"> & {
|
|
12
|
+
extract: Omit<I18nextToolkitConfig["extract"], "output" | "primaryLanguage" | "indentation"> & Required<Pick<I18nextToolkitConfig["extract"], "output" | "primaryLanguage" | "indentation">>;
|
|
13
|
+
types: Omit<NonNullable<I18nextToolkitConfig["types"]>, "input" | "output" | "enableSelector" | "indentation"> & {
|
|
14
|
+
input?: string;
|
|
15
|
+
output?: string;
|
|
16
|
+
enableSelector: boolean | "optimize";
|
|
17
|
+
indentation: number | string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type I18NextPluginContext<TResolvedConfig extends I18NextPluginResolvedConfig = I18NextPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig };
|
|
24
|
+
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;KAsBY,oBAAA,GAAuB,WAAA,CAAY,oBAAA;AAAA,KAEnC,uBAAA,GAA0B,UAAA;EACpC,OAAA,GAAU,oBAAA;AAAA;AAAA,KAGA,2BAAA,GAA8B,cAAA;EACxC,OAAA,EAAS,IAAA,CAAK,oBAAA;IACZ,OAAA,EAAS,IAAA,CACP,oBAAA,6DAGA,QAAA,CACE,IAAA,CACE,oBAAA;IAIN,KAAA,EAAO,IAAA,CACL,WAAA,CAAY,oBAAA;MAGZ,KAAA;MACA,MAAA;MACA,cAAA;MACA,WAAA;IAAA;EAAA;AAAA;AAAA,KAKM,oBAAA,yBACc,2BAAA,GACtB,2BAAA,IACA,aAAA,CAAc,eAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-i18next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.263",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A Powerlines plugin to use i18next for internationalization.",
|
|
6
6
|
"keywords": ["i18next", "powerlines", "storm-software", "powerlines-plugin"],
|
|
@@ -111,12 +111,12 @@
|
|
|
111
111
|
"defu": "^6.1.4",
|
|
112
112
|
"i18next-cli": "^1.50.3",
|
|
113
113
|
"i18next-resources-for-ts": "^2.0.2",
|
|
114
|
-
"powerlines": "^0.42.
|
|
114
|
+
"powerlines": "^0.42.7"
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
117
|
+
"@powerlines/plugin-plugin": "^0.12.317",
|
|
118
118
|
"@types/node": "^25.5.0"
|
|
119
119
|
},
|
|
120
120
|
"publishConfig": { "access": "public" },
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "8c25b27c36407abbd22351d8a9afba5bce5abc08"
|
|
122
122
|
}
|