Skip to content

I18N #452

@rainbowflesh

Description

@rainbowflesh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions