The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> display text based on browser language, display text based on browser language
vinay b
post Feb 21 2010, 10:12 PM
Post #1





Group: Members
Posts: 4
Joined: 21-February 10
Member No.: 11,165



Hi,

I have a requirement where in the same html should display different text based on the browser language.
Is it possible to display/ hide the text this way?

If yes please assist as soon as possible.

Thanks a Ton!!!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Feb 21 2010, 11:07 PM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,283
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



You can use content negotiation to send different documents based on the Accept-Language header sent by the browser.
http://httpd.apache.org/docs/2.0/content-negotiation.html

You could also generate the page with a server-side (e.g., CGI, PHP) program, and have that program generate different content depending on the value of the Accept-Language header.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Feb 21 2010, 11:57 PM
Post #3


Jocular coder
********

Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43



QUOTE(vinay b @ Feb 22 2010, 12:12 PM) *

Hi,

I have a requirement where in the same html should display different text based on the browser language.
Is it possible to display/ hide the text this way?

If yes please assist as soon as possible.

Thanks a Ton!!!


What do you mean by "browser language"? I don't think that strictly speaking you have any access to the user interface language of the browser, if that is what you mean.

Probably this is yet another Clueless Monolinguals project: yes, CM browsers send an "accept language", indicating "The Language" of the CM. But many people in the world are not CMs, and this "content negotiation" causes endless nuisance. It means that someone says "On this page (URL) it says such and such", I click on the link, and see something entirely different.

It's a very stupid idea, unless you think (as CMs seem to) that there is a magic thing called "translation", whereby Exactly The Same Words come out in a "different language". Well, there isn't, and they don't.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
vinay b
post Feb 22 2010, 12:41 AM
Post #4





Group: Members
Posts: 4
Joined: 21-February 10
Member No.: 11,165



QUOTE(Brian Chandler @ Feb 22 2010, 10:27 AM) *

QUOTE(vinay b @ Feb 22 2010, 12:12 PM) *

Hi,

I have a requirement where in the same html should display different text based on the browser language.
Is it possible to display/ hide the text this way?

If yes please assist as soon as possible.

Thanks a Ton!!!


What do you mean by "browser language"? I don't think that strictly speaking you have any access to the user interface language of the browser, if that is what you mean.

Probably this is yet another Clueless Monolinguals project: yes, CM browsers send an "accept language", indicating "The Language" of the CM. But many people in the world are not CMs, and this "content negotiation" causes endless nuisance. It means that someone says "On this page (URL) it says such and such", I click on the link, and see something entirely different.

It's a very stupid idea, unless you think (as CMs seem to) that there is a magic thing called "translation", whereby Exactly The Same Words come out in a "different language". Well, there isn't, and they don't.


Hi Brian,
I dint mean the language gets translated all by itself. It off course isnt some magic:)
What I meant is that, I wanted to check this language parameter set in the browser of the person logged in, and based on the language I will show the person the text he/she expects, which is already translated and written there in the same page by me.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
vinay b
post Feb 22 2010, 01:08 AM
Post #5





Group: Members
Posts: 4
Joined: 21-February 10
Member No.: 11,165



QUOTE(Darin McGrew @ Feb 22 2010, 09:37 AM) *

You can use content negotiation to send different documents based on the Accept-Language header sent by the browser.
http://httpd.apache.org/docs/2.0/content-negotiation.html

You could also generate the page with a server-side (e.g., CGI, PHP) program, and have that program generate different content depending on the value of the Accept-Language header.


Hi Darin,

I did check the link, thank you smile.gif , unfortunately I am not much aware of Apache and how to use it.
I understand that it has this Accept-Language through which it might help, but I am ignorant of how to use it in an HTML. Can you please guide me further.

Thank you:)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Feb 22 2010, 02:03 AM
Post #6


Jocular coder
********

Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43



QUOTE(vinay b @ Feb 22 2010, 02:41 PM) *

Hi Brian,
I dint mean the language gets translated all by itself. It off course isnt some magic:)
What I meant is that, I wanted to check this language parameter set in the browser of the person logged in, and based on the language I will show the person the text he/she expects, which is already translated and written there in the same page by me.


Well, Darin more or less gave you the answer. You can't do this "in html": you either fiddle with the .htaccess file to specify to Apache to send different files, or you write some server scripting to send selective content.

But: I am trying to urge you to make all of your content available to everyone. Just suppose you are from Quebec and want to provide French and English versions of some of your writing. (Great!) Offer them both. If someone only reads French, and gets a link to your website from some other page they are reading in French, the link will naturally go to the French version. It sounds seductively plausible that someone might "arrive", and you need to worry about what language you speak to them, but it can hardly ever happen. (Try giving examples: the obvious ones are that someone may find your _home_ page from Google maps, or by seeing the URL written on the side of a vehicle. But these have to be either language-neutral situations, or ones where the source site (Google maps for example) has a (viewing) language but there is no mechanism for it to connect to the language of the target website.)

The current "negotiation" design is no good, because it does not let the intelligent agent (the person viewing) make the decision based on what the unintelligent agent (the website) offers. There needs to be a mechanism for the website to tell the browser what languages are available, so that the user can choose depending on the situation. (For example, I want to read websites written in English in English, not some ghastly mistranslation into Japanese, and vice versa.)

HTH
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
vinay b
post Feb 24 2010, 02:45 AM
Post #7





Group: Members
Posts: 4
Joined: 21-February 10
Member No.: 11,165



Hi,

My query is resolved. I have applied javascript to detect the browser language and in the if loop have given the redirecting link.

Thanks and Regards,
Vinay Baji

This post has been edited by vinay b: Feb 24 2010, 02:45 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Adrio
post Aug 19 2011, 06:32 AM
Post #8





Group: Members
Posts: 7
Joined: 15-August 11
Member No.: 15,183



I think the main problem here is that the browser settings don't actually affect the navigator.language property that is obtained via javascript.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Aug 19 2011, 06:35 AM
Post #9


Jocular coder
********

Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43



QUOTE(Adrio @ Aug 19 2011, 08:32 PM) *

I think the main problem here is that the browser settings don't actually affect the navigator.language property that is obtained via javascript.


What reason do you have for thinking that?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 20th November 2018 - 08:19 AM