当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - How to change a specific value in data-i18n, without using the language files

问题描述:

I am embedding a foreign system that uses i18n into my website. I have no control over the source of language files, and my language isn't one of the available languages there.

But I do have access to JavaScript/jQuery, so I thought I'd change a few of the headers, to give the interface a more localized feel. Not a full translation, just a few of the more prominent values.

Is there a way to select specific i18n elements, and change their value using JavaScript/jQuery?

This is the syntax of the elements I want to change:

<div class="className" data-i18n="some.idententifier">English Value</div>

edit:

Some more research got me to a point where I managed to change content of divs, but it only works when the identifier is one word, no dots.

See this fiddle: http://jsfiddle.net/einavatar/50wnqrym/1/

But all the identifiers on the interface I'm using make use of the dot syntax. How can I hook on to those then?

网友答案:

In your jsfiddle you have doesnt.work as a single key. Split that up into doesnt: { work: "different value" } and you should find it works (ironically unless you change doesnt to does).

分享给朋友:
您可能感兴趣的文章:
随机阅读: