@contentstorage/i18next-plugin 1.0.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/LICENSE +21 -0
- package/README.md +453 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +384 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +391 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +73 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/post-processor.d.ts +42 -0
- package/dist/post-processor.d.ts.map +1 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +88 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +53 -0
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ContentStorageWindow, MemoryMap } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the code is running in a browser environment
|
|
4
|
+
*/
|
|
5
|
+
export declare function isBrowser(): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Gets the ContentStorage window object with type safety
|
|
8
|
+
*/
|
|
9
|
+
export declare function getContentStorageWindow(): ContentStorageWindow | null;
|
|
10
|
+
/**
|
|
11
|
+
* Detects if the application is running in ContentStorage live editor mode
|
|
12
|
+
*
|
|
13
|
+
* @param liveEditorParam - Query parameter name to check
|
|
14
|
+
* @param forceLiveMode - Force live mode regardless of environment
|
|
15
|
+
* @returns true if in live editor mode
|
|
16
|
+
*/
|
|
17
|
+
export declare function detectLiveEditorMode(liveEditorParam?: string, forceLiveMode?: boolean): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Initializes the global memory map if it doesn't exist
|
|
20
|
+
*/
|
|
21
|
+
export declare function initializeMemoryMap(): MemoryMap | null;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the global memory map
|
|
24
|
+
*/
|
|
25
|
+
export declare function getMemoryMap(): MemoryMap | null;
|
|
26
|
+
/**
|
|
27
|
+
* Normalizes i18next key format to consistent dot notation
|
|
28
|
+
* Converts namespace:key format to namespace.key
|
|
29
|
+
*
|
|
30
|
+
* @param key - The translation key
|
|
31
|
+
* @param namespace - Optional namespace
|
|
32
|
+
* @returns Normalized key in dot notation
|
|
33
|
+
*/
|
|
34
|
+
export declare function normalizeKey(key: string, namespace?: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Extracts the base translation key without interpolation context
|
|
37
|
+
* Handles plural forms, contexts, and other i18next features
|
|
38
|
+
*
|
|
39
|
+
* Examples:
|
|
40
|
+
* - 'welcome' -> 'welcome'
|
|
41
|
+
* - 'items_plural' -> 'items'
|
|
42
|
+
* - 'friend_male' -> 'friend'
|
|
43
|
+
*
|
|
44
|
+
* @param key - The translation key
|
|
45
|
+
* @returns Base key without suffixes
|
|
46
|
+
*/
|
|
47
|
+
export declare function extractBaseKey(key: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Removes interpolation variables from a translated string
|
|
50
|
+
*
|
|
51
|
+
* Examples:
|
|
52
|
+
* - 'Hello {{name}}!' -> 'Hello !'
|
|
53
|
+
* - 'You have {{count}} items' -> 'You have items'
|
|
54
|
+
*
|
|
55
|
+
* @param value - The translated string
|
|
56
|
+
* @returns String with interpolations removed
|
|
57
|
+
*/
|
|
58
|
+
export declare function removeInterpolation(value: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Tracks a translation in the memory map
|
|
61
|
+
*
|
|
62
|
+
* @param translationValue - The actual translated text
|
|
63
|
+
* @param translationKey - The content ID (i18next key)
|
|
64
|
+
* @param namespace - Optional namespace
|
|
65
|
+
* @param language - Optional language code
|
|
66
|
+
* @param debug - Enable debug logging
|
|
67
|
+
*/
|
|
68
|
+
export declare function trackTranslation(translationValue: string, translationKey: string, namespace?: string, language?: string, debug?: boolean): void;
|
|
69
|
+
/**
|
|
70
|
+
* Cleans up old entries from memory map when size exceeds limit
|
|
71
|
+
* Removes oldest entries first (based on trackedAt timestamp)
|
|
72
|
+
*
|
|
73
|
+
* @param maxSize - Maximum number of entries to keep
|
|
74
|
+
*/
|
|
75
|
+
export declare function cleanupMemoryMap(maxSize: number): void;
|
|
76
|
+
/**
|
|
77
|
+
* Deeply traverses a translation object and extracts all string values with their keys
|
|
78
|
+
*
|
|
79
|
+
* @param obj - Translation object to traverse
|
|
80
|
+
* @param prefix - Current key prefix (for nested objects)
|
|
81
|
+
* @returns Array of [key, value] pairs
|
|
82
|
+
*/
|
|
83
|
+
export declare function flattenTranslations(obj: any, prefix?: string): Array<[string, string]>;
|
|
84
|
+
/**
|
|
85
|
+
* Debug helper to log memory map contents
|
|
86
|
+
*/
|
|
87
|
+
export declare function debugMemoryMap(): void;
|
|
88
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAkB,MAAM,SAAS,CAAC;AAE/E;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,oBAAoB,GAAG,IAAI,CAGrE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,GAAE,MAAqC,EACtD,aAAa,GAAE,OAAe,GAC7B,OAAO,CAqBT;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,GAAG,IAAI,CAStD;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,GAAG,IAAI,CAG/C;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAcpE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAkBlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,gBAAgB,EAAE,MAAM,EACxB,cAAc,EAAE,MAAM,EACtB,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,GAAE,OAAe,GACrB,IAAI,CAgCN;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAqBtD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,MAAM,GAAE,MAAW,GAClB,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkBzB;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAsBrC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contentstorage/i18next-plugin",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "i18next plugin for Contentstorage live editor translation tracking",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "rollup -c",
|
|
14
|
+
"dev": "rollup -c -w",
|
|
15
|
+
"test": "jest",
|
|
16
|
+
"type-check": "tsc --noEmit",
|
|
17
|
+
"prepublishOnly": "npm run build",
|
|
18
|
+
"release": "npx release-it"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"i18next",
|
|
22
|
+
"contentstorage",
|
|
23
|
+
"translation",
|
|
24
|
+
"live-editor",
|
|
25
|
+
"i18n",
|
|
26
|
+
"internationalization"
|
|
27
|
+
],
|
|
28
|
+
"author": "ContentStorage",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"i18next": ">=21.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
35
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
36
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
37
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
38
|
+
"@types/jest": "^29.5.11",
|
|
39
|
+
"@types/node": "^20.10.6",
|
|
40
|
+
"i18next": "^23.7.13",
|
|
41
|
+
"jest": "^29.7.0",
|
|
42
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
43
|
+
"release-it": "^19.0.5",
|
|
44
|
+
"rollup": "^4.9.4",
|
|
45
|
+
"ts-jest": "^29.1.1",
|
|
46
|
+
"tslib": "^2.6.2",
|
|
47
|
+
"typescript": "^5.3.3"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/contentstorage/i18next-plugin.git"
|
|
52
|
+
}
|
|
53
|
+
}
|