intor 2.3.34 → 2.3.35
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/dist/react/src/client/react/translator/trans.js +2 -2
- package/dist/types/src/client/react/translator/trans.d.ts +3 -12
- package/dist/types/src/client/vue/translator/trans.d.ts +7 -2
- package/dist/vue/src/client/vue/translator/trans.js +10 -4
- package/dist/vue/src/client/vue/translator/use-translator.js +3 -3
- package/package.json +1 -1
|
@@ -8,8 +8,8 @@ import { useTranslator } from './use-translator.js';
|
|
|
8
8
|
*/
|
|
9
9
|
function Trans(props) {
|
|
10
10
|
const { i18nKey, components, values } = props;
|
|
11
|
-
const
|
|
12
|
-
return jsx(Fragment, { children:
|
|
11
|
+
const { tRich } = useTranslator();
|
|
12
|
+
return jsx(Fragment, { children: tRich(i18nKey, components, values) });
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export { Trans };
|
|
@@ -4,18 +4,9 @@ import type { LocalizedKey, LocalizedReplacement, LocalizedRich, Replacement } f
|
|
|
4
4
|
type TransProps<CK extends GenConfigKeys = "__default__", K extends string = LocalizedKey<GenMessages<CK>>, RI = LocalizedRich<GenRich<CK>, K>, RE extends Replacement = LocalizedReplacement<GenReplacements<CK>, K>> = {
|
|
5
5
|
/** The message key to translate. */
|
|
6
6
|
i18nKey: K | (string & {});
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Maps a tag name to either a React node or a render function,
|
|
11
|
-
* allowing customization of rich tag rendering.
|
|
12
|
-
*/
|
|
13
|
-
components?: ReactTagRenderers<RI>;
|
|
14
|
-
/**
|
|
15
|
-
* Optional replacement values for message interpolation.
|
|
16
|
-
*
|
|
17
|
-
* These values are passed to the underlying translator.
|
|
18
|
-
*/
|
|
7
|
+
/** Optional React renderers for semantic tags. */
|
|
8
|
+
components?: ReactTagRenderers<RI> | ReactTagRenderers;
|
|
9
|
+
/** Optional replacement values for interpolation. */
|
|
19
10
|
values?: RE | Replacement;
|
|
20
11
|
};
|
|
21
12
|
/**
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { VueTagRenderers } from "../../../client/vue/render";
|
|
2
2
|
import type { Replacement } from "intor-translator";
|
|
3
|
+
/**
|
|
4
|
+
* `<Trans />` is a lightweight Vue component for rendering rich translations.
|
|
5
|
+
*
|
|
6
|
+
* It is a thin adapter around `translator.tRich` and introduces no additional logic.
|
|
7
|
+
*/
|
|
3
8
|
export declare const Trans: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
9
|
/** The message key to translate. */
|
|
5
10
|
i18nKey: {
|
|
6
|
-
type:
|
|
11
|
+
type: StringConstructor;
|
|
7
12
|
required: true;
|
|
8
13
|
};
|
|
9
14
|
/** Optional Vue renderers for semantic tags. */
|
|
@@ -21,7 +26,7 @@ export declare const Trans: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
21
26
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
22
27
|
/** The message key to translate. */
|
|
23
28
|
i18nKey: {
|
|
24
|
-
type:
|
|
29
|
+
type: StringConstructor;
|
|
25
30
|
required: true;
|
|
26
31
|
};
|
|
27
32
|
/** Optional Vue renderers for semantic tags. */
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { defineComponent, h } from 'vue';
|
|
1
|
+
import { defineComponent, h, Fragment } from 'vue';
|
|
2
2
|
import { useTranslator } from './use-translator.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* `<Trans />` is a lightweight Vue component for rendering rich translations.
|
|
6
|
+
*
|
|
7
|
+
* It is a thin adapter around `translator.tRich` and introduces no additional logic.
|
|
8
|
+
*/
|
|
4
9
|
const Trans = defineComponent({
|
|
5
10
|
name: "Trans",
|
|
6
11
|
props: {
|
|
@@ -21,10 +26,11 @@ const Trans = defineComponent({
|
|
|
21
26
|
},
|
|
22
27
|
},
|
|
23
28
|
setup(props) {
|
|
24
|
-
const
|
|
29
|
+
const { tRich } = useTranslator();
|
|
25
30
|
return () => {
|
|
26
|
-
const
|
|
27
|
-
|
|
31
|
+
const { i18nKey, components, values } = props;
|
|
32
|
+
const nodes = tRich(i18nKey, components, values);
|
|
33
|
+
return h(Fragment, null, nodes);
|
|
28
34
|
};
|
|
29
35
|
},
|
|
30
36
|
});
|
|
@@ -13,9 +13,9 @@ function useTranslator(preKey) {
|
|
|
13
13
|
locale: computed(() => translator.value.locale),
|
|
14
14
|
isLoading: computed(() => translator.value.isLoading),
|
|
15
15
|
setLocale: intor.value.setLocale,
|
|
16
|
-
hasKey:
|
|
17
|
-
t:
|
|
18
|
-
tRich:
|
|
16
|
+
hasKey: (...args) => scoped.value.hasKey(...args),
|
|
17
|
+
t: (...args) => scoped.value.t(...args),
|
|
18
|
+
tRich: (...args) => createTRich(scoped.value.t)(...args),
|
|
19
19
|
// NOTE:
|
|
20
20
|
// The runtime implementation is intentionally erased.
|
|
21
21
|
// Type safety is guaranteed by public type contracts.
|