Tamir Yakov
03/19/2026, 12:05 PMTamir Yakov
03/19/2026, 12:06 PMDevRev
03/19/2026, 12:06 PMerrorTransformer function in your client SDK to translate error messages from action error handling.
const errorTransformer = (error) => {
const language = getClientLanguage(); // Get user's language
const translationMap = {
en: {
"Trigger 404 failure": "I'm a pinecone",
"SAMLStartFailed": "Failed to start SAML flow",
},
es: {
"Trigger 404 failure": "Soy una piña",
"SAMLStartFailed": "Error al iniciar flujo SAML",
},
de: {
"Trigger 404 failure": "Ich bin ein Pinienzapfen",
"SAMLStartFailed": "SAML-Flow konnte nicht gestartet werden",
}
};
const translations = translationMap[language] || translationMap['en'];
return translations[error.type] || translations[error.text] || error.text;
};
SDK Configuration
Pass the errorTransformer to your Descope component:
// React/Vue example
<Descope
flowId="sign-up-or-in"
errorTransformer={errorTransformer}
/>
• The errorTransformer receives an error object and returns a translated string
• Custom flow errors from actions must be translated using the errorTransformer in the frontend SDK
• You can map error types or error text to localized messages based on user language
Descope Component Guide | Client SDK | Descope Documentation
Customizing Localization | Descope DocumentationDevRev
03/19/2026, 12:06 PMTamir Yakov
03/19/2026, 12:06 PMDevRev
03/19/2026, 12:06 PM// In your backend API
function translateError(error, userLanguage) {
const translations = {
en: {
"authentication_failed": "Authentication failed",
"invalid_credentials": "Invalid credentials"
},
es: {
"authentication_failed": "Falló la autenticación",
"invalid_credentials": "Credenciales inválidas"
}
};
return translations[userLanguage]?.[error.type] || error.message;
}
Option 3: Flow Variables for Localization
Use flow variables to store translated error messages and display them on error screens based on user locale.
• Custom error handling in flows allows you to route to different screens with localized messages
• You can add conditions after actions to handle errors with custom messages
Actions Overview | Descope Documentation
Customizing Flow Errors | Descope DocumentationTamir Yakov
03/19/2026, 12:06 PMDevRev
03/19/2026, 12:07 PM// Listen for errors from the web component
const descopeWc = document.querySelector('descope-wc');
descopeWc.addEventListener('error', (event) => {
const error = event.detail;
const translatedMessage = translateError(error);
// Update your UI with translated message
displayError(translatedMessage);
});
function translateError(error) {
const userLanguage = navigator.language.split('-')[0];
const translations = {
en: {
"authentication_failed": "Authentication failed",
"invalid_credentials": "Invalid credentials"
},
es: {
"authentication_failed": "Falló la autenticación",
"invalid_credentials": "Credenciales inválidas"
}
};
return translations[userLanguage]?.[error.type] || error.message;
}
Alternative: Set Locale on Web Component
<descope-wc
project-id="your-project-id"
flow-id="sign-up-or-in"
locale="es">
</descope-wc>
• Web components emit error events that you can catch and translate client-side
• The locale attribute on the web component handles built-in message translation
Descope Component Guide | Client SDK | Descope Documentation