I am using jquery-localize plugin for my static web project. I can localize strings in html file, like this:
<p rel=localize[hello]></p>
But I also need to use localized strings in js functions.
How can I correctly access those jquery-localize strings from a function?
alert( localized_strings[hello] ??? );
here is the jquery-localize plugin: https://github.com/coderifous/jquery-localize/blob/master/README.markdown
I’ve no experience with this plugin, but after a look at the code, I believe you can access the data of the loaded package through
where
PACKAGEis the language package you’ve loaded viaand
KEYis the whatever key you want to retrieve (in your examplehello).Since the package is loaded via AJAX you might have to ensure that the data is actually available when you need it. The plugin seems to define a callback method for when the data is loaded an expose it through an option. So you could do something like this: