A jQuery plugin that automatically loads JavaScript localisation packages based on the user's language preference. If you find this plugin useful please vote for it on the jQuery site.
The current version is 1.0.4 and is available under the GPL and MIT licences. For more detail see the documentation reference page.
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:
for language
Change to another language
$.localise('js/greeting');
$('#greeting').val(greeting);
$('#languages').val($.localise.defaultLanguage);
$('#changeLocale').change(function() {
var newLang = $(this).val();
$.localise('js/greeting', {language: newLang, loadBase: true});
$('#greeting').val(greeting);
$('#languages').val(newLang);
});
This tab highlights examples of this plugin in use "in the wild".
None as yet.
To add another example, please contact me (kbwood{at}iinet.com.au) and provide the plugin name, the URL of your site, its title, and a short description of its purpose and where/how the plugin is used.
A full list of all possible uses is shown below. For more detail see the documentation reference page.
$.localise(package(s), settings)
$.localise(package(s), language, loadBase, path, timeout)
$.localise.defaultLanguage
$.localize(package(s), settings)
$.localize(package(s), language, loadBase, path, timeout)
$.localize.defaultLanguage
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><script type="text/javascript" src="jquery.localisation.js"></script>
or the packed version jquery.localisation.pack.js (1.6K vs 4.1K)
or minified version jquery.localisation.min.js (1.4K, 0.7K when zipped).<script type="text/javascript" src="mypackage.js"></script><script type="text/javascript">$.localise('mypackage');</script>I am using your code and has made my life very easy.
Contact Keith Wood at kbwood{at}iinet.com.au with comments or suggestions.
| Version | Date | Changes |
|---|---|---|
| 1.0.4 | 07 Mar 2009 |
|
| 1.0.3 | 31 Jan 2009 |
|
| 1.0.2 | 29 Sep 2007 |
|
| 1.0.1 | 01 Sep 2007 |
|
| 1.0.0 | 20 Jun 2007 |
|