Localisation works by appending language indicators to the base package name
to download and implement the contained overrides. If no specific language is given,
the default setting for the browser is used. For example, setting the
language to English - Australian (en-AU) for the greeting
package
causes the download and evaluation of the greeting-en.js
and
greeting-en-AU.js
files (if they exist) in that order.
As an example the greeting
package has the following
localisation packages available:
File | Language | Value |
---|---|---|
greeting.js | Default | Hello |
greeting-en.js | Standard English | Good morning |
greeting-en-AU.js | Australian English | G'day |
greeting-en-US.js | US English | Hi |
greeting-fr.js | French | Bonjour |
These packages just set a variable (greeting
) that is then displayed:
Default language
Change to another language
for language
$('#defaultLang').val($.localise.defaultLanguage);
$('#changeLocale').change(function() {
var newLang = $(this).val();
$.localise('js/greeting', {language: newLang, loadBase: true});
$('#greeting').val(greeting);
$('#languages').val(newLang);
}).
val($.localise.defaultLanguage).
change();