Jump to content

PHP welcome message in viewer's language ???


Recommended Posts

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.
Link to comment
Share on other sites

I googled it...
I found something called "HTTP_ACCEPT_LANGUAGE" in the PHP manual:
"'HTTP_ACCEPT_LANGUAGE'
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.

EDIT:
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.