Closed mcallegari closed 4 years ago
Can you describe how you came to the conclusion that it is looking up the entire string? I haven’t used the plugin for years because no one uses jQuery in production anymore but I don’t remember it having any issues like this...
I see an error message
Translation for "Quite a long text to display some information about this element" not found in language pack: xy
By the way I fixed the code. Might submit a pull request but atm I'm quite busy.
In _storeAttribs
, I translate directly the attribute if both lang
and data-lang-token
are defined.
262,263c262,271
< // Add the attribute and value to the store
< attrObj[attr] = elem.attr(attr);
---
> var eToken = elem.data('langToken');
> if (eToken) {
> var t = this.translate(eToken, this.currentLang);
> //console.log("data token found: " + eToken + ", translation: " + t);
> elem.attr(attr, t);
> }
> else {
> // Add the attribute and value to the store
> attrObj[attr] = elem.attr(attr);
> }
Hi ya, this might be fixed by the update pushed today to version 4.0.0.
The trick is to set the title to the token you want to use rather than the initial text. You also need to make sure you have a language pack for your default language and make sure you've got a translation from the token to the text you want the title attribute to display (but only version 4.0.0).
Closing for now, please re-open if version 4.0.0 doesn't solve the problem for you!
Hello, I'm trying to use this plugin, but there's one thing not working for me.
<span class="a b c" lang="en" data-lang-token="_myToken" title="Quite a long text to display some information about this element" ></span>
The plugin tries to lookup the entire string (inefficient) rather than the token (efficient). Is there a workaround/fix for this?