components-js
components-js copied to clipboard
I18N
Describe the problem
Hope there have i18n entry.
Describe the proposed solution
Maintain a json file that contain i18n KV context / translate, for example: https://react.i18next.com/
export const useTranslate = () => {
const { i18nProvider } = useContext("path/to/json.json");
const fn = useMemo(() => {
function translate(
key: string,
options?: any,
defaultMessage?: string,
): string;
function translate(key: string, defaultMessage?: string): string;
function translate(
key: string,
options?: string | any,
defaultMessage?: string,
) {
return (
i18nProvider?.translate(key, options, defaultMessage) ??
defaultMessage ??
(typeof options === "string" &&
typeof defaultMessage === "undefined"
? options
: key)
);
}
return translate;
}, [i18nProvider]);
return fn;
};
Alternatives considered
No response
Importance
I cannot use LiveKit without it
Additional Information
No response