Locale language detection and translation?

廉价感情. 提交于 2020-01-25 20:40:06

问题


I am building an offline multi-page mobile application on Dreamweaver, and I am trying to make it so that the application can detect only certain <h1>s and translate them to the locale language the users phone is set to, but I do not know how. below, I want the top <h1> to be translated to the users locale language, while leaving the bottom <h1> in English.

//html

<h1 class="TopText" id="HouseT">Apartment</h1>
<img src"~"/>
<h1 class="BotText" id="HouseB">Apartment</h1>

回答1:


Using jQuery you could write a selector, that matches the first h1 element, but not the second. For example:

'h1.TopText' (select h1 elements having ToText class attribute) or 'h1#HouseT' (selecting h1 elements having HouseT as id) and then go on and manipulate it's contents.

Here is a working example:

$('h1.TopText').html('some other text');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<h1 class="TopText" id="HouseT">Apartment</h1>
<img src"http://placehold.it/100x100"/>
<h1 class="BotText" id="HouseB">Apartment</h1>


来源:https://stackoverflow.com/questions/38416738/locale-language-detection-and-translation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!