views:

40

answers:

2

Hi,
i try to build a language selection for my Website.

I use php and Javascript.

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

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 am not sure, is this a good solution? Or is there a better way?

Thanks in advance!
Peter

+4  A: 

Please please please don't make up your own solutions. You'll never get it as right as something that already exists.

Ignacio Vazquez-Abrams
Thank you very much! :)
Peter
+3  A: 

Solutions for your problem already exist, you might want to look into gettext

Here is a tutorial on how to use it with php: http://mel.melaxis.com/devblog/2005/08/06/localizing-php-web-sites-using-gettext/

WakiMiko
Thanks for your fast answer!
Peter