PHP/JavaScript – managing site language strings

  caching, javascript, jquery, php, user-interface

My website is available in multiple languages.

Should I format the language strings to the page with PHP or JavaScript? For example, should the server detect the user’s language preference and output the right language strings, or should I use JavaScript to do it?

What is the "right way" of doing it?

<?php 

echo "<span id="english">Hi</span>"
echo "<span id="spanish">Hola</span>";

?>

or 
<span id="english"></span>
<span id="spanish"></span>
<script>
$("#english").text("Hi");
$("#spanish").text("Hola");
</script>

Source: Ask PHP

LEAVE A COMMENT