Translate attr place holder!
Hi all,
I'm translating my store element's, everything seems to work fine, but I can't manage to translate the attr 'placeholder' acording to the language. Maybe you can advice a method how to do it.
Here is the HTML:
- <nav>
- <div class="nav-holder row">
- <ul>
- <li><a href="http://stores.ebay.es/100x100ORYGINAL" class="tr" key="tienda">Tienda</a></li>
- <li><a href="http://stores.ebay.es/100x100ORYGINAL/PAGO-Y-ENVIO.html" class="tr" key="pagos-envios">Pagos y Envíos</a></li>
- <li><a href="http://stores.ebay.es/100x100ORYGINAL/DEVOLUCIONES.html" class="tr" key="devoluciones">Devoluciones</a></li>
- <li><a href="http://stores.ebay.es/100x100ORYGINAL/TERMINOS-CONDICIONES-LEGALES.html" class="tr" key="condiciones">Condiciones</a></li>
- <li><a href="http://stores.ebay.es/100x100ORYGINAL/ATENCION-AL-CLIENTE.html" class="tr" key="att-cliente">Atención al cliente</a></li>
- </ul>
- </div>
- </nav>
- <div id="buscar">
- <form name="search" method="get" action="http://search.stores.ebay.es/search/search.dll?GetResult&">
- <input class="input" type="text" name="query" maxlength="300" placeholder="Buscar...">
- <input type="hidden" name="fcd" value="2">
- <input type="hidden" name="from" value="R10">
- <input type="hidden" name="sid" value="1066798634">
- <input class="btn" name="submit" type="submit" value="">
- </form>
- </div><!-- End Search Container -->
-
- <div class="lang_switcher">
- <button id="it" class="lang">IT</button>
- <button id="fr" class="lang">FR</button>
- <button id="es" class="lang">ES</button>
- </div>
I'm using this script to make the translation
Translation and added some extras to check the url and asign correct language. But I can't get it to work with the placeholder.
Here is the full script I'm working on:
- // preparing language file
- var aLangKeys=new Array();
- aLangKeys['it']=new Array();
- aLangKeys['fr']=new Array();
- aLangKeys['es']=new Array();
- aLangKeys['it']['tienda']='Negozio';
- aLangKeys['it']['pagos-envios']='Pagamenti e Spedizione';
- aLangKeys['it']['devoluciones']='Restituisce';
- aLangKeys['it']['condiciones']='Condizioni';
- aLangKeys['it']['att-cliente']='Servizio clienti';
- aLangKeys['it']['dias']='Lunedì - Venerdì'
- aLangKeys['fr']['tienda']='Boutique';
- aLangKeys['fr']['pagos-envios']='Pagamenti e Spedizione';
- aLangKeys['fr']['devoluciones']='Retours';
- aLangKeys['fr']['condiciones']='Conditions';
- aLangKeys['fr']['att-cliente']='Service à la clientèle';
- aLangKeys['fr']['dias']='Lundi - Vendredi'
- aLangKeys['es']['tienda']='Tienda';
- aLangKeys['es']['pagos-envios']='Pagos y Envíos';
- aLangKeys['es']['devoluciones']='Devoluciones';
- aLangKeys['es']['condiciones']='Condiciones';
- aLangKeys['es']['att-cliente']='Atención al cliente';
- aLangKeys['es']['dias']='Lunes - Viernes'
- $(document).ready(function() {
- if(document.URL.indexOf("ebay.fr") != -1) {
- $('body').attr('id','fr');
- var lang = $('body').attr('id');
- $('.tr').each(function(i){
- $(this).text(aLangKeys[lang][ $(this).attr('key') ]);
- });
- $('a').each(function(){
- this.href = this.href.replace('ebay.es','ebay.' + lang);
- });
- } else
- if(document.URL.indexOf("ebay.it") != -1) {
- $('body').attr('id','it');
- var lang = $('body').attr('id');
- $('.tr').each(function(i){
- $(this).text(aLangKeys[lang][ $(this).attr('key') ]);
- });
- $('a').each(function(){
- this.href = this.href.replace('ebay.es','ebay.' + lang);
- });
- } else
- if(document.URL.indexOf("ebay.es") != -1) {
- $('body').attr('id','es');
- var lang = $('body').attr('id');
- $('.tr').each(function(i){
- $(this).text(aLangKeys[lang][ $(this).attr('key') ]);
- });
- $('a').each(function(){
- this.href = this.href.replace('ebay.es','ebay.' + lang);
- });
- };
- // onclick behavior
- $('.lang').click( function() {
- var lang = $(this).attr('id'); // obtain language id
- // translate all translatable elements
- $('.tr').each(function(i){
- $(this).text(aLangKeys[lang][ $(this).attr('key') ]);
- $('body').attr('id', lang);
- $('body' + '#' + lang).find('a').each(function(){
- this.href = this.href.replace('ebay.es','ebay.' + lang);
- });
- });
- });
- });
Any advice will be highly appreciated!
Thanks to all,