@cudenix/cudenix 0.0.14 → 0.0.15
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.
|
@@ -6,7 +6,7 @@ type DeepValue<Type extends Record<PropertyKey, unknown>, Path extends string[]>
|
|
|
6
6
|
type ExtractPlaceholders<String extends string> = String extends `${infer _Start}\${${infer Param}}${infer Rest}` ? Param | ExtractPlaceholders<Rest> : never;
|
|
7
7
|
interface TranslateOptions<Key extends string> {
|
|
8
8
|
language?: string;
|
|
9
|
-
|
|
9
|
+
replace?: {
|
|
10
10
|
[_Key in ExtractPlaceholders<Key>]?: string;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
@@ -67,11 +67,11 @@ function translate(...args) {
|
|
|
67
67
|
for (let i = 0; i < path.length; i++) {
|
|
68
68
|
translation = translation[path[i]];
|
|
69
69
|
}
|
|
70
|
-
if (options?.
|
|
71
|
-
const keys = Object.keys(options.
|
|
70
|
+
if (options?.replace) {
|
|
71
|
+
const keys = Object.keys(options.replace);
|
|
72
72
|
for (let i = 0; i < keys.length; i++) {
|
|
73
73
|
const key = keys[i];
|
|
74
|
-
translation = translation.replaceAll(`\${${key}}`, options.
|
|
74
|
+
translation = translation.replaceAll(`\${${key}}`, options.replace[key]);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
return translation;
|
package/package.json
CHANGED