I am using JQuery Localizer plugin. That plugin has a one function defined like that:
jQuery.fn.localize = function(stringsVar) {
...
}
I want to define a variable inside of it and have an ability to set it. i.e.:
Pseudo code is like that:
jQuery.fn.localize = function(stringsVar) {
var defaultLanguage;
defaultlanguage : function(){
return if defined defaultlanguage else "localizer_en";
}
...
}
I run it as like that right now:
$('html').localize('localize_tr');
So I will able to set default before run it:
localizer.defaultlanguage = 'af'; //just a pseudo code
$('html').localize('localize_tr');
How can I do that with JQuery/Javascript?
You essentially have it already.
The problem you might be running into though, is if you define the default language inside another function. This won’t work:
If this is the case, just make sure you instantiate defaultLanguage outside of Function A. This will work: