How to deal with translation by code?

Highlighted
New Member
4 0 0

Hi

 

I have changed theme code so much so I think translation app is not suitable for my web-page.

I have written code for translation.

 

<div data-tl="example">example</div>

 

<script>

 

$.lang = {};

$.lang.es = {

"example" :"ejemplo",

};

 

function setLanguage(currentLanguage) {

$('[tl]').each(function() {
var $this = $(this);
$this.html($.lang[currentLanguage][$this.data('tl')]);

}

 

setLanguage("es");

</script>

 

I have noticed that most of web cralwers get page data before web page runs Javascript which means my code causes 'duplicated content' problem.

 

I would like to know if there is any way to solve my problem.

Could you please help me?

 

Thank you. 

0 Likes