i18next 23.4.2 → 23.4.3

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.
@@ -1 +1 @@
1
- {"type":"module","version":"23.4.2"}
1
+ {"type":"module","version":"23.4.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next",
3
- "version": "23.4.2",
3
+ "version": "23.4.3",
4
4
  "description": "i18next internationalization framework",
5
5
  "main": "./dist/cjs/i18next.js",
6
6
  "module": "./dist/esm/i18next.js",
@@ -110,7 +110,7 @@
110
110
  "watchify": "4.0.0"
111
111
  },
112
112
  "scripts": {
113
- "pretest": "npm run test:typescript && npm run test:typescript:customtypes && npm run test:typescript:defaulttypes && npm run test:typescript:fallbacktypes && npm run test:typescript:noninterop",
113
+ "pretest": "npm run test:typescript && npm run test:typescript:customtypes && npm run test:typescript:defaulttypes && npm run test:typescript:fallbacktypes && npm run test:typescript:noninterop && npm run test:typescript:customcontextseparator",
114
114
  "lint": "eslint src",
115
115
  "test": "npm run lint && npm run test:new && npm run test:compat",
116
116
  "test:new": "karma start karma.conf.js --singleRun",
@@ -119,6 +119,7 @@
119
119
  "test:typescript:defaulttypes": "tslint --project test/typescript/default-types/tsconfig.json",
120
120
  "test:typescript:customtypes": "tslint --project test/typescript/custom-types/tsconfig.json",
121
121
  "test:typescript:fallbacktypes": "tslint --project test/typescript/fallback-types/tsconfig.json",
122
+ "test:typescript:customcontextseparator": "tslint --project test/typescript/custom-context-separator/tsconfig.json",
122
123
  "test:typescript:noninterop": "tslint --project tsconfig.nonEsModuleInterop.json",
123
124
  "tdd": "karma start karma.conf.js",
124
125
  "tdd:compat": "karma start karma.backward.conf.js",
@@ -55,10 +55,15 @@ export type TypeOptions = $MergeBy<
55
55
  nsSeparator: ':';
56
56
 
57
57
  /**
58
- * Char to split namespace from key
58
+ * Char to split plural from key
59
59
  */
60
60
  pluralSeparator: '_';
61
61
 
62
+ /**
63
+ * Char to split context from key
64
+ */
65
+ contextSeparator: '_';
66
+
62
67
  /**
63
68
  * Default namespace used if not passed to translation function
64
69
  */
package/typescript/t.d.ts CHANGED
@@ -19,6 +19,7 @@ type _ReturnNull = TypeOptions['returnNull'];
19
19
  type _KeySeparator = TypeOptions['keySeparator'];
20
20
  type _NsSeparator = TypeOptions['nsSeparator'];
21
21
  type _PluralSeparator = TypeOptions['pluralSeparator'];
22
+ type _ContextSeparator = TypeOptions['contextSeparator'];
22
23
  type _FallbackNamespace = TypeOptions['fallbackNS'];
23
24
  type _Resources = TypeOptions['resources'];
24
25
  type _JSONFormat = TypeOptions['jsonFormat'];
@@ -104,7 +105,7 @@ type ParseKeysByFallbackNs<Keys extends $Dictionary> = _FallbackNamespace extend
104
105
  : Keys[_FallbackNamespace & string];
105
106
 
106
107
  type FilterKeysByContext<Keys, TOpt extends TOptions> = TOpt['context'] extends string
107
- ? Keys extends `${infer Prefix}_${TOpt['context']}${infer Suffix}`
108
+ ? Keys extends `${infer Prefix}${_ContextSeparator}${TOpt['context']}${infer Suffix}`
108
109
  ? `${Prefix}${Suffix}`
109
110
  : never
110
111
  : Keys;
@@ -156,7 +157,7 @@ type TReturnOptionalObjects<TOpt extends TOptions> = _ReturnObjects extends true
156
157
  type DefaultTReturn<TOpt extends TOptions> = TReturnOptionalObjects<TOpt> | TReturnOptionalNull;
157
158
 
158
159
  type KeyWithContext<Key, TOpt extends TOptions> = TOpt['context'] extends string
159
- ? `${Key & string}_${TOpt['context']}`
160
+ ? `${Key & string}${_ContextSeparator}${TOpt['context']}`
160
161
  : Key;
161
162
 
162
163
  export type TFunctionReturn<