Jump to content
xisto Community
Sign in to follow this  
miCRoSCoPiC^eaRthLinG

Need Help With Multi-lingual Site Design

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

Like so:

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:
<?phpDEFINE('_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

Share this post


Link to post
Share on other sites

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 :)

 

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 :)

 

~edit~

 

Heh. vujsa beat me to it :)

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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 :) im doing it better then Russian into English :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.