WEBVTT

00:00.230 --> 00:07.070
In the last modules we were talking about the content negotiation in the Http protocol and how the quality

00:07.070 --> 00:12.680
parameter helps a client decide what is the content that it wants.

00:13.300 --> 00:19.900
So continuing with that today, we'll be talking about the excerpt and the content language headers

00:19.900 --> 00:21.550
in the Http protocol.

00:23.700 --> 00:32.520
So by the name itself Accept language header tells that it basically is used to determine on what is

00:32.520 --> 00:34.980
the language that client prefers.

00:35.830 --> 00:37.330
Within the response.

00:37.870 --> 00:44.530
So we have already seen this example where in the Excel language there are three languages over here

00:44.530 --> 00:48.250
and each of the languages associated with a parameter.

00:48.610 --> 00:51.400
So the first preference is the Danish.

00:51.430 --> 00:59.290
Second preference becomes British English because it has a score of 0.8 and the last preference is 0.7.

01:00.490 --> 01:06.880
So accept language header is very useful in a website which has multiple languages.

01:07.120 --> 01:11.230
So let's see on how it will help us.

01:12.070 --> 01:16.950
So let's say this is a server which is example.com, which has two variants.

01:16.960 --> 01:23.920
One is English for English users and one is Japanese for Japanese users.

01:24.670 --> 01:30.340
So how will the example.com server determine on which page to serve?

01:30.940 --> 01:36.190
So during this time the accept language header comes into play.

01:37.110 --> 01:45.930
So if the accept language header is J which stands for Japanese, then the server will serve the Japanese

01:45.930 --> 01:47.040
version of the page.

01:47.580 --> 01:50.690
However, it is n which is English.

01:50.700 --> 01:54.960
Then the server will serve the English version of the page.

01:55.980 --> 02:03.930
So the server has to know or it has to extract a value from the accept language header which the client's

02:03.930 --> 02:06.420
browser will send along with the page.

02:09.370 --> 02:17.020
Now there is one more important header called content language, which basically determines the language

02:17.020 --> 02:20.410
of the body for the intended audience.

02:20.800 --> 02:26.680
Please note that it is not saying that the language of the message body.

02:27.490 --> 02:31.390
It says language of the message body for the intended audience.

02:31.390 --> 02:32.590
So there is difference.

02:32.770 --> 02:38.140
So let's take a simple example where the content language header says N.

02:38.560 --> 02:41.770
So what this basically determines is that this.

02:42.890 --> 02:48.380
The body is specific for intended audience who understands English.

02:49.250 --> 02:56.170
So if I give you a day to day example, let's say a travel guide for China.

02:56.180 --> 03:01.610
So if a person is visiting a China, there is a travel website with a travel guide.

03:01.910 --> 03:08.360
Now the travel guide is intended for English audience or the people who understands English.

03:08.540 --> 03:17.720
However, the document also contains basic Chinese sentences that can help people in day to day communication

03:17.720 --> 03:19.370
in local languages.

03:20.550 --> 03:27.420
So during that time, the document contains both English as well as Chinese based characters.

03:28.660 --> 03:33.580
However, it is specifically for people who understands English.

03:33.580 --> 03:36.810
So during that time the content language becomes Ian.

03:37.240 --> 03:44.620
Although it has Chinese characters still, as it is specific for English based audience, the content

03:44.620 --> 03:45.930
language will be Ian.

03:49.240 --> 03:56.800
So as we're talking about the Multi-language website, let me show you an example of how it works along

03:56.800 --> 03:59.200
with the accept language headers.

03:59.830 --> 04:00.850
So.

04:04.480 --> 04:12.010
I have a server and if I do a call, let me show you curl followed by header.

04:12.850 --> 04:15.910
Say header that I want is accept language.

04:18.040 --> 04:23.260
Say my preferences in which is English followed by the name of the website.

04:23.260 --> 04:25.540
Say example.com slash hi dot HTML.

04:27.480 --> 04:29.070
And the contents are.

04:29.100 --> 04:31.530
This is English version of the website.

04:31.560 --> 04:33.780
So now let's modify the header.

04:34.520 --> 04:36.080
From N to J.

04:36.110 --> 04:38.150
So J stands for Japanese.

04:38.870 --> 04:42.380
And now you see, this is a Japanese version of the website.

04:42.500 --> 04:51.050
And this is one of the reasons why the Accept language header instructs the server on what type of language

04:51.050 --> 04:53.960
it would prefer in the response.

04:55.410 --> 05:05.100
Now, again, it is very important to know the exact language followed by N or J is specified in the

05:05.100 --> 05:05.880
browser.

05:05.880 --> 05:14.310
So by default, if you are downloading Chrome or Firefox in the European or maybe even in India, then

05:14.310 --> 05:16.650
by default the language is n.

05:16.830 --> 05:23.640
However, for other languages, other countries, the language might differ in the browsers.

05:23.640 --> 05:28.050
So this is something that you can always change depending upon your requirement.

05:28.890 --> 05:36.210
So this is it about the basics of except language and content language headers in the Http protocol.

05:36.480 --> 05:41.940
So I hope this video has been informative for you and I'd like to thank you for viewing.
