Maybe it is a trivial task, but I am really bad in web programming... Their exist a bunch of Homepages, like Wikipedia, which have a language annotation in the URL (e.g. the German Wikipedia side is de.wikipedia.org). Hence, connecting to Wikipedia in multiple languages is trivial, one only need to change "de" by "en" for example. This leads to my problem. What to do if an homepage offers multiple languages but don't have a language annotation in their URL?
When I connect with Java to the following homepage (http://ift.tt/1McrcR6), it is always presented in English. I found out, that English is the default language. However, they offer to change the language by clicking on the language type at the top right side. From the source code, the following code fragment shows the active language:
<div id="languages-selector">
<form id="lang-select-form" name="lang-select-form" method="post" action="/index.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="lang-select-form" value="lang-select-form" />
<input type="hidden" name="javax.faces.ViewState" id="j_id1_javax.faces.ViewState_0" value="8624728434571030461:-486100683348744248" autocomplete="off" />
<ul>
<!-- German -->
<li>
<script type="text/javascript" src="/javax.faces.resource/jsf.js.xhtml?ln=javax.faces"></script>
<a id="lang-select-form_de" href="#" onclick="mojarra.jsfcljs(document.getElementById('lang-select-form'),{'lang-select-form_de':'lang-select-form_de'},'');return false" class="inactive">Deutsch</a>
</li>
<!-- French -->
<li><a id="lang-select-form_fr" href="#" onclick="mojarra.jsfcljs(document.getElementById('lang-select-form'),{'lang-select-form_fr':'lang-select-form_fr'},'');return false" class="inactive">Français</a>
</li>
<!-- Italian -->
<li><a id="lang-select-form_it" href="#" onclick="mojarra.jsfcljs(document.getElementById('lang-select-form'),{'lang-select-form_it':'lang-select-form_it'},'');return false" class="inactive">Italiano</a>
</li>
<!-- English -->
<li class="last"><a id="lang-select-form_en" href="#" onclick="mojarra.jsfcljs(document.getElementById('lang-select-form'),{'lang-select-form_en':'lang-select-form_en'},'');return false" class="active">English</a>
</li>
</ul>
</form>
</div>
Hence finding out, which of the languages is active, is easy. Nevertheless, I don't find out, how I can tell the side using Java to set the active language to German without clicking on their link at the top right side. Any idea?
Thank you.
Aucun commentaire:
Enregistrer un commentaire