Posted by Frits van Leeuwen on 10/15/06 19:23
>> Good idear. ;-)
>> I know, but do not know how. So I start with 1 page and try to change it
>> into a template with texts form somewere
>
> 1 way that people do this without using a database which is in fact very
> common (just look at forum softwares etc) is to have a seperate file for
> each language.
>
> For example if you have french, english and german you may have 3 files
> called:-
>
> lang_de.php
> lang_en.php
> lang_de.php
>
> In these files you would have an array such as:-
>
> $lang['hello'] = 'hello';
> $lang['welcome_text'] = 'some welcome text';
> $lang['goodbye'] = 'goodbye';
>
> you would have a different line for each section of text (making sure that
> each section of text had a unique key in the array, thats the thing in the
> square brackets).
>
> The other 2 languages would have exactly the same arrays in them but with
> the text after (and only after) translated into the respective language.
>
> on your pages you would need for example a pull down menu so that the
> person can choose their language. when that is submitted you could either
> store the result in a session or in a cookie. At which time you could then
> use an if statement such as the following:-
>
> if($_SESSION['lang'] == 'de')
> {
> require_once('lang_de.php')
> }
> elseif($_SESSION['lang'] == 'fr')
> {
> require_once('lang_fr.php')
> }
> else
> {
> require_once('lang_en.php')
> }
>
> the else 1 would obviously be the default language if nothing was chosen
> (but of course still make it a selection in the pull down menu in case
> someone changes the language and wishes to change it back).
>
> lastly to use the language you simply place $lang['welcome_text'] for
> example where you want the text that this is for to be displayed and it
> will be displayed in the language the person has chosen (or the default
> language if none chosen).
>
> To fully accomplish this take a look in the manual at the following
> pages:-
>
> http://uk.php.net/session_start
> http://uk.php.net/array
How about texts like this?
<p align="center"><span lang="en-gb"><font size="4" face="Monotype Corsiva">
Welcome at the family-website<br></font><font face="Monotype Corsiva"
size="5">"Leeuwendeel.info"</font><font size="4" face="Monotype
Corsiva">.<br>As you can see, we are very busy, to bring this website
online.</font></span></p>
<p align="center"><span lang="en-gb"><font size="4" face="Monotype
Corsiva">New at the site: You can choose Dutch or English.<p>
--------------------------------------------------------------------------------
Mijn Postvak In wordt beschermd door SPAMfighter
4017 spam-mails zijn er tot op heden geblokkeerd.
Download de gratis SPAMfighter vandaag nog!
[Back to original message]
|