Multilingual website language (php and javascript)


I am trying to create a language choice for my site.

I am using php and javascript.

My idea is to create a php file for each language.

For example: lang_en.php

<?php
 $lang = array();
 $lang[1] = "Everything is ok!";
 $lang[2] = "Please select a Number.";
?>

<script language="JavaScript" type="text/javascript">
  lang = new Array();
  lang[1] = 'Hello, please select a Button.';
  lang[2] = 'Are you sure?';    
</script>

But I'm not sure if this is a good solution? Or is there a better way?

Thanks in advance!
Peter

+5
source share
2 answers

Please, please do not make your own decisions . You will never get it right, like something that already exists.

+5
source

Solutions to your problem already exist, you might want to view gettext

php: http://mel.melaxis.com/devblog/2005/08/06/localizing-php-web-sites-using-gettext/

+3

All Articles