In the last modules we were talking about the content negotiation in the Http protocol and how the quality
parameter helps a client decide what is the content that it wants.
So continuing with that today, we'll be talking about the excerpt and the content language headers
in the Http protocol.
So by the name itself Accept language header tells that it basically is used to determine on what is
the language that client prefers.
Within the response.
So we have already seen this example where in the Excel language there are three languages over here
and each of the languages associated with a parameter.
So the first preference is the Danish.
Second preference becomes British English because it has a score of 0.8 and the last preference is 0.7.
So accept language header is very useful in a website which has multiple languages.
So let's see on how it will help us.
So let's say this is a server which is example.com, which has two variants.
One is English for English users and one is Japanese for Japanese users.
So how will the example.com server determine on which page to serve?
So during this time the accept language header comes into play.
So if the accept language header is J which stands for Japanese, then the server will serve the Japanese
version of the page.
However, it is n which is English.
Then the server will serve the English version of the page.
So the server has to know or it has to extract a value from the accept language header which the client's
browser will send along with the page.
Now there is one more important header called content language, which basically determines the language
of the body for the intended audience.
Please note that it is not saying that the language of the message body.
It says language of the message body for the intended audience.
So there is difference.
So let's take a simple example where the content language header says N.
So what this basically determines is that this.
The body is specific for intended audience who understands English.
So if I give you a day to day example, let's say a travel guide for China.
So if a person is visiting a China, there is a travel website with a travel guide.
Now the travel guide is intended for English audience or the people who understands English.
However, the document also contains basic Chinese sentences that can help people in day to day communication
in local languages.
So during that time, the document contains both English as well as Chinese based characters.
However, it is specifically for people who understands English.
So during that time the content language becomes Ian.
Although it has Chinese characters still, as it is specific for English based audience, the content
language will be Ian.
So as we're talking about the Multi-language website, let me show you an example of how it works along
with the accept language headers.
So.
I have a server and if I do a call, let me show you curl followed by header.
Say header that I want is accept language.
Say my preferences in which is English followed by the name of the website.
Say example.com slash hi dot HTML.
And the contents are.
This is English version of the website.
So now let's modify the header.
From N to J.
So J stands for Japanese.
And now you see, this is a Japanese version of the website.
And this is one of the reasons why the Accept language header instructs the server on what type of language
it would prefer in the response.
Now, again, it is very important to know the exact language followed by N or J is specified in the
browser.
So by default, if you are downloading Chrome or Firefox in the European or maybe even in India, then
by default the language is n.
However, for other languages, other countries, the language might differ in the browsers.
So this is something that you can always change depending upon your requirement.
So this is it about the basics of except language and content language headers in the Http protocol.
So I hope this video has been informative for you and I'd like to thank you for viewing.