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
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>";
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.