Lock Internationalization
You can change the language of Lock by using the language
configuration option. This will pull the corresponding language file from the i18n
directory in Lock.
Provided languages
Take a look at the i18n directory for language files.
Language | Code | Source |
---|---|---|
Afrikaans | 'af' |
af.js |
Catalan | 'ca' |
ca.js |
Chinese | 'zh' |
zh.js |
Chinese (Taiwan) | 'zh-tw' |
zh-tw.js |
Croatian | 'hr' |
hr.js |
Czech | 'cs' |
cs.js |
Danish | 'da' |
da.js |
Dutch | 'nl' |
nl.js |
English | 'en' |
en.js |
Estonian | 'et' |
et.js |
Farsi (Persian) | 'fa' |
fa.js |
Finnish | 'fi' |
fi.js |
French | 'fr' |
fr.js |
German | 'de' |
de.js |
Greek | 'el |
el.js |
Hebrew | 'he' |
he.js |
Hungarian | 'hu' |
hu.js |
Italian | 'it' |
it.js |
Japanese | 'ja' |
ja.js |
Korean | 'ko' |
ko.js |
Lithuanian | 'lt' |
lt.js |
Norwegian | 'no' |
no.js |
Norwegian (Bokmål) | 'nb' |
nb.js |
Norwegian (Nynorsk) | 'nn' |
nn.js |
Polish | 'pl' |
pl.js |
Portuguese (Brazil) | 'pt-br' |
pt-br.js |
Romanian | 'ro' |
ro.js |
Russian | 'ru' |
ru.js |
Slovak | 'sk' |
sk.js |
Slovenian | 'sl' |
sl.js |
Spanish | 'es' |
es.js |
Swedish | 'sv' |
sv.js |
Turkish | 'tr' |
tr.js |
Ukrainian | 'ua' |
ua.js |
Vietnamese | 'vi' |
vi.js |
Set language option
To use the following examples, you'll need to first include Lock in your page:
<script src="https://cdn.auth0.com/js/lock/11.14/lock.min.js"></script>
Next define your options
object and include the language
option. The language
option needs to be a string matching the name of the corresponding file in the i18n
directory within Lock. Then instantiate Lock.
to configure this snippet with your account
// Select a supported language
var options = {
language: 'es'
};
// Initiating our Auth0Lock
var lock = new Auth0Lock(
'{yourClientId}',
'{yourDomain}',
options
);
Was this helpful?
Translation data for Lock comes from language files which have key-value pairs representing various translations. For some languages, certain values may be missing, in which case you will see a warning: language does not have property <missing prop>
. We encourage you to submit a pull request to add these missing values. Alternatively, you may define the missing values in your Lock options
(see below).
Replace dictionary terms
You can also customize your own specific dictionary items using the languageDictionary
option. This is useful if you are using one of the supported languages, but change the specific wording of a few items. For example, you might re-word the title
or change the way other labels display to the user while leaving the remaining text on the widget intact.
to configure this snippet with your account
// Customize some languageDictionary attributes
var options = {
languageDictionary: {
emailInputPlaceholder: "something@youremail.com",
title: "Log me in"
},
};
// Initiating our Auth0Lock
var lock = new Auth0Lock(
'{yourClientId}',
'{yourDomain}',
options
);
Was this helpful?
For an example of available languageDictionary
property names and how to structure a language
file, see the English dictionary file for Lock.
The languageBaseUrl
option, which takes a string value (a URL), overrides the language source URL for Auth0's provided translations. By default, it uses the Auth0's CDN URL https://cdn.auth0.com
because that is where the provided language translations are stored. By providing another value, you can use your own source for the language translations as needed for your applications. Your language source should be a JavaScript file.