Jump to content


PHP welcome message in viewer's language ???

  • Please log in to reply
1 reply to this topic

#1 j4mes_bond25

  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 12 June 2006 - 12:41 PM

One of the page from my presently under-contruction website can be seen on [a href=\"http://members.lycos.co.uk/darsh25/Personal%20Website/services.php\" target=\"_blank\"]http://members.lycos.co.uk/darsh25/Persona...te/services.php[/a]

As it can be seen from the HEADER (right at the top) that I've the text-size selector (which isn't working, at the moment) along with the present date (as set in user's own computer).

Realising that such a "text-sizer" isn't quite a good idea since browser provides that facility anyway, I'm thinking to get rid-off this text-sizer and leave the "date" code as it is.

However, in the same HEADER area, I wonder if there's ANYTHING in PHP that allows to do the following:

>> Firstly, identify the "clock/time setting" in their computer and then display message saying "Good Morning/Afternoon/Evening".

>> Additionally, I would like this "Good Morning/Afternoon/Evening" appearing in viewers OWN language i.e. if he's from English speaking country then this message should appear in ENGLISH, if he's from French speaking country this message should appear in FRENCH, etc.

I've read a book few months back on PHP which said such a thing could be possible using a PHP script that identifies the "clock timing" along with the "language" set on viewers browser (or something like that).

I really DO NOT want to ask user about their language/country (and then display the message in THEIR language) since not all viewers would appreciate answering such question and beside the services of my website in itself isn't quite relevant to asking such question.

Hence, would there be anything within PHP script that identifies the relevant information (time & language/country) and then display the necessary "Welcome Message" such as:

> Good Morning, Hope you enjoy your stay (if user's location or brower setting is ENGLISH)
> Guten Morning, (same message in German) (if user's location or brower setting is GERMAN).
> Bonjour, (same message in French) (if user's location or brower setting is FRANCE/French speaking location).

Any idea, alternative thing to do instead, recommendation, help or guidance would be greatly appreciated.

#2 pixy

  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 13 June 2006 - 02:28 PM

I googled it...
I found something called "HTTP_ACCEPT_LANGUAGE" in the PHP manual:
Contents of the Accept-Language: header from the current request, if there is one. Example: 'en'."

[a href=\"http://techpatterns.com/downloads/php_language_detection.php\" target=\"_blank\"]http://techpatterns.com/downloads/php_language_detection.php[/a]

This place seems to offer a script that will do the language detection for you. Then you can easily use that to do the different "good morning" languages you wanted.

I found a tutorial on the language thing:
[a href=\"http://www.domsmith.co.uk/resources/4/php_accept_lang.pdf\" target=\"_blank\"]http://www.domsmith.co.uk/resources/4/php_accept_lang.pdf[/a]

It's quite lengthy, but hopefully helpful to you.

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users