Locale.AutoUse is a project mainly written in JavaScript, it's free.
Automatically determine the right language of the document to use for Locale
Locale.AutoUse searches for a lang
attribute, which is usually at the html tag of a document.
If a language is found and defined by Locale it will set this as default language of the page.
You can also choose to get the language of the visitor.
This plugin is an extension for Locale in MooTools More 1.3.
Include the Locale.AutoUse.js file in your page or build.
It is possible to use Locale.AutoUse manually.
Locale.AutoUse(selector, attributeName, ua);
*[lang]
) Any CSS selector Slick supports. If you set this to navigator
it will use the visitors language.lang
) The attribute name which contains the Language code.true
if you want to use the visitors language instead of the lang
attribute. Passing the navigator
object to the first argument will do the same.Locale.AutoUse();
// Search for another tag instead of the `html` tag
Locale.AutoUse('div#languageDefinition');
// Don't use the lang attribute, but the `data-lang` attribute
Locale.AutoUse('div[data-lang]', 'data-lang');
// Use the language defined by the visitors browser
Locale.AutoUse(navigator);
// Another way
Locale.AutoUse(null, null, true);
Locale.AutoUse
function manually.