One of the major shortcomings of Blogger is multilingual and, to date, it does not provide a solution to publish entries in different languages.
After some time testing solutions found in the web, I got a fairly simple and satisfactory option, based on jQuery. Its main advantage over most I've seen, is that it allows one entry with different languages, so that the views, comments, etc., are unique. It also attempts to show visitors the most appropriate language, according to the browser settings.
The solution is to create a panel with the contents of the entry in each of the desired languages, and add buttons for each language, showing the corresponding panel when it´s pressed, and hidding the others.
The solution, step by step:
1. Add the jQuery library to our blog template. To do this, go to Template - Edit HTML, and in code we search for </head>. Just behind, copy the following line:
2. Add the script to select default language, and control clicks on the buttons. Paste it below the import line.
3. Add buttons to change language. We can place them in each post; to do that, we have to paste the code in the beginning of each one. The other option is to place the buttons in a fixed location. (Change %your_image% by the url of the image you want to use for the button).
4. For each post, write the text for each language in a div tag, indicating the language in class attribute. Do the same for the title.
And that's it. You can see the result in the entries of this blog. You can add as many languages as you want.
Now, I just have to improve my english...
After some time testing solutions found in the web, I got a fairly simple and satisfactory option, based on jQuery. Its main advantage over most I've seen, is that it allows one entry with different languages, so that the views, comments, etc., are unique. It also attempts to show visitors the most appropriate language, according to the browser settings.
The solution is to create a panel with the contents of the entry in each of the desired languages, and add buttons for each language, showing the corresponding panel when it´s pressed, and hidding the others.
The solution, step by step:
1. Add the jQuery library to our blog template. To do this, go to Template - Edit HTML, and in code we search for </head>. Just behind, copy the following line:
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js' type='text/javascript'/>
2. Add the script to select default language, and control clicks on the buttons. Paste it below the import line.
<script type='text/javascript'> $(document).ready(function() { <!-- Select the initial language --> var userLang = navigator.language || navigator.userLanguage; if (userLang.indexOf("es") >= 0) { $("div.english").hide(); } else { $("div.spanish").hide(); } <!-- If spanish button is clicked, hide english text, and show spanish text --> $("#spanish_button").click(function () { $("div.english").hide(); $("div.spanish").fadeIn(300); }); <!-- If english button is clicked, hide spanish text, and show english text --> $("#english_button").click(function () { $("div.english").fadeIn(300); $("div.spanish").hide(); }); }); </script>
3. Add buttons to change language. We can place them in each post; to do that, we have to paste the code in the beginning of each one. The other option is to place the buttons in a fixed location. (Change %your_image% by the url of the image you want to use for the button).
<img align='right' height='50' id='english_button' src=%your_image% width='50'/> <img align='right' height='50' id='spanish_button' src=%your_image% width='50'/>
4. For each post, write the text for each language in a div tag, indicating the language in class attribute. Do the same for the title.
<div class="english"> English Text. </div> <div class="espanish"> Spanish Text. </div>
And that's it. You can see the result in the entries of this blog. You can add as many languages as you want.
Now, I just have to improve my english...