Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Need Help With Multi-lingual Site Design
miCRoSCoPiC^eaRt...
post Jan 17 2007, 09:46 AM
Post #1


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411



Does any of you have any ideas on multi-lingual site design? I'm looking for some resources/guides that'll show me the exact technique of achieving this...

I am NOT looking for the Google Translate kind of option, where you've got a bunch of buttons on your site - clicking on which, will pass your page through Google Translator producing a totally garbled grammatical output in another language...

What I want is to define every Text Element on the site as variables and depending on the lanugage of your choice, these variables are filled in from pre-defined language files containing key-value pair declarations of the same.

I know this is very much possible in Firefox extensions - how do you go about doing the same for web-pages ?

Thanks,
m^e
Go to the top of the page
 
+Quote Post
vujsa
post Jan 17 2007, 10:59 AM
Post #2


Absolute Newbie
Group Icon

Group: Admin
Posts: 888
Joined: 20-February 05
From: Indianapolis, Indiana, USA (Midwest)
Member No.: 2,714



Generally speaking in PHP at least, the language file is nothing more than a list of defined constants.

Like so:
CODE

DEFINE('_LANGUAGE','en');
DEFINE('_NOT_AUTH','You are not authorized to view this resource.');
DEFINE('_DO_LOGIN','You need to login.');
DEFINE('_VALID_AZ09',"Please enter a valid %s.  No spaces, more than %d characters and contain 0-9,a-z,A-Z");
DEFINE('_VALID_AZ09_USER',"Please enter a valid %s.  More than %d characters and contain 0-9,a-z,A-Z");
DEFINE('_CMN_YES','Yes');
DEFINE('_CMN_NO','No');
DEFINE('_CMN_SHOW','Show');
DEFINE('_CMN_HIDE','Hide');


Basically, you load this file very near the top of your script. Probably after you determine the users preference and every time PHP comes accross one of your defined constants, it replaces the constant with the text..

Pretty simple, right?

So here is some code for you to look at:
CODE

<?php
DEFINE('_LOGIN_SUCCESS','You have successfully Logged In');
DEFINE('_LOGOUT_SUCCESS','You have successfully Logged Out');

if($new_session == TRUE){
    echo _LOGIN_SUCCESS;
}

if($session_end == TRUE){
    echo _LOGOUT_SUCCESS;
}


Now of course, you'll need to store the user's preference somewhere. If you will have regular members, you can set a default language preference in the database for the user but visitors will have to choose each visit. Take your pick as to how you will manage your user sessions and then adapt a language variable to that. You could set a long term cookie on the user's system to ensure that their prefered language is preselected but that is up to you.

Good Luck.

vujsa
Go to the top of the page
 
+Quote Post
pyost
post Jan 17 2007, 11:02 AM
Post #3


Nenad Bozidarevic
Group Icon

Group: [MODERATOR]
Posts: 1,013
Joined: 7-November 05
From: Belgrade, Serbia
Member No.: 9,500



If you are doing a site from scratch, this shouldn't be a problem, as you will know exactly what structure to use. However, redesigning one probably isn't worth the trouble.

Anyway, this is how I would solve this problem - assuming that all your pages are PHP. In the page URL, there would always be a language attribute that determines which one to use. Let's say your site offers English, French and German. Therefore, the possible values would be lang=en, fr, de. If the value doesn't match any of these, or isn't set, the default language is used. All of this is a simple case command in PHP.

As for the text elements you will be using, it would be best if you stored them in a separate PHP file for each language (for example, /lang/en.php). Since you have already figured out which language the visitor wants to use, you would just add the language file to your current page - include/require('lang/en.php'). Now you would have all the text elements available inside variables smile.gif

Of course, there are several downsides to this method. First, which is not so bad, you would have to add the language parameter to all the links. And second, it would be a lot harder to create content, as there would be now text in the code, only variables. But it sure is useful if you plan on adding more languages later on.

By the way, I believe this is exactly how IPB works, so you might want to take a look wink.gif

~edit~

Heh. vujsa beat me to it tongue.gif
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Jan 18 2007, 02:15 PM
Post #4


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411



Thanks guys.. am working out the login/member maintenance issues of a test site... and am going to implement multilingual interface for it.. hence the queries.. Will get back to you with more pestering questions the moment I get around to working on this issue biggrin.gif
Go to the top of the page
 
+Quote Post
pyost
post Jan 18 2007, 05:37 PM
Post #5


Nenad Bozidarevic
Group Icon

Group: [MODERATOR]
Posts: 1,013
Joined: 7-November 05
From: Belgrade, Serbia
Member No.: 9,500



And how about some more information on what you are woking on? Are you doing a complete site, or merely editing an already existing PHP script?
Go to the top of the page
 
+Quote Post
Aka_Bar
post Jan 18 2007, 07:30 PM
Post #6


Member - Active Contributor
Group Icon

Group: Members
Posts: 87
Joined: 4-November 06
Member No.: 16,990



miCRoSCoPiC^eaRthLinG, i can help you with Russian Language, if you want you are welcom, i wll help you with pleasure!!! cotact with me any time!! Russian is my first lang so i wll not have problems with that!! i have years of experiense in translation From English to Russian smile.gif im doing it better then Russian into English smile.gif
Go to the top of the page
 
+Quote Post
pyost
post Jan 18 2007, 08:09 PM
Post #7


Nenad Bozidarevic
Group Icon

Group: [MODERATOR]
Posts: 1,013
Joined: 7-November 05
From: Belgrade, Serbia
Member No.: 9,500



Now that you mention it, I can do Serbian translation, though I don't know why you would want to have it biggrin.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Music On My Site?(18)
  2. Help me(3)
  3. Site Designing(21)
  4. Free Templates(3)
  5. Add A Search Box To My Web Site(10)
  6. Why A Site Is Viewed Differently In Browsers(12)
  7. Web Site Trackers?(8)
  8. Wap Sites(4)
  9. What Is The Best Language For Web Site ?(23)
  10. Get Afree Template For Your Site(3)
  11. How Do You Put Flash Into Your Site?(7)
  12. Find Out Dead Links In Your Site Automatically(11)
  13. Programing My Site(4)
  14. Multi-user Blogs?(6)
  15. Free Shoutbox For Your Web-site(12)
  1. Good Site To Download Web Templates ?(21)
  2. Embeding Font Files(1)
  3. Redirecting All Htm Files To Php Site...(8)
  4. How Can You Spice Up Your Basic HTML Site ? Beginner Needs Help(9)
  5. How To Display XX Users Online On Your Site ?(5)
  6. With Or Without Tabs?(15)
  7. How Do I Keep A Background On My Site(14)
  8. Help Choose A New Banner For Me Please(11)
  9. Thinking About An "audio" Web Site(4)
  10. Cvs For Maintaining Your Site(0)
  11. Unicode Encoded Site - Characters Not Displaying Properly?(4)
  12. Stretching My Site Vertically(6)
  13. Website Navigation Hover Buttons Stick So Made Css Today(7)


 



- Lo-Fi Version Time is now: 16th October 2008 - 04:06 AM