@intlayer/sync-po-plugin 8.9.4

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.
@@ -0,0 +1,81 @@
1
+ import { Locale } from "@intlayer/types/allLocales";
2
+ import { DictionaryFormat } from "@intlayer/types/dictionary";
3
+ import { FilePathPattern } from "@intlayer/types/filePathPattern";
4
+ import { Plugin } from "@intlayer/types/plugin";
5
+
6
+ //#region src/loadJSON.d.ts
7
+ type LoadJSONPluginOptions = {
8
+ /**
9
+ * The source of the plugin.
10
+ * Is a function to build the source from the key and locale.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * loadJSON({
15
+ * source: ({ key }) => `blog/${'**'}/${key}.i18n.json`,
16
+ * })
17
+ * ```
18
+ */
19
+ source: FilePathPattern;
20
+ /**
21
+ * Locale
22
+ *
23
+ * If not provided, the plugin will consider the default locale.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * loadJSON({
28
+ * source: ({ key }) => `blog/${'**'}/${key}.i18n.json`,
29
+ * locale: Locales.ENGLISH,
30
+ * })
31
+ * ```
32
+ */
33
+ locale?: Locale;
34
+ /**
35
+ * Because Intlayer transform the JSON files into Dictionary, we need to identify the plugin in the dictionary.
36
+ * Used to identify the plugin in the dictionary.
37
+ *
38
+ * In the case you have multiple plugins, you can use this to identify the plugin in the dictionary.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const config = {
43
+ * plugins: [
44
+ * loadJSON({
45
+ * source: ({ key }) => `./resources/${key}.json`,
46
+ * location: 'plugin-i18next',
47
+ * }),
48
+ * loadJSON({
49
+ * source: ({ key }) => `./messages/${key}.json`,
50
+ * location: 'plugin-next-intl',
51
+ * }),
52
+ * ]
53
+ * }
54
+ * ```
55
+ */
56
+ location?: string;
57
+ /**
58
+ * The priority of the dictionaries created by the plugin.
59
+ *
60
+ * In the case of conflicts with remote dictionaries, or .content files, the dictionary with the highest priority will override the other dictionaries.
61
+ *
62
+ * Default is -1. (.content file priority is 0)
63
+ *
64
+ */
65
+ priority?: number;
66
+ /**
67
+ * The format of the dictionary content.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * loadJSON({
72
+ * format: 'icu',
73
+ * })
74
+ * ```
75
+ */
76
+ format?: DictionaryFormat;
77
+ };
78
+ declare const loadJSON: (options: LoadJSONPluginOptions) => Plugin;
79
+ //#endregion
80
+ export { loadJSON };
81
+ //# sourceMappingURL=loadJSON.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadJSON.d.ts","names":[],"sources":["../../src/loadJSON.ts"],"mappings":";;;;;;KAgJK,qBAAA;;AAlIgD;;;;;;;;;;EA8InD,MAAA,EAAQ,eAAA;EAeC;;;;;;;AAiDX;;;;;;EAjDE,MAAA,GAAS,MAAA;EAqGV;;;;;;;;;;;;;;;;;;;;;;EA7EC,QAAA;;;;;;;;;EAUA,QAAA;;;;;;;;;;;EAYA,MAAA,GAAS,gBAAA;AAAA;AAAA,cAGE,QAAA,GAAY,OAAA,EAAS,qBAAA,KAAwB,MAAA"}
@@ -0,0 +1,64 @@
1
+ import { Locale } from "@intlayer/types/allLocales";
2
+ import { FilePathPattern } from "@intlayer/types/filePathPattern";
3
+ import { Plugin } from "@intlayer/types/plugin";
4
+
5
+ //#region src/loadPO.d.ts
6
+ type LoadPOPluginOptions = {
7
+ /**
8
+ * The source of the plugin.
9
+ * Is a function to build the source from the key and locale.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * loadPO({
14
+ * source: ({ key }) => `blog/${'**'}/${key}.i18n.po`,
15
+ * })
16
+ * ```
17
+ */
18
+ source: FilePathPattern;
19
+ /**
20
+ * Locale
21
+ *
22
+ * If not provided, the plugin will consider the default locale.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * loadPO({
27
+ * source: ({ key }) => `blog/${'**'}/${key}.i18n.po`,
28
+ * locale: Locales.ENGLISH,
29
+ * })
30
+ * ```
31
+ */
32
+ locale?: Locale;
33
+ /**
34
+ * Because Intlayer transforms PO files into Dictionary, we need to identify the plugin in the dictionary.
35
+ * Used to identify the plugin in the dictionary.
36
+ *
37
+ * In the case you have multiple plugins, you can use this to identify the plugin in the dictionary.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const config = {
42
+ * plugins: [
43
+ * loadPO({
44
+ * source: ({ key }) => `./resources/${key}.po`,
45
+ * location: 'plugin-i18next-po',
46
+ * }),
47
+ * ]
48
+ * }
49
+ * ```
50
+ */
51
+ location?: string;
52
+ /**
53
+ * The priority of the dictionaries created by the plugin.
54
+ *
55
+ * In the case of conflicts with remote dictionaries, or .content files, the dictionary with the highest priority will override the other dictionaries.
56
+ *
57
+ * Default is 0.
58
+ */
59
+ priority?: number;
60
+ };
61
+ declare const loadPO: (options: LoadPOPluginOptions) => Plugin;
62
+ //#endregion
63
+ export { loadPO };
64
+ //# sourceMappingURL=loadPO.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadPO.d.ts","names":[],"sources":["../../src/loadPO.ts"],"mappings":";;;;;KAuIK,mBAAA;;AA7HgD;;;;;;;;;;EAyInD,MAAA,EAAQ,eAAA;EA4CA;AAGV;;;;;;;;;;;;EAhCE,MAAA,GAAS,MAAA;;;;;;;;;;;;;;;;;;;EAoBT,QAAA;;;;;;;;EASA,QAAA;AAAA;AAAA,cAGW,MAAA,GAAU,OAAA,EAAS,mBAAA,KAAsB,MAAA"}
@@ -0,0 +1,67 @@
1
+ import { Locale } from "@intlayer/types/allLocales";
2
+ import { DictionaryFormat, DictionaryLocation } from "@intlayer/types/dictionary";
3
+ import { FilePathPattern } from "@intlayer/types/filePathPattern";
4
+ import { Plugin } from "@intlayer/types/plugin";
5
+
6
+ //#region src/syncJSON.d.ts
7
+ declare const extractKeyAndLocaleFromPath: (filePath: string, maskPattern: string, locales: Locale[], defaultLocale: Locale) => {
8
+ key: string;
9
+ locale: Locale;
10
+ } | null;
11
+ type SyncJSONPluginOptions = {
12
+ /**
13
+ * The source of the plugin.
14
+ * Is a function to build the source from the key and locale.
15
+ *
16
+ * ```ts
17
+ * syncJSON({
18
+ * source: ({ key, locale }) => `./messages/${locale}/${key}.json`
19
+ * })
20
+ * ```
21
+ */
22
+ source: FilePathPattern;
23
+ /**
24
+ * Because Intlayer transform the JSON files into Dictionary, we need to identify the plugin in the dictionary.
25
+ * Used to identify the plugin in the dictionary.
26
+ *
27
+ * In the case you have multiple plugins, you can use this to identify the plugin in the dictionary.
28
+ *
29
+ * ```ts
30
+ * // Example usage:
31
+ * const config = {
32
+ * plugins: [
33
+ * syncJSON({
34
+ * source: ({ key, locale }) => `./resources/${locale}/${key}.json`,
35
+ * location: 'plugin-i18next',
36
+ * }),
37
+ * syncJSON({
38
+ * source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
39
+ * location: 'plugin-next-intl',
40
+ * }),
41
+ * ]
42
+ * }
43
+ * ```
44
+ */
45
+ location?: DictionaryLocation | (string & {});
46
+ /**
47
+ * The priority of the dictionaries created by the plugin.
48
+ *
49
+ * In the case of conflicts with remote dictionaries, or .content files, the dictionary with the highest priority will override the other dictionaries.
50
+ *
51
+ * Default is -1. (.content file priority is 0)
52
+ *
53
+ */
54
+ priority?: number;
55
+ /**
56
+ * The format of the dictionaries created by the plugin.
57
+ *
58
+ * Default: 'intlayer'
59
+ *
60
+ * The format of the dictionaries created by the plugin.
61
+ */
62
+ format?: DictionaryFormat;
63
+ };
64
+ declare const syncJSON: (options: SyncJSONPluginOptions) => Promise<Plugin>;
65
+ //#endregion
66
+ export { extractKeyAndLocaleFromPath, syncJSON };
67
+ //# sourceMappingURL=syncJSON.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncJSON.d.ts","names":[],"sources":["../../src/syncJSON.ts"],"mappings":";;;;;;cA2Ba,2BAAA,GACX,QAAA,UACA,WAAA,UACA,OAAA,EAAS,MAAA,IACT,aAAA,EAAe,MAAA;EACZ,GAAA;EAAa,MAAA,EAAQ,MAAA;AAAA;AAAA,KA0MrB,qBAAA;EA5MM;;;;;;;;;;EAuNT,MAAA,EAAQ,eAAA;EArNL;;;;;AAkDH;;;;;;;;;;;;;;;;;EA2LA,QAAA,GAAW,kBAAA;EAqLZ;;;;;;;;EA3KC,QAAA;EAcC;;;;;;;EALD,MAAA,GAAS,gBAAA;AAAA;AAAA,cAGE,QAAA,GACX,OAAA,EAAS,qBAAA,KACR,OAAA,CAAQ,MAAA"}
@@ -0,0 +1,64 @@
1
+ import { Locale } from "@intlayer/types/allLocales";
2
+ import { FilePathPattern } from "@intlayer/types/filePathPattern";
3
+ import { Plugin } from "@intlayer/types/plugin";
4
+ import { DictionaryLocation } from "@intlayer/types/dictionary";
5
+
6
+ //#region src/syncPO.d.ts
7
+ declare const extractKeyAndLocaleFromPath: (filePath: string, maskPattern: string, locales: Locale[], defaultLocale: Locale) => {
8
+ key: string;
9
+ locale: Locale;
10
+ } | null;
11
+ /**
12
+ * Parse a PO file string into a flat msgid → msgstr record.
13
+ * Skips the PO header (msgid ""), comment lines, and plural/context keywords.
14
+ */
15
+ declare const parsePO: (fileContent: string) => Record<string, string>;
16
+ /**
17
+ * Serialize a flat key → value record to PO file format.
18
+ * Non-string values are silently skipped.
19
+ */
20
+ declare const serializePO: (content: Record<string, unknown>, locale?: string) => string;
21
+ type SyncPOPluginOptions = {
22
+ /**
23
+ * The source of the plugin.
24
+ * Is a function to build the source from the key and locale.
25
+ *
26
+ * ```ts
27
+ * syncPO({
28
+ * source: ({ key, locale }) => `./messages/${locale}/${key}.po`
29
+ * })
30
+ * ```
31
+ */
32
+ source: FilePathPattern;
33
+ /**
34
+ * Because Intlayer transforms PO files into Dictionary, we need to identify the plugin in the dictionary.
35
+ * Used to identify the plugin in the dictionary.
36
+ *
37
+ * In the case you have multiple plugins, you can use this to identify the plugin in the dictionary.
38
+ *
39
+ * ```ts
40
+ * // Example usage:
41
+ * const config = {
42
+ * plugins: [
43
+ * syncPO({
44
+ * source: ({ key, locale }) => `./resources/${locale}/${key}.po`,
45
+ * location: 'plugin-i18next-po',
46
+ * }),
47
+ * ]
48
+ * }
49
+ * ```
50
+ */
51
+ location?: DictionaryLocation | (string & {});
52
+ /**
53
+ * The priority of the dictionaries created by the plugin.
54
+ *
55
+ * In the case of conflicts with remote dictionaries, or .content files, the dictionary with the highest priority will override the other dictionaries.
56
+ *
57
+ * Default is 0.
58
+ */
59
+ priority?: number;
60
+ };
61
+ declare const syncPO: (options: SyncPOPluginOptions) => Promise<Plugin>;
62
+ //#endregion
63
+ export { extractKeyAndLocaleFromPath, parsePO, serializePO, syncPO };
64
+ //# sourceMappingURL=syncPO.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncPO.d.ts","names":[],"sources":["../../src/syncPO.ts"],"mappings":";;;;;;cAuBa,2BAAA,GACX,QAAA,UACA,WAAA,UACA,OAAA,EAAS,MAAA,IACT,aAAA,EAAe,MAAA;EACZ,GAAA;EAAa,MAAA,EAAQ,MAAA;AAAA;;;;;cAuEb,OAAA,GAAW,WAAA,aAAsB,MAAA;;;;;cAsEjC,WAAA,GACX,OAAA,EAAS,MAAA,mBACT,MAAA;AAAA,KAoLG,mBAAA;EApUH;;;;;;AAwEF;;;;EAuQE,MAAA,EAAQ,eAAA;EAjMG;;;;;;;;;AA0BX;;;;;;;;;EA2LA,QAAA,GAAW,kBAAA;EASH;AAGV;;;;;;EAHE,QAAA;AAAA;AAAA,cAGW,MAAA,GAAgB,OAAA,EAAS,mBAAA,KAAsB,OAAA,CAAQ,MAAA"}
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "@intlayer/sync-po-plugin",
3
+ "version": "8.9.4",
4
+ "private": false,
5
+ "description": "A plugin for Intlayer that syncs Portable Object (.po) files to dictionaries.",
6
+ "keywords": [
7
+ "intlayer",
8
+ "po",
9
+ "gettext",
10
+ "plugin",
11
+ "sync"
12
+ ],
13
+ "homepage": "https://intlayer.org",
14
+ "bugs": {
15
+ "url": "https://github.com/aymericzip/intlayer/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/aymericzip/intlayer.git"
20
+ },
21
+ "license": "Apache-2.0",
22
+ "author": {
23
+ "name": "Aymeric PINEAU",
24
+ "url": "https://github.com/aymericzip"
25
+ },
26
+ "contributors": [
27
+ {
28
+ "name": "Aymeric Pineau",
29
+ "email": "ay.pineau@gmail.com",
30
+ "url": "https://github.com/aymericzip"
31
+ }
32
+ ],
33
+ "sideEffects": false,
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/types/index.d.ts",
37
+ "require": "./dist/cjs/index.cjs",
38
+ "import": "./dist/esm/index.mjs"
39
+ },
40
+ "./package.json": "./package.json"
41
+ },
42
+ "main": "dist/cjs/index.cjs",
43
+ "module": "dist/esm/index.mjs",
44
+ "types": "dist/types/index.d.ts",
45
+ "typesVersions": {
46
+ "*": {
47
+ "package.json": [
48
+ "./package.json"
49
+ ]
50
+ }
51
+ },
52
+ "files": [
53
+ "./dist",
54
+ "./package.json"
55
+ ],
56
+ "scripts": {
57
+ "build": "tsdown --config tsdown.config.ts",
58
+ "build:ci": "tsdown --config tsdown.config.ts",
59
+ "clean": "bun --bun rimraf ./dist .turbo",
60
+ "dev": "tsdown --config tsdown.config.ts --watch",
61
+ "format": "bun --bun biome format . --check",
62
+ "format:fix": "bun --bun biome format --write .",
63
+ "lint": "bun --bun biome lint .",
64
+ "lint:fix": "bun --bun biome lint --write .",
65
+ "process-files": "ts-node src/transpiler/processFilesCLI.ts --dir $npm_config_dir --extension $npm_config_extension --no-node-snapshot",
66
+ "prepublish": "cp -f ../../README.md ./README.md",
67
+ "publish": "bun publish || true",
68
+ "publish:canary": "bun publish --access public --tag canary || true",
69
+ "publish:latest": "bun publish --access public --tag latest || true",
70
+ "test": "bun --bun vitest run",
71
+ "test:watch": "bun --bun vitest",
72
+ "typecheck": "tsc --noEmit --project tsconfig.types.json"
73
+ },
74
+ "dependencies": {
75
+ "@intlayer/chokidar": "8.9.4",
76
+ "@intlayer/config": "8.9.4",
77
+ "@intlayer/core": "8.9.4",
78
+ "@intlayer/types": "8.9.4",
79
+ "fast-glob": "3.3.3"
80
+ },
81
+ "devDependencies": {
82
+ "@types/node": "25.6.2",
83
+ "@utils/ts-config": "1.0.4",
84
+ "@utils/ts-config-types": "1.0.4",
85
+ "@utils/tsdown-config": "1.0.4",
86
+ "rimraf": "6.1.3",
87
+ "tsdown": "0.22.00",
88
+ "typescript": "6.0.3",
89
+ "vitest": "4.1.5"
90
+ },
91
+ "engines": {
92
+ "node": ">=14.18"
93
+ },
94
+ "bug": {
95
+ "url": "https://github.com/aymericzip/intlayer/issues"
96
+ }
97
+ }