I can't get wikimedia's jquery.i18n plugin to work with external files.
This :
// Localisation
$.i18n.debug = true;
$.i18n().load( {
'fr' : {
'message-hello' : 'bonjour!'
},
'en': '/assets/i18n/en.json'
} );
$.i18n().locale = 'fr';
console.log($.i18n('message-hello'));
is working perfectly. Console says:
Loading messages from: /assets/i18n/en.json jquery.i18n.js:269
bonjour!
but this :
// Localisation
$.i18n.debug = true;
$.i18n().load( {
'fr' : {
'message-hello' : 'bonjour!'
},
'en': '/assets/i18n/en.json'
} );
$.i18n().locale = 'en';
console.log($.i18n('message-hello'));
is not. Console says:
Loading messages from: /assets/i18n/en.json jquery.i18n.js:269
message-hello
What am I missing ?
Here is my /assets/i18n/en.json
file :
{
"@metadata": {
"authors": [
"Alice",
"David",
"Santhosh"
],
"last-updated": "2012-09-21",
"locale": "en",
"message-documentation": "qqq",
"AnotherMetadata": "AnotherMedatadataValue"
},
"appname-title": "Example Application",
"appname-sub-title": "An example application with jquery.i18n",
"appname-header-introduction": "Introduction",
"appname-about": "About this application",
"appname-footer": "Footer text",
"message-hello": "hello!"
}
EDIT : If i do $.i18n('message-hello')
from the console, it works. Could this be because the json file is not yet loaded when I call $.i18n('message-hello')
from my script ? And if so, how can I tell the script to wait until it is ?