6


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

2 Answers 2

5

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

Sign up to request clarification or add additional context in comments.

Comments

3

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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.