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

HI,how can i use this js in chinse version? #110

Closed jackyrong closed 6 years ago

jackyrong commented 6 years ago

HI,nice to see this project,it sounds really help.now we are making a project which usesd written in struts2,and after we built,customer suddenly wanted to make a english version(we are chinese version),so i want to know if i use jquery-lang.js,should i make two json file?one is chinese version,the other is english version?

Irrelon commented 6 years ago

You just make one file which maps chinese text to english text. The site starts out in chinese and then "converts" to english when you switch language. If you switch back to chinese it restores the original text.

Irrelon commented 6 years ago

But I would have thought that struts would have its own l18n library / system to use? I don't use struts or Java but I'd research that first before choosing the system to use.

jackyrong commented 6 years ago

THANKS FOR reply my question,now my jsp is:

and i have two json,one is cn.json,the other is en.json? cn.json: { "token": { "province":"省份",

}

} en.json: { "token": { "province":"province",

}

} 省份:

are they right?

Irrelon commented 6 years ago

You only need ONE language pack for each EXTRA language. So if your page is already in Chinese, and you want to translate to English, you only need 1 pack, the "en" pack. This is because it uses your existing text as the token and then looks up that text and converts to the matching value in the en.json file. This is all fairly well documented in the readme.md file.

E.G HTML:

省份

en.json:

{
    "token": {
        "省份": "province"
    }
}