@open-xchange/rolldown-plugin-i18next-gettext 1.2.0 → 1.2.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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## `1.2.1` – 2026-Apr-20
4
+
5
+ - fixed: name of option `potFile` for compatibility with old plugin
6
+
3
7
  ## `1.2.0` – 2026-Apr-15
4
8
 
5
9
  - added: switched back to direct imports of PO files
package/README.md CHANGED
@@ -30,7 +30,7 @@ export default defineConfig(() => {
30
30
  plugins: [
31
31
  i18nextPlugin({
32
32
  srcFiles: 'src/**/*.{js,jsx,ts,tsx}',
33
- potFiles: '[NAMESPACE].pot',
33
+ potFile: '[NAMESPACE].pot',
34
34
  projectName: 'My Project',
35
35
  }),
36
36
  ],
@@ -43,7 +43,7 @@ export default defineConfig(() => {
43
43
  | - | - | - | - |
44
44
  | `poFiles` | `string\|string[]` | `**/*.po` | Glob pattern(s) for all PO files to be converted when imported in source code. |
45
45
  | `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
- | `potFiles` | `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. |
46
+ | `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. |
47
47
  | `projectName` | `string` | _required_ | The project name to be inserted into the POT file under the key 'Project-Id-Version'. May contain the placeholder `[NAMESPACE]` |
48
48
 
49
49
  ## Usage
package/dist/index.d.mts CHANGED
@@ -29,6 +29,11 @@ interface PluginI18nextGettextOptions {
29
29
  * @default
30
30
  * '[NAMESPACE].pot'
31
31
  */
32
+ potFile?: string;
33
+ /**
34
+ * @deprecated
35
+ * Use option `potFile`.
36
+ */
32
37
  potFiles?: string;
33
38
  /**
34
39
  * The project name to be inserted into the POT files under the key
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;AAUA;UAAiB,2BAAA;;;;;;;;EASf,OAAA;EAiCW;;;;;AAA8D;;EAxBzE,QAAA;EAqCwF;;;;;;;;EA3BxF,QAAA;;;;;EAMA,WAAA;AAAA;;;;cAQW,YAAA;;;;;;;;;;iBAaW,oBAAA,CAAqB,OAAA,EAAS,2BAAA,GAA8B,MAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;AAUA;UAAiB,2BAAA;;;;;;;;EASf,OAAA;EA+BW;AAQb;;;;;AAA2E;EA9BzE,QAAA;;;;;;;;;EAUA,OAAA;;;;;EAMA,QAAA;;;;;EAMA,WAAA;AAAA;;;;cAQW,YAAA;;;;;;;;;;iBAaW,oBAAA,CAAqB,OAAA,EAAS,2BAAA,GAA8B,MAAA"}
package/dist/index.mjs CHANGED
@@ -15,7 +15,7 @@ const PROJECT_NAME = "@open-xchange/rolldown-plugin-i18next-gettext";
15
15
  * The rolldown plugin object.
16
16
  */
17
17
  function pluginI18nextGettext(options) {
18
- const { poFiles = "**/*.po", srcFiles = "src/**/*.{js,jsx,ts,tsx}", potFiles = "[NAMESPACE].pot", projectName } = options;
18
+ const { poFiles = "**/*.po", srcFiles = "src/**/*.{js,jsx,ts,tsx}", potFile = options.potFiles ?? "[NAMESPACE].pot", projectName } = options;
19
19
  return {
20
20
  name: PROJECT_NAME,
21
21
  load: {
@@ -29,9 +29,9 @@ function pluginI18nextGettext(options) {
29
29
  files: srcFiles,
30
30
  project: projectName
31
31
  });
32
- if (catalogs.size > 1 && !potFiles.includes("[NAMESPACE]")) this.error("multiple POT files written to same file location (missing placeholder `[NAMESPACE]` in option potFile)");
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) {
34
- const fileName = potFiles.replaceAll("[NAMESPACE]", namespace);
34
+ const fileName = potFile.replaceAll("[NAMESPACE]", namespace);
35
35
  this.emitFile({
36
36
  type: "asset",
37
37
  fileName,
@@ -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 potFiles?: 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 {\n poFiles = '**/*.po',\n srcFiles = 'src/**/*.{js,jsx,ts,tsx}',\n potFiles = '[NAMESPACE].pot',\n projectName,\n } = options\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 async handler(id) {\n return createJsonModule(await parsePoFile(id))\n },\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: projectName })\n\n // warn when writing multiple POT files to same file location\n if ((catalogs.size > 1) && !potFiles.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 = potFiles.replaceAll('[NAMESPACE]', namespace)\n this.emitFile({ type: 'asset', fileName, source })\n }\n },\n }\n}\n"],"mappings":";;;;;;AAoDA,MAAa,eAAe;;;;;;;;;;AAa5B,SAAwB,qBAAqB,SAA8C;CAGzF,MAAM,EACJ,UAAU,WACV,WAAW,4BACX,WAAW,mBACX,gBACE;AAEJ,QAAO;EACL,MAAM;EAGN,MAAM;GACJ,QAAQ,EAAE,IAAI,SAA8B;GAC5C,MAAM,QAAQ,IAAI;AAChB,WAAO,iBAAiB,MAAM,YAAY,GAAG,CAAC;;GAEjD;EAGD,MAAM,iBAAiB;GAGrB,MAAM,WAAW,MAAM,iBAAiB;IAAE,OAAO;IAAU,SAAS;IAAa,CAAC;AAGlF,OAAK,SAAS,OAAO,KAAM,CAAC,SAAS,SAAS,cAAc,CAC1D,MAAK,MAAM,yGAAyG;AAItH,QAAK,MAAM,CAAC,WAAW,WAAW,UAAU;IAC1C,MAAM,WAAW,SAAS,WAAW,eAAe,UAAU;AAC9D,SAAK,SAAS;KAAE,MAAM;KAAS;KAAU;KAAQ,CAAC;;;EAGvD"}
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 * @deprecated\n * Use option `potFile`.\n */\n potFiles?: 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 {\n poFiles = '**/*.po',\n srcFiles = 'src/**/*.{js,jsx,ts,tsx}',\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n potFile = options.potFiles ?? '[NAMESPACE].pot',\n projectName,\n } = options\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 async handler(id) {\n return createJsonModule(await parsePoFile(id))\n },\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: 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":";;;;;;AA0DA,MAAa,eAAe;;;;;;;;;;AAa5B,SAAwB,qBAAqB,SAA8C;CAGzF,MAAM,EACJ,UAAU,WACV,WAAW,4BAEX,UAAU,QAAQ,YAAY,mBAC9B,gBACE;AAEJ,QAAO;EACL,MAAM;EAGN,MAAM;GACJ,QAAQ,EAAE,IAAI,SAA8B;GAC5C,MAAM,QAAQ,IAAI;AAChB,WAAO,iBAAiB,MAAM,YAAY,GAAG,CAAC;;GAEjD;EAGD,MAAM,iBAAiB;GAGrB,MAAM,WAAW,MAAM,iBAAiB;IAAE,OAAO;IAAU,SAAS;IAAa,CAAC;AAGlF,OAAK,SAAS,OAAO,KAAM,CAAC,QAAQ,SAAS,cAAc,CACzD,MAAK,MAAM,yGAAyG;AAItH,QAAK,MAAM,CAAC,WAAW,WAAW,UAAU;IAC1C,MAAM,WAAW,QAAQ,WAAW,eAAe,UAAU;AAC7D,SAAK,SAAS;KAAE,MAAM;KAAS;KAAU;KAAQ,CAAC;;;EAGvD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/rolldown-plugin-i18next-gettext",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Rolldown integration of i18next using gettext PO files",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,14 +29,14 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@open-xchange/rolldown-plugin-dynamic-import-vars": "^1.0.2",
32
- "@vitest/coverage-v8": "^4.1.3",
33
- "i18next": "^26.0.4",
32
+ "@vitest/coverage-v8": "^4.1.4",
33
+ "i18next": "^26.0.5",
34
34
  "rolldown": "^1.0.0-rc.15",
35
35
  "tsdown": "^0.21.8",
36
- "vitest": "^4.1.3",
37
- "@open-xchange/vitest-plugin-extended": "^1.6.0",
36
+ "vitest": "^4.1.4",
38
37
  "@open-xchange/vitest-plugin-utils": "^1.1.1",
39
38
  "@open-xchange/linter-presets": "^1.22.0",
39
+ "@open-xchange/vitest-plugin-extended": "^1.6.0",
40
40
  "@open-xchange/tsconfig": "^0.0.3"
41
41
  },
42
42
  "peerDependencies": {