@open-xchange/rolldown-plugin-i18next-gettext 1.3.0 → 1.4.1
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/CHANGELOG.md +9 -0
- package/README.md +1 -0
- package/dist/index.d.mts +3 -10
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -14
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@ import i18nextPlugin from '@open-xchange/rolldown-plugin-i18next-gettext'
|
|
|
29
29
|
export default defineConfig(() => {
|
|
30
30
|
plugins: [
|
|
31
31
|
i18nextPlugin({
|
|
32
|
+
poFiles: 'i18n/**/*.po',
|
|
32
33
|
srcFiles: 'src/**/*.{js,jsx,ts,tsx}',
|
|
33
34
|
potFile: '[NAMESPACE].pot',
|
|
34
35
|
projectName: 'My Project',
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Plugin } from "rolldown";
|
|
2
|
-
|
|
3
2
|
//#region src/index.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Configuration options for the plugin '@open-xchange/rolldown-plugin-i18next-gettext'.
|
|
6
5
|
*/
|
|
7
|
-
interface PluginI18nextGettextOptions {
|
|
6
|
+
export interface PluginI18nextGettextOptions {
|
|
8
7
|
/**
|
|
9
8
|
* Glob pattern(s) for all PO files to be converted when imported in source
|
|
10
9
|
* code.
|
|
@@ -30,11 +29,6 @@ interface PluginI18nextGettextOptions {
|
|
|
30
29
|
* '[NAMESPACE].pot'
|
|
31
30
|
*/
|
|
32
31
|
potFile?: string;
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated
|
|
35
|
-
* Use option `potFile`.
|
|
36
|
-
*/
|
|
37
|
-
potFiles?: string;
|
|
38
32
|
/**
|
|
39
33
|
* The project name to be inserted into the POT files under the key
|
|
40
34
|
* 'Project-Id-Version'. May contain the placeholder `[NAMESPACE]`.
|
|
@@ -44,7 +38,7 @@ interface PluginI18nextGettextOptions {
|
|
|
44
38
|
/**
|
|
45
39
|
* Identifier of this plugin.
|
|
46
40
|
*/
|
|
47
|
-
declare const PROJECT_NAME = "@open-xchange/rolldown-plugin-i18next-gettext";
|
|
41
|
+
export declare const PROJECT_NAME = "@open-xchange/rolldown-plugin-i18next-gettext";
|
|
48
42
|
/**
|
|
49
43
|
* Rolldown plugin for using i18next with gettext `.po` files under the hood.
|
|
50
44
|
*
|
|
@@ -54,7 +48,6 @@ declare const PROJECT_NAME = "@open-xchange/rolldown-plugin-i18next-gettext";
|
|
|
54
48
|
* @returns
|
|
55
49
|
* The rolldown plugin object.
|
|
56
50
|
*/
|
|
57
|
-
|
|
51
|
+
export default function pluginI18nextGettext(options: PluginI18nextGettextOptions): Plugin;
|
|
58
52
|
//#endregion
|
|
59
|
-
export { PROJECT_NAME, PluginI18nextGettextOptions, pluginI18nextGettext as default };
|
|
60
53
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;iBAWiB;;;;;;;;EASf;;;;;;;;EASA;;;;;;;;;EAUA;;;;;EAMA;;;;;qBAQW;;;;;;;;;;wBAaW,qBAAqB,SAAS,8BAA8B"}
|
package/dist/index.mjs
CHANGED
|
@@ -15,19 +15,19 @@ const PROJECT_NAME = "@open-xchange/rolldown-plugin-i18next-gettext";
|
|
|
15
15
|
* The rolldown plugin object.
|
|
16
16
|
*/
|
|
17
17
|
function pluginI18nextGettext(options) {
|
|
18
|
-
const
|
|
18
|
+
const srcFiles = options.srcFiles ?? "src/**/*.{js,jsx,ts,tsx}";
|
|
19
|
+
const poFiles = options.poFiles ?? "**/*.po";
|
|
20
|
+
const potFile = options.potFile ?? "[NAMESPACE].pot";
|
|
19
21
|
return {
|
|
20
22
|
name: PROJECT_NAME,
|
|
21
23
|
load: {
|
|
22
24
|
filter: { id: poFiles },
|
|
23
|
-
async
|
|
24
|
-
return createJsonModule(await parsePoFile(id));
|
|
25
|
-
}
|
|
25
|
+
handler: async (id) => createJsonModule(await parsePoFile(id))
|
|
26
26
|
},
|
|
27
27
|
async generateBundle() {
|
|
28
28
|
const catalogs = await parseSourceFiles({
|
|
29
29
|
files: srcFiles,
|
|
30
|
-
project: projectName
|
|
30
|
+
project: options.projectName
|
|
31
31
|
});
|
|
32
32
|
if (catalogs.size > 1 && !potFile.includes("[NAMESPACE]")) this.error("multiple POT files written to same file location (missing placeholder `[NAMESPACE]` in option potFile)");
|
|
33
33
|
for (const [namespace, source] of catalogs) {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["\nimport type { Plugin, GeneralHookFilter } from 'rolldown'\nimport { createJsonModule } from '@open-xchange/rolldown-utils'\nimport { parsePoFile, parseSourceFiles } from '@open-xchange/i18next-po-parser'\n\n// types ======================================================================\n\n/**\n * Configuration options for the plugin '@open-xchange/rolldown-plugin-i18next-gettext'.\n */\nexport interface PluginI18nextGettextOptions {\n\n /**\n * Glob pattern(s) for all PO files to be converted when imported in source\n * code.\n *\n * @default\n * '**\\/*.po'\n */\n poFiles?: string | readonly string[]\n\n /**\n * Glob pattern(s) for all source files to be scanned for UI strings for the\n * POT file generator.\n *\n * @default\n * 'src/**\\/*.{js,jsx,ts,tsx}'\n */\n srcFiles?: string | readonly string[]\n\n /**\n * Path to and filename of the generated POT files, relative to the build\n * output directory. Must contain the placeholder `[NAMESPACE]` if the\n * project contains translation strings in different i18next namespaces.\n *\n * @default\n * '[NAMESPACE].pot'\n */\n potFile?: string\n\n /**\n *
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["\nimport type { Plugin, GeneralHookFilter } from 'rolldown'\nimport { createJsonModule } from '@open-xchange/rolldown-utils'\n\nimport { parsePoFile, parseSourceFiles } from '@open-xchange/i18next-po-parser'\n\n// types ======================================================================\n\n/**\n * Configuration options for the plugin '@open-xchange/rolldown-plugin-i18next-gettext'.\n */\nexport interface PluginI18nextGettextOptions {\n\n /**\n * Glob pattern(s) for all PO files to be converted when imported in source\n * code.\n *\n * @default\n * '**\\/*.po'\n */\n poFiles?: string | readonly string[]\n\n /**\n * Glob pattern(s) for all source files to be scanned for UI strings for the\n * POT file generator.\n *\n * @default\n * 'src/**\\/*.{js,jsx,ts,tsx}'\n */\n srcFiles?: string | readonly string[]\n\n /**\n * Path to and filename of the generated POT files, relative to the build\n * output directory. Must contain the placeholder `[NAMESPACE]` if the\n * project contains translation strings in different i18next namespaces.\n *\n * @default\n * '[NAMESPACE].pot'\n */\n potFile?: string\n\n /**\n * The project name to be inserted into the POT files under the key\n * 'Project-Id-Version'. May contain the placeholder `[NAMESPACE]`.\n */\n projectName: string\n}\n\n// constants ==================================================================\n\n/**\n * Identifier of this plugin.\n */\nexport const PROJECT_NAME = '@open-xchange/rolldown-plugin-i18next-gettext'\n\n// plugin =====================================================================\n\n/**\n * Rolldown plugin for using i18next with gettext `.po` files under the hood.\n *\n * @param options\n * Plugin configuration.\n *\n * @returns\n * The rolldown plugin object.\n */\nexport default function pluginI18nextGettext(options: PluginI18nextGettextOptions): Plugin {\n\n // resolve default options\n const srcFiles = options.srcFiles ?? 'src/**/*.{js,jsx,ts,tsx}'\n const poFiles = options.poFiles ?? '**/*.po'\n const potFile = options.potFile ?? '[NAMESPACE].pot'\n\n return {\n name: PROJECT_NAME,\n\n // convert PO files to i18next namespace records\n load: {\n filter: { id: poFiles as GeneralHookFilter },\n handler: async id => createJsonModule(await parsePoFile(id)),\n },\n\n // parse source files and create POT files per namespace\n async generateBundle() {\n\n // parse all source files and extract translations\n const catalogs = await parseSourceFiles({ files: srcFiles, project: options.projectName })\n\n // warn when writing multiple POT files to same file location\n if ((catalogs.size > 1) && !potFile.includes('[NAMESPACE]')) {\n this.error('multiple POT files written to same file location (missing placeholder `[NAMESPACE]` in option potFile)')\n }\n\n // add all POT files as assets to the bundle\n for (const [namespace, source] of catalogs) {\n const fileName = potFile.replaceAll('[NAMESPACE]', namespace)\n this.emitFile({ type: 'asset', fileName, source })\n }\n },\n }\n}\n"],"mappings":";;;;;;AAqDA,MAAa,eAAe;;;;;;;;;;AAa5B,SAAwB,qBAAqB,SAA8C;CAGzF,MAAM,WAAW,QAAQ,YAAY;CACrC,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,UAAU,QAAQ,WAAW;CAEnC,OAAO;EACL,MAAM;EAGN,MAAM;GACJ,QAAQ,EAAE,IAAI,QAA6B;GAC3C,SAAS,OAAM,OAAM,iBAAiB,MAAM,YAAY,EAAE,CAAC;EAC7D;EAGA,MAAM,iBAAiB;GAGrB,MAAM,WAAW,MAAM,iBAAiB;IAAE,OAAO;IAAU,SAAS,QAAQ;GAAY,CAAC;GAGzF,IAAK,SAAS,OAAO,KAAM,CAAC,QAAQ,SAAS,aAAa,GACxD,KAAK,MAAM,wGAAwG;GAIrH,KAAK,MAAM,CAAC,WAAW,WAAW,UAAU;IAC1C,MAAM,WAAW,QAAQ,WAAW,eAAe,SAAS;IAC5D,KAAK,SAAS;KAAE,MAAM;KAAS;KAAU;IAAO,CAAC;GACnD;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-xchange/rolldown-plugin-i18next-gettext",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Rolldown integration of i18next using gettext PO files",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://gitlab.
|
|
7
|
+
"url": "git+https://gitlab.com/openxchange/appsuite/documents/commons/plugins.git",
|
|
8
8
|
"directory": "packages/rolldown-plugin-i18next-gettext"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
@@ -19,25 +19,26 @@
|
|
|
19
19
|
"types": "./dist/client.d.ts"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
22
25
|
"files": [
|
|
23
26
|
"dist",
|
|
24
27
|
"CHANGELOG.*"
|
|
25
28
|
],
|
|
26
29
|
"dependencies": {
|
|
27
|
-
"@open-xchange/i18next-po-parser": "^1.
|
|
28
|
-
"@open-xchange/rolldown-utils": "^1.2.
|
|
30
|
+
"@open-xchange/i18next-po-parser": "^1.5.1",
|
|
31
|
+
"@open-xchange/rolldown-utils": "^1.2.1"
|
|
29
32
|
},
|
|
30
33
|
"devDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"rolldown": "^1.
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"@open-xchange/tsconfig": "^0.1.0",
|
|
40
|
-
"@open-xchange/vitest-plugin-utils": "^1.2.0"
|
|
34
|
+
"@open-xchange/bundler-testutils": "^1.6.0",
|
|
35
|
+
"@open-xchange/linter-presets": "^1.30.4",
|
|
36
|
+
"@open-xchange/rolldown-plugin-dynamic-import-vars": "^1.3.1",
|
|
37
|
+
"@open-xchange/tsconfig": "^0.2.3",
|
|
38
|
+
"i18next": "^26.4.2",
|
|
39
|
+
"rolldown": "^1.2.7",
|
|
40
|
+
"tsdown": "^0.23.0",
|
|
41
|
+
"vitest": "^5.0.0"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"rolldown": "*",
|