Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-24-2008, 04:48 AM   PM User | #1
gc40
New Coder

 
Join Date: Aug 2007
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
gc40 is an unknown quantity at this point
Two Langauges, One Site...

Greetings all,
I have made a CMS for a site where the admin can update text content on the home page....

They login to the admin panel and enter a title, and the body.

However, the client wants to offer two languages now. One English, and one French..

Therefore, I made the database changes by adding one extra field called body_french and changed body to body_english...
Now the admin enters the body for both english and french...

The problem comes when I display the database information on the home page.
How should I allow the client to select between English and French?

Should I use sessions? Or should I use a simple PHP If else fucntion?

Also, if I use sessions, can someone direct me how to start? I have never used sessions.
gc40 is offline   Reply With Quote
Old 01-24-2008, 05:16 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,752
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Sessions. And if the users create accounts, store it with the account.
As for changing it, its a simple matter of adding a link for it.
Lets take for example to go to french:
PAGE_NAME?chgLang=french
If you put the control for it in a seperate inclusion file, say global.php:
PHP Code:
<?php
session_start
();

if (isset(
$_GET['chgLang'])):
    
$lang strtolower($_GET['chgLang']);
    switch (
$lang):
        case 
'french':
            
$_SESSION['language'] = 'french';
            break;
        default:
            
$_SESSION['language'] = 'english';
    endswitch;
endif;
Sort of idea. You would use the condition that if no session language exists to use english, otherwise use whatever is specified. I assume you got the linguistics already scripted and just need the condition / session usage yeah?
__________________
PHP Code:
header('HTTP/1.1 420 Enhance Your Calm'); 
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:09 AM.


Advertisement
Log in to turn off these ads.