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

data-lang-token can't have more than one? #111

Closed Deelite310 closed 6 years ago

Deelite310 commented 6 years ago

edit: okay found the issue, so can data-lang-token contain HTML elements? I would need to be able to replace HTML elements for certain languages

Example: English = <div lang="en" data-lang-token="dolor"><ul><li>1</li><li>2</li></ul></div> Spanish = <div lang="es" data-lang-token="dolor"><ul><li>1</li><li>2</li><li>3</li></ul></div> As I'm looking to replace entire content in html, does this script have issues with html in the use of data-lang-token ?

Example:

<div>
Long text translation with a custom defined token(data-lang-token attribute):<br>
<div lang="en" data-lang-token="lorem">Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in ...</div>
</div>
<div>
Change Elements:<br>
<div lang="en" data-lang-token="change"><b>Hello</b></div>
</div>

Once I added in the new data-lang-token="change" and placed the token in the language files, the script breaks.

example from language file:

{
    "token": {
        "Property Search":"Búsqueda de Propiedades",
        "lorem" : "Quisque dapibus dictum ligula non lobortis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
        "change" : "<i>Hola</i>"
    },
    "regex": [
        ["Budget", "Presupuesto"]
    ]
}