Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Map language for Lock with fallback to English
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sign In with Auth0</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<!--[if IE 8]>
<script src="//cdnjs.cloudflare.com/ajax/libs/ie8/0.2.5/ie8.js"></script>
<![endif]-->
<!--[if lte IE 9]>
<script src="https://cdn.auth0.com/js/base64.js"></script>
<script src="https://cdn.auth0.com/js/es5-shim.min.js"></script>
<![endif]-->
<script src="https://cdn.auth0.com/js/lock/11.14/lock.min.js"></script>
<script>
// Decode utf8 characters properly
var config = JSON.parse(decodeURIComponent(escape(window.atob('@@config@@'))));
config.extraParams = config.extraParams || {};
var connection = config.connection;
var prompt = config.prompt;
var languageDictionary;
var language;
switch (config.extraParams.lang) {
case "af":
language = "af";
break;
case "zh":
language = "zh";
break;
case "zh-tw":
language = "zh-tw";
break;
case "hr":
language = "hr";
break;
case "cs":
language = "cs";
break;
case "da":
language = "da";
break;
case "nl":
language = "nl";
break;
case "en":
language = "en";
break;
case "et":
language = "et";
break;
case "fa":
language = "fa";
break;
case "fi":
language = "fi";
break;
case "fr":
language = "fr";
break;
case "de":
language = "de";
break;
case "el":
language = "el";
break;
case "he":
language = "he";
break;
case "hu":
language = "hu";
break;
case "it":
language = "it";
break;
case "ja":
language = "ja";
break;
case "ko":
language = "ko";
break;
case "lt":
language = "lt";
break;
case "no":
language = "no";
break;
case "nb":
language = "nb";
break;
case "nn":
language = "nn";
break;
case "pl":
language = "pl";
break;
case "pt-br":
language = "pt-br";
break;
case "ro":
language = "ro";
break;
case "ru":
language = "ru";
break;
case "sk":
language = "sk";
break;
case "sl":
language = "sl";
break;
case "es":
language = "es";
break;
case "sv":
language = "sv";
break;
case "tr":
language = "tr";
break;
case "ua":
language = "ua";
break;
case "vi":
language = "vi";
break;
// Any additional maping if necessary
// here
default:
language = "en";
break;
}
var loginHint = config.extraParams.login_hint;
var colors = config.colors || {};
// Available Lock configuration options: https://auth0.com/docs/libraries/lock/v11/configuration
var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
auth: {
redirectUrl: config.callbackURL,
responseType: (config.internalOptions || {}).response_type ||
(config.callbackOnLocationHash ? 'token' : 'code'),
params: config.internalOptions
},
/* additional configuration needed for custom domains
configurationBaseUrl: config.clientConfigurationBaseUrl,
overrides: {
__tenant: config.auth0Tenant,
__token_issuer: 'YOUR_CUSTOM_DOMAIN'
}, */
assetsUrl: config.assetsUrl,
allowedConnections: connection ? [connection] : null,
rememberLastLogin: !prompt,
language: language,
languageDictionary: languageDictionary,
theme: {
//logo: 'YOUR LOGO HERE',
primaryColor: colors.primary ? colors.primary : 'green'
},
prefill: loginHint ? { email: loginHint, username: loginHint } : null,
closable: false,
defaultADUsernameFromEmailPrefix: false,
// uncomment if you want small buttons for social providers
// socialButtonStyle: 'small'
});
if(colors.page_background) {
var css = '.auth0-lock.auth0-lock .auth0-lock-overlay { background: ' +
colors.page_background +
' }';
var style = document.createElement('style');
style.appendChild(document.createTextNode(css));
document.body.appendChild(style);
}
lock.show();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.