Translate attr place holder!

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:
  1. <nav>
  2. <div class="nav-holder row">
  3. <ul>
  4. <li><a href="http://stores.ebay.es/100x100ORYGINAL" class="tr" key="tienda">Tienda</a></li>
  5. <li><a href="http://stores.ebay.es/100x100ORYGINAL/PAGO-Y-ENVIO.html" class="tr" key="pagos-envios">Pagos y Envíos</a></li>
  6. <li><a href="http://stores.ebay.es/100x100ORYGINAL/DEVOLUCIONES.html" class="tr" key="devoluciones">Devoluciones</a></li>
  7. <li><a href="http://stores.ebay.es/100x100ORYGINAL/TERMINOS-CONDICIONES-LEGALES.html" class="tr" key="condiciones">Condiciones</a></li>
  8. <li><a href="http://stores.ebay.es/100x100ORYGINAL/ATENCION-AL-CLIENTE.html" class="tr" key="att-cliente">Atención al cliente</a></li>
  9. </ul>
  10. </div>
  11. </nav>
  12.             <div id="buscar">
  13.              <form name="search" method="get" action="http://search.stores.ebay.es/search/search.dll?GetResult&">
  14.                     <input class="input" type="text" name="query" maxlength="300" placeholder="Buscar...">
  15.                     <input type="hidden" name="fcd" value="2">
  16.                     <input type="hidden" name="from" value="R10">
  17.                     <input type="hidden" name="sid" value="1066798634">
  18.                     <input class="btn" name="submit" type="submit" value="">
  19.                 </form>
  20.             </div><!-- End Search Container -->
  21. <div class="lang_switcher">
  22.   <button id="it" class="lang">IT</button>
  23.   <button id="fr" class="lang">FR</button>
  24.   <button id="es" class="lang">ES</button>
  25. </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:

  1. // preparing language file
  2. var aLangKeys=new Array();
  3. aLangKeys['it']=new Array();
  4. aLangKeys['fr']=new Array();
  5. aLangKeys['es']=new Array();

  6. aLangKeys['it']['tienda']='Negozio';
  7. aLangKeys['it']['pagos-envios']='Pagamenti e Spedizione';
  8. aLangKeys['it']['devoluciones']='Restituisce';
  9. aLangKeys['it']['condiciones']='Condizioni';
  10. aLangKeys['it']['att-cliente']='Servizio clienti';
  11. aLangKeys['it']['dias']='Lunedì - Venerdì'

  12. aLangKeys['fr']['tienda']='Boutique';
  13. aLangKeys['fr']['pagos-envios']='Pagamenti e Spedizione';
  14. aLangKeys['fr']['devoluciones']='Retours';
  15. aLangKeys['fr']['condiciones']='Conditions';
  16. aLangKeys['fr']['att-cliente']='Service à la clientèle';
  17. aLangKeys['fr']['dias']='Lundi - Vendredi'

  18. aLangKeys['es']['tienda']='Tienda';
  19. aLangKeys['es']['pagos-envios']='Pagos y Envíos';
  20. aLangKeys['es']['devoluciones']='Devoluciones';
  21. aLangKeys['es']['condiciones']='Condiciones';
  22. aLangKeys['es']['att-cliente']='Atención al cliente';
  23. aLangKeys['es']['dias']='Lunes - Viernes'

  24. $(document).ready(function() {
  25.     if(document.URL.indexOf("ebay.fr") != -1) {
  26.       $('body').attr('id','fr');
  27.         var lang = $('body').attr('id');
  28.         $('.tr').each(function(i){
  29.           $(this).text(aLangKeys[lang][ $(this).attr('key') ]);
  30.         });
  31.         $('a').each(function(){
  32.           this.href = this.href.replace('ebay.es','ebay.' + lang);
  33.         });
  34.     } else 
  35.     if(document.URL.indexOf("ebay.it") != -1) {
  36.       $('body').attr('id','it');
  37.         var lang = $('body').attr('id');
  38.         $('.tr').each(function(i){
  39.           $(this).text(aLangKeys[lang][ $(this).attr('key') ]);
  40.         });
  41.         $('a').each(function(){
  42.           this.href = this.href.replace('ebay.es','ebay.' + lang);
  43.         });
  44.     } else 
  45.     if(document.URL.indexOf("ebay.es") != -1) {
  46.       $('body').attr('id','es');
  47.         var lang = $('body').attr('id');
  48.         $('.tr').each(function(i){
  49.           $(this).text(aLangKeys[lang][ $(this).attr('key') ]);
  50.         });
  51.         $('a').each(function(){
  52.           this.href = this.href.replace('ebay.es','ebay.' + lang);
  53.         });
  54.     };
  55.     // onclick behavior
  56.     $('.lang').click( function() {
  57.         var lang = $(this).attr('id'); // obtain language id
  58.         // translate all translatable elements
  59.         $('.tr').each(function(i){
  60.           $(this).text(aLangKeys[lang][ $(this).attr('key') ]);
  61.           $('body').attr('id', lang);
  62.           $('body' + '#' + lang).find('a').each(function(){
  63.             this.href = this.href.replace('ebay.es','ebay.' + lang);
  64.           });
  65.         });
  66.     });
  67. });

Any advice will be highly appreciated!

Thanks to all,