Irrelon / jquery-lang-js

i18n Allow instant language switching on HTML pages without reloading the page.
https://www.irrelon.com
362 stars 132 forks source link

Issue in Combined Elements #134

Closed mobinco closed 3 years ago

mobinco commented 3 years ago

Hi!

Combined Elements cannot be translated correctly and repeated several times!

Example:

<p lang="en">Or click here to Sign up: 
  <br><a href="register"><button type="button" class="btn btn-primary btn-lg active m-t-1" lang="en">Sign Up</button></a>
</p>

Older version support it.

thanks

Irrelon commented 3 years ago

Hey, thanks for the bug report. Do you know what version it worked on? If so can you let me know and I’ll see if I can find the update that broke this. Nested elements like this are gonna be tricky to support because you have a text node in the same child level as other html nodes.

The easiest fix would be to contain your text with a span and put the lang attribute on the span instead of the p tag, e.g.

<p><span lang=“en”>Or click here to Sign up: </span>
  <br><a href="register"><button type="button" class="btn btn-primary btn-lg active m-t-1" lang="en">Sign Up</button></a>
</p>
mobinco commented 3 years ago

I didn't find the version in the file. But I think I used version 3. I got this version because of the new feature in 4.

Thanks

Irrelon commented 3 years ago

I'm not sure if I can identify the issue or even confirm it was working before in another version. I think the fix I proposed above is the best solution.