Selecting The Language To Use

1. Setting the Language / Locale

The locale describes the regional settings for a piece of software, such as a website, or unblu. The most noticeable aspect of the locale is the language in which the user interface is displayed, but the locale can contain other regional aspects (such as date formats, number formats, and so on).

If your website has only one locale, you can set that locale for unblu in the configuration. This makes sure that the website and unblu use the same locale (that is, the same language and the same other regional settings).

If your website supports multiple locales, then you have to tell unblu which locale to use.

2. Using an attribute

A very straightforward way of telling unblu which locale to use is by using the default html lang attribute in the <html> tag, as follows:

 

<html lang="en">

 

IMPORTANT: Although according to the html specification, the lang attribute can be set on any tag, unblu only checks the html tag to pick up the language.

unblu supports either language code or language-region code as defined in http://www.ietf.org/rfc/bcp/bcp47.txt section 2.2.1(language), section 2.2.4 (region) and Appendix A (Examples for language-region). For more information, see http://www.w3.org/International/tutorials/new-language-decl/qa-html-language-declarations. If you do not want to set the language for the entire page, you can tell unblu explicitly what locale to use. To do so, add the (custom) attribute unblu_locale to the html tag as follows:

<html unblu_locale="en-US"> 

 

Most content management systems will let you add this attribute to all pages with little effort.

3. Using a JavaScript function call

You can also use a JavaScript function call to set the locale, as follows:

 

unblu.setLocale(language-code)

 

Note that you have to call the function after the unblu snippet, but before the page is rendered. If at all possible, we recommend to place the call immediately after the snippet.

4. Languages and regions

The language code follows the IETF convention for language codes, so the following calls set the locales for English, US-English, and German as spoken in Germany:

  • unblu.setLocale("en")
  • unblu.setLocale("en-US")
  • unblu.setLocale("de-DE")

How can we help?

Chat with us and we will take you through our site!

Read about how we use cookies and how you can control them by clicking "Cookie Settings." If you continue to use this site, you consent to our use of cookies.