lang - Define your language detection

Userlane automatically detects the language of your application and of the user's browser to match a user's language preferences.

If you want to make sure that Userlane always uses the same language as your application, you can explicitly define the language that Userlane should use with the language command. This is especially useful if your application offers a language setting and does not define its language in the standard html lang-Attribute:

// set the language of userlane
Userlane('lang', 'language_code');

Your language_code might be a 2 letters code (like 'en' or 'de') or a 5 letters code (like 'en-us' or 'en-gb').

Language Detection Priorities

Userlane detects languages based on a priority list. You can find that below: 

Priority 1: Language is taken from the settings of the application (lang Command)
Priority 2: Language is taken based on your language settings in the Userlane Dashboard
Priority 3: Based on the HTML tag
Priority 4: Based on Meta information
Priority 5: Based on the browser language
Priority 6: The language falls back to the default language defined in the Userlane Dashboard 

Good to know

  • The language code used in the command should exactly match the language key that was used when the language was created in the Dashboard.

  • Keep in mind, that the language you pass via the language command must exist and be public in the Userlane Dashboard. Otherwise, Userlane will take the defined default language instead. 

  • ⇨ Start this Guide to learn how to manage your languages within the Dashboard. 

Related articles