Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi language for a Website (php and javascript)


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

like image 340
Peter Avatar asked Oct 20 '10 06:10

Peter


People also ask

Can you use multiple languages for a website?

A multi-lingual website is a website where the content is written in more than one language. The information displayed in different languages is often the same, but maybe tailored for different audiences. Booking.com is an example of a multi-lingual website as its content is available in 35 different languages.

How do you serve a page with content in multiple languages HTML?

To change the language, just simply set the lang attribute. We can define it anywhere in the document, such as in the body, in the paragraph, in the heading, or in the span tag. But the best practice is to set the lang in the span tag.


1 Answers

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

like image 79
Ignacio Vazquez-Abrams Avatar answered Oct 16 '22 09:10

Ignacio Vazquez-Abrams