-
Notifications
You must be signed in to change notification settings - Fork 128
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
Comments
|
@MildTomato can you tell if there is any option? |
@carlosstenzel please read issue #97 and see what I mentioned in point 2. |
related to supabase/auth#915 |
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. |
I needed the translation urgently, so I wrote the following temporary code. // * 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,
});
}, []); |
Thanks for sharing 🙏
Le ven. 28 avr. 2023 à 05:49, hmmhmmhm ***@***.***> a écrit :
… 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 TranslationuseEffect(() => {
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-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;
}
if (!document.querySelector("#auth-forgot-password")) {
node.innerHTML = translatedErrorMessage;
}
}
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true,
});}, []);
—
Reply to this email directly, view it on GitHub
<#86 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABA5QRJSLZC4NRI2NB2DX3XDM45ZANCNFSM6AAAAAAS5XWJSY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@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. |
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. |
Same here, could be an important feature to add. (thanks for the temporary code until the feature.) |
also need this! |
+1, on this. |
1 similar comment
+1, on this. |
+1 on This |
+1 !!! |
+1 |
1 similar comment
+1 |
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.
The text was updated successfully, but these errors were encountered: