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

Error message localization #86

Open
Escapado opened this issue Dec 13, 2022 · 18 comments
Open

Error message localization #86

Escapado opened this issue Dec 13, 2022 · 18 comments
Labels
enhancement New feature or request

Comments

@Escapado
Copy link

Feature request

I would like to request the option to localize error and info messages for e-mail auth.

Is your feature request related to a problem? Please describe.

I am using the german localization of the auth ui. However if invalid credentials are entered the error message will be displayed in english. Same goes for the info message that is displayed if a user resets their password.

Describe the solution you'd like

I would like to be able to provide localization strings for all the different messages that the ui might display.

Describe alternatives you've considered

Currently my workaround is to hide the messages and append a pseudo element to display a different error. This feels incredibly janky.

Screenshot from 2022-12-13 23-28-57

@Escapado Escapado added the enhancement New feature or request label Dec 13, 2022
@PhilBookst
Copy link

  • 1 for me, it's really weird when all of the UI is in german but then an english error pops up.

@carlosstenzel
Copy link

@MildTomato can you tell if there is any option?

@silentworks
Copy link
Contributor

@carlosstenzel please read issue #97 and see what I mentioned in point 2.

@konhi
Copy link

konhi commented Apr 9, 2023

related to supabase/auth#915

@MildTomato
Copy link
Contributor

Sorry for late response.

Yep, i agree this is really related to supabase/auth#915 as @konhi mentions, so we can assign translations easily to error codes.

@hmmhmmhm
Copy link

hmmhmmhm commented Apr 28, 2023

I needed the translation urgently, so I wrote the following temporary code.
If someone needs translated error messages in a hurry, you might want to consider using the code below.

// * Supabase Auth Error Message Translation
useEffect(() => {
  const observer = new MutationObserver((mutations) => {
    mutations.forEach((mutation) => {
      if (mutation.type !== "childList" || mutation.addedNodes.length === 0)
        return;

      for (const node of mutation.addedNodes) {
        if (
          node instanceof HTMLElement &&
          (node.classList.contains("supabase-account-ui_ui-message") ||
            node.classList.contains("supabase-auth-ui_ui-message"))
        ) {
          const originErrorMessage = node.innerHTML.trim();

          let translatedErrorMessage = "<DEFAULT MESSAGE>";
          switch (originErrorMessage) {
            case "To signup, please provide your email":
              translatedErrorMessage = "";
              break;
            case "Signup requires a valid password":
              translatedErrorMessage = "";
              break;
            case "User already registered":
              translatedErrorMessage = "";
              break;
            case "Only an email address or phone number should be provided on signup.":
              translatedErrorMessage = "";
              break;
            case "Signups not allowed for this instance":
              translatedErrorMessage = "";
              break;
            case "Email signups are disabled":
              translatedErrorMessage = "";
              break;
            case "Email link is invalid or has expired":
              translatedErrorMessage = "";
              break;
            case "Token has expired or is invalid":
              translatedErrorMessage = "";
              break;
            case "The new email address provided is invalid":
              translatedErrorMessage = "";
              break;
            case "Password should be at least 6 characters":
              translatedErrorMessage = "";
              break;
            case "Invalid login credentials":
              translatedErrorMessage = "";
              break;
          }

          if (!document.querySelector("#auth-forgot-password")) {
            node.innerHTML = translatedErrorMessage;
          }
        }
      }
    });
  });

  observer.observe(document.body, {
    childList: true,
    subtree: true,
  });
}, []);

@caipicoder
Copy link

caipicoder commented Apr 29, 2023 via email

@hmmhmmhm
Copy link

hmmhmmhm commented May 1, 2023

image
While working on this, I noticed something very strange: out of all the messages I get from gotrue, only one is translated into multiple languages. (The message appears to be related to sending a password reset email.) Is this by design, and why is only this message translated?

@silentworks
Copy link
Contributor

@hmmhmmhm that's interesting, I didn't know this was even translated. We will be working on Auth codes over the coming months to allow for better i18n support.

@tgraveleau
Copy link

I ran into the issue too and maybe a good fix would be to add a code field on the error and to document all codes so each of us can handle them as he wants.

@damien-schneider
Copy link

Same here, could be an important feature to add. (thanks for the temporary code until the feature.)

@JimmyLv
Copy link

JimmyLv commented Jul 18, 2023

also need this!

@CharleeWa
Copy link

+1, on this.

1 similar comment
@codeorlov
Copy link

+1, on this.

@jerocosio
Copy link

+1 on This

@almeidapaulooliveira
Copy link

+1 !!!

@KatayR
Copy link

KatayR commented Nov 8, 2023

+1

1 similar comment
@AM-77
Copy link

AM-77 commented Nov 9, 2023

+1

@supabase-community supabase-community locked and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests