What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Language selector

Language selector
Author: Message:
wohow
New Member
*


Posts: 2
– / Male / –
Joined: Oct 2005
O.P. Language selector

Hi ya!

I just registered a couple of hours ago as a member of this community (a friend of mine told me about MP! yesterday...) and I've come across a tech problem lol.

I'm sure it should be kinda easy to work out, but, honestly, I have no idea about webpage programming so... I guess I've been wasting more than enough time on this. Anyway, here it goes:

I'm trying to make some kind of script (I don't mind using PHP, JavaScript... as long as it works :^)) which would get the user's navigator language. There'd be 2 possibilities: Spanish or non-Spanish (English). As a result, the script would "embed" or "include" (dunno how you'd refer to that in English...) the appropiate page (ie: indexsp.htm) into the script page (index.htm).

I've already found a couple of examples on the Internet, in JavaScript... but they relocate the URL, which is something I don't wanna do...

I know this sounds extremely stupid/rubbish, but I haven't got a clue....

Nice to join ya and thank you so much!

Luis

This post was edited on 10-07-2005 at 09:33 PM by wohow.
10-07-2005 08:59 PM
Profile PM Find Quote Report
rav0
Veteran Member
*****

Avatar
i have an avatar

Posts: 1419
Reputation: 29
35 / Male / Flag
Joined: Aug 2003
RE: Language selector
I'm not really sure of this, but since nobody else has replied, I'll add this.

It checks if the user agent (browser) accepts Spanish, and if so, includes indexsp.htm, otherwise includes index.htm. It also sets the content language HTTP header to Spanish or English depending on which file was included.

I've tested it on my computer and the English half works, but I don't know about the Spanish part because I don't have a computer in Spanish.

code:
<?php
if($_SERVER['HTTP_ACCEPT_LANGUAGE']=='es')
      {
      header('content-language:es');
      include 'indexsp.htm';
      }
else
      {
      header('content-language:en');
      include 'index.htm';
      }
?>
Hopefully somebody with better knowledge can take a look at this and modify or improve this where it needs to be.

Update:
Changed sp to es in line two of code.

This post was edited on 10-11-2005 at 09:04 AM by rav0.
| [Image: dorsh] |

(\ /)
(O.o)
(> <)

This is Bunny. Copy Bunny into your signature to help him on his way to world domination
10-08-2005 01:52 AM
Profile E-Mail PM Web Find Quote Report
wohow
New Member
*


Posts: 2
– / Male / –
Joined: Oct 2005
O.P. Grin  RE: Language selector

It works like a dream!

I just modified the 'sp' (should be 'es', to determine whether the computer accepts Spanish or not).

Cheers mate!
10-08-2005 08:16 AM
Profile PM Find Quote Report
rav0
Veteran Member
*****

Avatar
i have an avatar

Posts: 1419
Reputation: 29
35 / Male / Flag
Joined: Aug 2003
RE: Language selector
Yay, it works!

That's the most complex PHP I've ever written, so I'm proud :D.

PS I has es as the language code in my local version (it took ages to find out what it should be as well), I don't know why the version I posted had sp in it.
| [Image: dorsh] |

(\ /)
(O.o)
(> <)

This is Bunny. Copy Bunny into your signature to help him on his way to world domination
10-11-2005 08:49 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On