Jump to content

Selecting a Language / files


MrK

Recommended Posts

I have a script which is english, but i need this script to show both english and german.

 

the english language already has a language file ( english.php ), so i am going to translate all the english wording to german ( german.php )

 

so my question is how can i select the language file, i am going to let the user select the language via a drop down box

 

<OPTION VALUE="English">English</OPTION>

<OPTION VALUE="German">German</OPTION>

<OPTION VALUE="French">French</OPTION>

 

etc etc , so if the user selects the option it will change to the selected language.

 

but how ?

 

Thanks MrK

Link to comment
https://forums.phpfreaks.com/topic/64335-selecting-a-language-files/
Share on other sites

You create string lookup tables.  A simple example.

<?php
  $en = Array();
  $en["HI"] = "Hello";
  $en["BYE"] = "Goodbye";

  $sp = Array();
  $sp["HI"] = "Hola";
  $sp["BYE"] = "Adios";

  // You would set the following var based on their selection from the dropdown
  $lang = $sp; // OR $lang = $en;

  echo $lang["HI"] . "<br>";
  echo $lang["BYE"] . "<br>";
?>

thanks, so if i create one single language file language.php and place all languages in that file , the language that is selected will be visible ?  so no need create separate language files ?

 

just out of interest is there a way using separate files as these files will be translated by individuals that speak the required language

 

thanks for the help

 

mrk

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.