Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I18N #452

Open
rainbowflesh opened this issue Apr 19, 2023 · 4 comments
Open

I18N #452

rainbowflesh opened this issue Apr 19, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@rainbowflesh
Copy link

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

@lukasIO
Copy link
Contributor

lukasIO commented Apr 19, 2023

Hi,

while i18n is very interesting, this would be a rather big endeavour.

Can you share a bit more about what you would like to achieve specifically?
Are you using lower level components or the VideoConference prefab directly?

@rainbowflesh
Copy link
Author

rainbowflesh commented Apr 19, 2023

Hi,

while i18n is very interesting, this would be a rather big endeavour.

Can you share a bit more about what you would like to achieve specifically? Are you using lower level components or the VideoConference prefab directly?

I tested both, and I found some component like <PreJoin /> allow override label; But prefabricated components like <ControlBar /> in line 126 give the showText a const value;

      {visibleControls.leave && (
        <DisconnectButton>
          {showIcon && <LeaveIcon />}
          {showText && 'Leave'}
        </DisconnectButton>
      )}

I'm attempting to make some of these components i18nlized such as {showText && translate("buttons.leave")}, however it may not an elegant solution because I was creating duplicate components. It could be helpful if showText have value from overridable labels.

Or, am I missing some hacky function to inject i18n value to showText 🤔? Please forgive me, Im not professional in front end.


Edit:
I had a quick thought: Could I replace these components with overridable labels like <PreJoin/> then PR, is that reasonable? If not, please let me know ;).

@lukasIO
Copy link
Contributor

lukasIO commented May 3, 2023

for the control bar you cannot inject it right now, but you can always do something like

<DisconnectButton>
{t('disconnect-button')}
<DisconnectButtion>

with your own translate implementation.

We'll think more about how to make this easier for users in the future

@Ocupe Ocupe added the enhancement New feature or request label May 22, 2023
@AlexanderKozhevin
Copy link

can I set up labels in config somehow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants