Gruzin Posted February 15, 2007 Share Posted February 15, 2007 Hi guys, I'm making a new web site, so there should be 2 languages: English and Russian. say I have a page: index.php?lang=ENG&id=3 - about us and when user clicks on russian version, page should display russian content of ABOUT US page and not homepage as it is now. Hope my example was helpfull, and if not please tell me about that... Thanks, George Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 15, 2007 Share Posted February 15, 2007 You might want to consider a different way of passing the language around from page to page, possibly with sessions. It's a little bit cleaner. Secondly, you have three sets of information which could potentially need to be in multiple languages. There's hard coded content, such as an actual .html file displayed by the site. For these you'll want to separate the files into directories where the base directory defines the language. i.e: en/home.html <- english sp/home.html <- spanish du/home.html <- dutch There's program output, which is basically strings of text in response to events. For these you'll want to use a string look up table: $lookup['en']['error'] = "Sorry, an error has occurred processing your request."; $lookup['sp']['error'] = "actual spanish"; Then there's potential database data. Not sure how to deal with that. I'd look up programming and internationalization through google. Quote Link to comment Share on other sites More sharing options...
Gruzin Posted February 15, 2007 Author Share Posted February 15, 2007 Thanks, but I'd like to use database... Regards, George Quote Link to comment Share on other sites More sharing options...
Gruzin Posted February 15, 2007 Author Share Posted February 15, 2007 *BUMP* Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 15, 2007 Share Posted February 15, 2007 So put the lookup table into a database. Quote Link to comment Share on other sites More sharing options...
craygo Posted February 15, 2007 Share Posted February 15, 2007 You may be better off with files rather than a database. Only because of the different charactor sets between the 2. Can try it but not sure if it will work or not. If you do want to do it you may have to have 2 tables with different datasets and use a session to select which table the translation comes from. Ray Quote Link to comment Share on other sites More sharing options...
Gruzin Posted February 16, 2007 Author Share Posted February 16, 2007 You may be better off with files rather than a database. Only because of the different charactor sets between the 2. Can try it but not sure if it will work or not. If you do want to do it you may have to have 2 tables with different datasets and use a session to select which table the translation comes from. Ray Thanks a lot! I'll give it a try.... Regards, George Quote Link to comment Share on other sites More sharing options...
superuser2 Posted February 16, 2007 Share Posted February 16, 2007 I agree with sessions. And I tend to see something like this in many scripts: have a file with the language definitions. Like this: english.php $lang['pleaselogin'] = 'Please enter your username and password'; $lang['badlogin'] = 'Invalid username or password'; russian.php $lang['pleaselogin'] = 'Russian for please login'; $lang['badlogin'] = 'Russian for bad password'; Then at the top of every file, check the session. If the language is English, include english.php. If the language is Russian, include russian.php. Then, when you display text, echo something from the $lang array. Then you can always change the text or add more languages later. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.