@open-xchange/rolldown-plugin-i18next-gettext 1.4.0 → 1.4.2
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 +8 -0
- package/README.md +1 -1
- package/dist/index.d.mts +4 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## `1.4.2` – 2026-Sep-20
|
|
4
|
+
|
|
5
|
+
- fixed: option `srcFiles` is now resolved against rolldown's resolved `cwd` option
|
|
6
|
+
|
|
7
|
+
## `1.4.1` – 2026-Sep-13
|
|
8
|
+
|
|
9
|
+
- chore: migrate to gitlab.com
|
|
10
|
+
|
|
3
11
|
## `1.4.0` – 2026-Aug-07
|
|
4
12
|
|
|
5
13
|
- removed: deprecated option `potFiles`
|
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ export default defineConfig(() => {
|
|
|
43
43
|
| Name | Type | Default | Description |
|
|
44
44
|
| - | - | - | - |
|
|
45
45
|
| `poFiles` | `string\|string[]` | `**/*.po` | Glob pattern(s) for all PO files to be converted when imported in source code. |
|
|
46
|
-
| `srcFiles` | `string\|string[]` | `src/**/*.{js,jsx,ts,tsx}` | Glob pattern(s) for all source files to be scanned for UI strings for the POT file generator. |
|
|
46
|
+
| `srcFiles` | `string\|string[]` | `src/**/*.{js,jsx,ts,tsx}` | Glob pattern(s) for all source files to be scanned for UI strings for the POT file generator. Resolved against rolldown's resolved `cwd` option. |
|
|
47
47
|
| `potFile` | `string` | `[NAMESPACE].pot` | Path to and filename of the generated POT files, relative to the build output directory. Must contain the placeholder `[NAMESPACE]` if the project contains translation strings in different i18next namespaces. |
|
|
48
48
|
| `projectName` | `string` | _required_ | The project name to be inserted into the POT file under the key 'Project-Id-Version'. May contain the placeholder `[NAMESPACE]` |
|
|
49
49
|
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { Plugin } from "rolldown";
|
|
|
3
3
|
/**
|
|
4
4
|
* Configuration options for the plugin '@open-xchange/rolldown-plugin-i18next-gettext'.
|
|
5
5
|
*/
|
|
6
|
-
interface PluginI18nextGettextOptions {
|
|
6
|
+
export interface PluginI18nextGettextOptions {
|
|
7
7
|
/**
|
|
8
8
|
* Glob pattern(s) for all PO files to be converted when imported in source
|
|
9
9
|
* code.
|
|
@@ -14,7 +14,7 @@ interface PluginI18nextGettextOptions {
|
|
|
14
14
|
poFiles?: string | readonly string[];
|
|
15
15
|
/**
|
|
16
16
|
* Glob pattern(s) for all source files to be scanned for UI strings for the
|
|
17
|
-
* POT file generator.
|
|
17
|
+
* POT file generator. Resolved against rolldown's resolved `cwd` option.
|
|
18
18
|
*
|
|
19
19
|
* @default
|
|
20
20
|
* 'src/**\/*.{js,jsx,ts,tsx}'
|
|
@@ -38,7 +38,7 @@ interface PluginI18nextGettextOptions {
|
|
|
38
38
|
/**
|
|
39
39
|
* Identifier of this plugin.
|
|
40
40
|
*/
|
|
41
|
-
declare const PROJECT_NAME = "@open-xchange/rolldown-plugin-i18next-gettext";
|
|
41
|
+
export declare const PROJECT_NAME = "@open-xchange/rolldown-plugin-i18next-gettext";
|
|
42
42
|
/**
|
|
43
43
|
* Rolldown plugin for using i18next with gettext `.po` files under the hood.
|
|
44
44
|
*
|
|
@@ -48,7 +48,6 @@ declare const PROJECT_NAME = "@open-xchange/rolldown-plugin-i18next-gettext";
|
|
|
48
48
|
* @returns
|
|
49
49
|
* The rolldown plugin object.
|
|
50
50
|
*/
|
|
51
|
-
|
|
51
|
+
export default function pluginI18nextGettext(options: PluginI18nextGettextOptions): Plugin;
|
|
52
52
|
//#endregion
|
|
53
|
-
export { PROJECT_NAME, PluginI18nextGettextOptions, pluginI18nextGettext as default };
|
|
54
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
|
@@ -18,14 +18,19 @@ function pluginI18nextGettext(options) {
|
|
|
18
18
|
const srcFiles = options.srcFiles ?? "src/**/*.{js,jsx,ts,tsx}";
|
|
19
19
|
const poFiles = options.poFiles ?? "**/*.po";
|
|
20
20
|
const potFile = options.potFile ?? "[NAMESPACE].pot";
|
|
21
|
+
let cwd;
|
|
21
22
|
return {
|
|
22
23
|
name: PROJECT_NAME,
|
|
24
|
+
buildStart(inputOptions) {
|
|
25
|
+
cwd = inputOptions.cwd;
|
|
26
|
+
},
|
|
23
27
|
load: {
|
|
24
28
|
filter: { id: poFiles },
|
|
25
29
|
handler: async (id) => createJsonModule(await parsePoFile(id))
|
|
26
30
|
},
|
|
27
31
|
async generateBundle() {
|
|
28
32
|
const catalogs = await parseSourceFiles({
|
|
33
|
+
cwd,
|
|
29
34
|
files: srcFiles,
|
|
30
35
|
project: options.projectName
|
|
31
36
|
});
|
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'\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;
|
|
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. Resolved against rolldown's resolved `cwd` option.\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 // the resolved rolldown \"cwd\" option, captured in \"buildStart\"\n let cwd: string\n\n return {\n name: PROJECT_NAME,\n\n // fetch resolved \"cwd\" option\n buildStart(inputOptions) {\n cwd = inputOptions.cwd\n },\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({ cwd, 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;CAGnC,IAAI;CAEJ,OAAO;EACL,MAAM;EAGN,WAAW,cAAc;GACvB,MAAM,aAAa;EACrB;EAGA,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;IAAK,OAAO;IAAU,SAAS,QAAQ;GAAY,CAAC;GAG9F,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.4.
|
|
3
|
+
"version": "1.4.2",
|
|
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",
|
|
@@ -27,20 +27,18 @@
|
|
|
27
27
|
"CHANGELOG.*"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@open-xchange/
|
|
31
|
-
"@open-xchange/
|
|
30
|
+
"@open-xchange/i18next-po-parser": "^1.6.0",
|
|
31
|
+
"@open-xchange/rolldown-utils": "^1.2.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"
|
|
36
|
-
"rolldown": "^1.
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"@open-xchange/linter-presets": "^1.29.1",
|
|
43
|
-
"@open-xchange/vitest-plugin-utils": "^1.2.0"
|
|
34
|
+
"@open-xchange/bundler-testutils": "^2.0.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.9",
|
|
40
|
+
"tsdown": "^0.23.0",
|
|
41
|
+
"vitest": "^5.0.1"
|
|
44
42
|
},
|
|
45
43
|
"peerDependencies": {
|
|
46
44
|
"rolldown": "*",
|