@powerlines/plugin-i18next 0.1.187 → 0.1.188
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.cjs +13 -12
- package/dist/index.d.cts +6 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +6 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +13 -12
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.d.cts +1 -3
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +1 -3
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,7 @@ const plugin = (options = {}) => {
|
|
|
30
30
|
name: "i18next",
|
|
31
31
|
async config() {
|
|
32
32
|
const i18next = (0, defu.default)(options, { extract: {
|
|
33
|
-
output: (language, namespace = "translation") => (0, __stryke_path_join.joinPaths)(this.config.
|
|
33
|
+
output: (language, namespace = "translation") => (0, __stryke_path_join.joinPaths)(this.config.root, `locales/${language}/${namespace}.json`),
|
|
34
34
|
primaryLanguage: this.workspaceConfig.locale
|
|
35
35
|
} }, {
|
|
36
36
|
extract: {
|
|
@@ -60,16 +60,17 @@ const plugin = (options = {}) => {
|
|
|
60
60
|
isWatchMode: false,
|
|
61
61
|
isDryRun: false,
|
|
62
62
|
syncAll: true,
|
|
63
|
-
syncPrimaryWithDefaults: true
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
+
}
|
|
73
74
|
}
|
|
74
75
|
});
|
|
75
76
|
},
|
|
@@ -94,7 +95,7 @@ const plugin = (options = {}) => {
|
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
97
|
let result;
|
|
97
|
-
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.
|
|
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, {
|
|
98
99
|
optimize: !!this.config.i18next.types.enableSelector,
|
|
99
100
|
indentation: this.config.i18next.types.indentation
|
|
100
101
|
}));
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig } from "./types/plugin.cjs";
|
|
2
2
|
import { Resource, ResourceContent } from "./types/i18n.cjs";
|
|
3
3
|
import "./types/index.cjs";
|
|
4
|
-
import { Plugin } from "powerlines
|
|
4
|
+
import { Plugin } from "powerlines";
|
|
5
5
|
|
|
6
6
|
//#region src/index.d.ts
|
|
7
|
-
|
|
7
|
+
declare module "powerlines" {
|
|
8
|
+
interface UserConfig {
|
|
9
|
+
i18next?: I18NextPluginOptions;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
8
12
|
/**
|
|
9
13
|
* i18next Plugin
|
|
10
14
|
*
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAyCc;EAJU;;;;;AAmBxB;;;;;;;;cAAa,0BACM,uBAAuB,gCAE/B,yBACR,OAAO"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig } from "./types/plugin.mjs";
|
|
2
2
|
import { Resource, ResourceContent } from "./types/i18n.mjs";
|
|
3
3
|
import "./types/index.mjs";
|
|
4
|
-
import { Plugin } from "powerlines
|
|
4
|
+
import { Plugin } from "powerlines";
|
|
5
5
|
|
|
6
6
|
//#region src/index.d.ts
|
|
7
|
-
|
|
7
|
+
declare module "powerlines" {
|
|
8
|
+
interface UserConfig {
|
|
9
|
+
i18next?: I18NextPluginOptions;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
8
12
|
/**
|
|
9
13
|
* i18next Plugin
|
|
10
14
|
*
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAyCc;EAJU;;;;;AAmBxB;;;;;;;;cAAa,0BACM,uBAAuB,gCAE/B,yBACR,OAAO"}
|
package/dist/index.mjs
CHANGED
|
@@ -27,7 +27,7 @@ const plugin = (options = {}) => {
|
|
|
27
27
|
name: "i18next",
|
|
28
28
|
async config() {
|
|
29
29
|
const i18next = defu(options, { extract: {
|
|
30
|
-
output: (language, namespace = "translation") => joinPaths(this.config.
|
|
30
|
+
output: (language, namespace = "translation") => joinPaths(this.config.root, `locales/${language}/${namespace}.json`),
|
|
31
31
|
primaryLanguage: this.workspaceConfig.locale
|
|
32
32
|
} }, {
|
|
33
33
|
extract: {
|
|
@@ -57,16 +57,17 @@ const plugin = (options = {}) => {
|
|
|
57
57
|
isWatchMode: false,
|
|
58
58
|
isDryRun: false,
|
|
59
59
|
syncAll: true,
|
|
60
|
-
syncPrimaryWithDefaults: true
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
+
}
|
|
70
71
|
}
|
|
71
72
|
});
|
|
72
73
|
},
|
|
@@ -91,7 +92,7 @@ const plugin = (options = {}) => {
|
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
94
|
let result;
|
|
94
|
-
if (this.config.i18next.types.resourcesFile) await this.fs.write(appendPath(this.config.i18next.types.resourcesFile, this.config.i18next.types.output || this.config.
|
|
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, {
|
|
95
96
|
optimize: !!this.config.i18next.types.enableSelector,
|
|
96
97
|
indentation: this.config.i18next.types.indentation
|
|
97
98
|
}));
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["resources: Resource[]","result!: string"],"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/types/plugin\";\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\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.projectRoot,\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(\n this.config.i18next as I18nextToolkitConfig,\n {\n isWatchMode: false,\n isDryRun: false,\n syncAll: true,\n syncPrimaryWithDefaults: true\n },\n {\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.projectRoot\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":";;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAa,UAGX,UAAgC,EAAE,KACb;AACrB,QAAO;EACL,MAAM;EACN,MAAM,SAAS;GACb,MAAM,UAAU,KAId,SACA,EACE,SAAS;IACP,SAAS,UAAkB,YAAY,kBACrC,UACE,KAAK,OAAO,aACZ,WAAW,SAAS,GAAG,UAAU,OAClC;IACH,iBAAiB,KAAK,gBAAgB;IACvC,EACF,EACD;IACE,SAAS;KACP,OAAO;MACL;MACA;MACA;MACA;MACD;KACD,aAAa;KACb,WAAW;KACX,iBAAiB;KACjB,aAAa;KACb,cAAc;KACd,iBACE,QAAQ,WAAW,QAAQ,QAAQ,SAAS,IACxC,QAAQ,QAAQ,KAChB;KACP;IACD,OAAO,EACL,gBAAgB,OACjB;IACD,SAAS,EAAE;IACZ,CACF;AAED,OAAI,CAAC,QAAQ,WAAW,QAAQ,QAAQ,WAAW,EACjD,SAAQ,UAAU,CAAC,QAAQ,QAAQ,mBAAmB,KAAK;AAG7D,OAAI,CAAC,MAAM,QAAQ,MAAM,YAAY,CACnC,S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,KAAK,OAAO,QAAQ,MAAM,cAC5B,OAAM,KAAK,GAAG,MACZ,WACE,KAAK,OAAO,QAAQ,MAAM,eAC1B,KAAK,OAAO,QAAQ,MAAM,UAAU,KAAK,OAAO,YACjD,EACD,0BAA0B,WAAW;IACnC,UAAU,CAAC,CAAC,KAAK,OAAO,QAAQ,MAAM;IACtC,aAAa,KAAK,OAAO,QAAQ,MAAM;IACxC,CAAC,CACH;OAED,UAAS,GAAG,KAAK;;EAEvB,0BAA0B,WAAW;IACrC,UAAU,CAAC,CAAC,KAAK,OAAO,QAAQ,MAAM;IACtC,aAAa,KAAK,OAAO,QAAQ,MAAM;IACxC,CAAC,CAAC;;;;;;;;;sBASmB,SAAS,KAAK,OAAO,QAAQ,MAAM,eAAe,GAAG,IAAI,KAAK,OAAO,QAAQ,MAAM,eAAe,KAAK,KAAK,OAAO,QAAQ,MAAM,eAAe;iBAEhK,KAAK,OAAO,QAAQ,QAAQ,cAAc,QACtC,UACA,IAAI,KAAK,OAAO,QAAQ,QAAQ,aAAa,cAAc,GAChE;;;;;AAOC,UAAO;;EAEV;;AAGH,kBAAe"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["resources: Resource[]","result!: string"],"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 export interface UserConfig {\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":";;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAa,UAGX,UAAgC,EAAE,KACb;AACrB,QAAO;EACL,MAAM;EACN,MAAM,SAAS;GACb,MAAM,UAAU,KAId,SACA,EACE,SAAS;IACP,SAAS,UAAkB,YAAY,kBACrC,UACE,KAAK,OAAO,MACZ,WAAW,SAAS,GAAG,UAAU,OAClC;IACH,iBAAiB,KAAK,gBAAgB;IACvC,EACF,EACD;IACE,SAAS;KACP,OAAO;MACL;MACA;MACA;MACA;MACD;KACD,aAAa;KACb,WAAW;KACX,iBAAiB;KACjB,aAAa;KACb,cAAc;KACd,iBACE,QAAQ,WAAW,QAAQ,QAAQ,SAAS,IACxC,QAAQ,QAAQ,KAChB;KACP;IACD,OAAO,EACL,gBAAgB,OACjB;IACD,SAAS,EAAE;IACZ,CACF;AAED,OAAI,CAAC,QAAQ,WAAW,QAAQ,QAAQ,WAAW,EACjD,SAAQ,UAAU,CAAC,QAAQ,QAAQ,mBAAmB,KAAK;AAG7D,OAAI,CAAC,MAAM,QAAQ,MAAM,YAAY,CACnC,SAAQ,MAAM,cAAc,QAAQ,QAAQ;AAG9C,UAAO,EACL,SACD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AK,GAAG,MACZ,WACE,KAAK,OAAO,QAAQ,MAAM,eAC1B,KAAK,OAAO,QAAQ,MAAM,UAAU,KAAK,OAAO,KACjD,EACD,0BAA0B,WAAW;IACnC,UAAU,CAAC,CAAC,KAAK,OAAO,QAAQ,MAAM;IACtC,aAAa,KAAK,OAAO,QAAQ,MAAM;IACxC,CAAC,CACH;OAED,UAAS,GAAG,KAAK;;EAEvB,0BAA0B,WAAW;IACrC,UAAU,CAAC,CAAC,KAAK,OAAO,QAAQ,MAAM;IACtC,aAAa,KAAK,OAAO,QAAQ,MAAM;IACxC,CAAC,CAAC;;;;;;;;;sBASmB,SAAS,KAAK,OAAO,QAAQ,MAAM,eAAe,GAAG,IAAI,KAAK,OAAO,QAAQ,MAAM,eAAe,KAAK,KAAK,OAAO,QAAQ,MAAM,eAAe;iBAEhK,KAAK,OAAO,QAAQ,QAAQ,cAAc,QACtC,UACA,IAAI,KAAK,OAAO,QAAQ,QAAQ,aAAa,cAAc,GAChE;;;;;AAOC,UAAO;;EAEV;;AAGH,kBAAe"}
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
|
|
1
2
|
import { DeepPartial } from "@stryke/types/base";
|
|
2
3
|
import { I18nextToolkitConfig } from "i18next-cli";
|
|
3
|
-
import { UserConfig } from "powerlines/types/config";
|
|
4
|
-
import { PluginContext } from "powerlines/types/context";
|
|
5
|
-
import { ResolvedConfig } from "powerlines/types/resolved";
|
|
6
4
|
|
|
7
5
|
//#region src/types/plugin.d.ts
|
|
8
6
|
type I18NextPluginOptions = DeepPartial<I18nextToolkitConfig>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;KAsBY,oBAAA,GAAuB,YAAY;KAEnC,uBAAA,GAA0B;EAF1B,OAAA,CAAA,EAGA,oBAHoB;AAEhC,CAAA;AAIY,KAAA,2BAAA,GAA8B,cAAH,GAAA;EAAG,OAAA,EAC/B,IAD+B,CAC1B,oBAD0B,EAAA,SAAA,GAAA,OAAA,CAAA,GAAA;IAC1B,OAAA,EACH,IADG,CAEV,oBAFU,CAAA,SAAA,CAAA,EAAA,QAAA,GAAA,iBAAA,GAAA,aAAA,CAAA,GAKV,QALU,CAMR,IANQ,CAON,oBAPM,CAAA,SAAA,CAAA,EAAA,QAAA,GAAA,iBAAA,GAAA,aAAA,CAAA,CAAA;IAAL,KAAA,EAWA,IAXA,CAYL,WAZK,CAYO,oBAZP,CAAA,OAAA,CAAA,CAAA,EAAA,OAAA,GAAA,QAAA,GAAA,gBAAA,GAAA,aAAA,CAAA,GAAA;MAEL,KAAA,CAAA,EAAA,MAAA;MADO,MAAA,CAAA,EAAA,MAAA;MAMH,cAAA,EAAA,OAAA,GAAA,UAAA;MADF,WAAA,EAAA,MAAA,GAAA,MAAA;IADF,CAAA;EAOY,CAAA;CAAZ;AADK,KAYC,oBAZD,CAAA,wBAae,2BAbf,GAcP,2BAdO,CAAA,GAeP,aAfO,CAeO,eAfP,CAAA"}
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { I18nextToolkitConfig } from "i18next-cli";
|
|
2
|
+
import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
|
|
2
3
|
import { DeepPartial } from "@stryke/types/base";
|
|
3
|
-
import { UserConfig } from "powerlines/types/config";
|
|
4
|
-
import { PluginContext } from "powerlines/types/context";
|
|
5
|
-
import { ResolvedConfig } from "powerlines/types/resolved";
|
|
6
4
|
|
|
7
5
|
//#region src/types/plugin.d.ts
|
|
8
6
|
type I18NextPluginOptions = DeepPartial<I18nextToolkitConfig>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;KAsBY,oBAAA,GAAuB,YAAY;KAEnC,uBAAA,GAA0B;EAF1B,OAAA,CAAA,EAGA,oBAHoB;AAEhC,CAAA;AAIY,KAAA,2BAAA,GAA8B,cAAH,GAAA;EAAG,OAAA,EAC/B,IAD+B,CAC1B,oBAD0B,EAAA,SAAA,GAAA,OAAA,CAAA,GAAA;IAC1B,OAAA,EACH,IADG,CAEV,oBAFU,CAAA,SAAA,CAAA,EAAA,QAAA,GAAA,iBAAA,GAAA,aAAA,CAAA,GAKV,QALU,CAMR,IANQ,CAON,oBAPM,CAAA,SAAA,CAAA,EAAA,QAAA,GAAA,iBAAA,GAAA,aAAA,CAAA,CAAA;IAAL,KAAA,EAWA,IAXA,CAYL,WAZK,CAYO,oBAZP,CAAA,OAAA,CAAA,CAAA,EAAA,OAAA,GAAA,QAAA,GAAA,gBAAA,GAAA,aAAA,CAAA,GAAA;MAEL,KAAA,CAAA,EAAA,MAAA;MADO,MAAA,CAAA,EAAA,MAAA;MAMH,cAAA,EAAA,OAAA,GAAA,UAAA;MADF,WAAA,EAAA,MAAA,GAAA,MAAA;IADF,CAAA;EAOY,CAAA;CAAZ;AADK,KAYC,oBAZD,CAAA,wBAae,2BAbf,GAcP,2BAdO,CAAA,GAeP,aAfO,CAeO,eAfP,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-i18next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.188",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Powerlines plugin to use i18next for internationalization.",
|
|
6
6
|
"repository": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"default": "./dist/index.mjs"
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
|
-
"
|
|
58
|
+
"./*": "./*",
|
|
59
59
|
"./types": {
|
|
60
60
|
"require": {
|
|
61
61
|
"types": "./dist/types/index.d.cts",
|
|
@@ -107,15 +107,15 @@
|
|
|
107
107
|
"@stryke/path": "^0.26.6",
|
|
108
108
|
"@stryke/types": "^0.10.39",
|
|
109
109
|
"defu": "^6.1.4",
|
|
110
|
-
"i18next-cli": "^1.46.
|
|
110
|
+
"i18next-cli": "^1.46.2",
|
|
111
111
|
"i18next-resources-for-ts": "^2.0.0",
|
|
112
|
-
"powerlines": "^0.
|
|
112
|
+
"powerlines": "^0.39.0"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
116
|
-
"@types/node": "^25.3.
|
|
115
|
+
"@powerlines/plugin-plugin": "^0.12.242",
|
|
116
|
+
"@types/node": "^25.3.2"
|
|
117
117
|
},
|
|
118
118
|
"publishConfig": { "access": "public" },
|
|
119
119
|
"types": "./dist/index.d.cts",
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "0dcb16f054b8a69915b074578e6d4dfa3ecc1529"
|
|
121
121
|
}
|