1
00:00:03,730 --> 00:00:09,520
Hello, everyone, and welcome back in this lesson, we're going to talk about how the angular eating

2
00:00:09,520 --> 00:00:13,450
and system supports the case of plural sentences.

3
00:00:13,660 --> 00:00:14,680
Let's give an example.

4
00:00:14,680 --> 00:00:20,710
Let's say that we would like to add here a sentence beneath the added button that would say something

5
00:00:20,710 --> 00:00:21,520
like this.

6
00:00:21,550 --> 00:00:28,480
We would like to write here in case there are zero courses in our platform that no courses are available.

7
00:00:28,630 --> 00:00:34,260
On the other hand, if there is only one course available, we would like to write the following sentence.

8
00:00:34,270 --> 00:00:41,140
One course is available and if there are several courses available, one or more we would like to write

9
00:00:41,140 --> 00:00:44,920
a total of, let's say ten courses are available.

10
00:00:45,070 --> 00:00:50,470
So depending on the total count of courses, that is getting to our component.

11
00:00:50,680 --> 00:00:54,070
We would like to modify the content of this sentence.

12
00:00:54,380 --> 00:00:59,410
We would like also to send all the alternative sentences to the translator.

13
00:00:59,470 --> 00:01:04,720
Let's then see how angular internationalization is going to support this use case.

14
00:01:04,870 --> 00:01:09,700
The first thing that we are going to do is we are going to head over here to our application component

15
00:01:09,700 --> 00:01:13,750
and we are going to arrive here courses total member variable.

16
00:01:13,960 --> 00:01:19,300
This is going to be a number that is going to correspond to the total number of courses available in

17
00:01:19,300 --> 00:01:20,620
the course array.

18
00:01:20,890 --> 00:01:25,980
Now that we have this very well-defined, let's see how could we write this expression?

19
00:01:26,020 --> 00:01:31,540
So the first thing that we are going to do is we are going to apply here the Aetate an attribute, as

20
00:01:31,540 --> 00:01:32,050
usual.

21
00:01:32,170 --> 00:01:36,150
Now, the syntax that we are going to be using here is going to be slightly different.

22
00:01:36,310 --> 00:01:39,510
So we are going to add here a pair of curly braces.

23
00:01:39,580 --> 00:01:44,580
Next, we are going to add here the variable containing the is total.

24
00:01:44,710 --> 00:01:50,950
After that, we need to add here some indication that we are able to provide multiple forms of the plural

25
00:01:50,950 --> 00:01:51,910
of a sentence.

26
00:01:51,920 --> 00:01:55,000
So we are going to adhere here, the plural keywords.

27
00:01:55,120 --> 00:02:00,440
Next, we are going to start providing here the multiple alternatives that we have covered before.

28
00:02:00,550 --> 00:02:07,830
So in case the courses total member variable is zero, we are going to be writing no courses available.

29
00:02:07,900 --> 00:02:12,310
So in order to identify that case, we are going to add here equals zero.

30
00:02:12,460 --> 00:02:18,580
And after this indicator that this should only be shown if this value here is zero, we're going to

31
00:02:18,580 --> 00:02:25,360
have here an extra pair of curly braces and we're going to have inside with the text that corresponds

32
00:02:25,360 --> 00:02:25,970
to this case.

33
00:02:25,990 --> 00:02:29,170
So in this case, no courses available.

34
00:02:29,410 --> 00:02:34,270
Next, we are going to handle the case when only one course is currently available.

35
00:02:34,360 --> 00:02:37,300
So we are going to identify that case with equals one.

36
00:02:37,300 --> 00:02:43,090
And inside here, an extra pair of curly braces we are going to have here the sentence.

37
00:02:43,090 --> 00:02:45,340
One course is available.

38
00:02:45,700 --> 00:02:52,540
Now we want to handle the last case, which will happen whenever there are multiple courses available.

39
00:02:52,550 --> 00:02:58,150
So more than one in that case, we are going to write here the other identifier.

40
00:02:58,150 --> 00:03:02,050
And inside here, one final pair of curly braces.

41
00:03:02,260 --> 00:03:08,680
We're going to write the following sentence, a total of and let's say in courses are available.

42
00:03:08,680 --> 00:03:15,040
We are going to have to write the value to this N placeholder that we have put here, because this would

43
00:03:15,040 --> 00:03:16,950
be printed out as a normal string.

44
00:03:16,990 --> 00:03:23,020
So if we want to print out here an expression here available at the level of our template, we can do

45
00:03:23,020 --> 00:03:27,760
so by using the normal angular, double curly brace expression.

46
00:03:27,760 --> 00:03:32,550
And here we can perceive the value of the courses total member variable.

47
00:03:32,740 --> 00:03:37,710
Let's see this expression in action to make sure that everything is working correctly.

48
00:03:37,720 --> 00:03:44,230
So in this case, this expression is going to also be interpreted by the angular runtime and we're going

49
00:03:44,230 --> 00:03:49,750
to see on the screen these multiple messages depending on the value of this variable.

50
00:03:50,000 --> 00:03:56,110
Now that we have our server up and running, let's refresh here our application and have a look here

51
00:03:56,110 --> 00:04:01,600
at the message that we get so we can see we get a total of ten courses are available.

52
00:04:01,720 --> 00:04:03,670
But now take a look at the following.

53
00:04:03,670 --> 00:04:09,730
If we head over here to our DV data file, which contains here our list of courses, let's say that

54
00:04:09,730 --> 00:04:15,690
we would remove all of these courses here from the list so we would have zero courses.

55
00:04:15,730 --> 00:04:17,769
Let's remove this value.

56
00:04:17,920 --> 00:04:22,180
Let's hit command s and we are going to reload with our application.

57
00:04:22,300 --> 00:04:28,180
So as we can see this time around, we have the sentence, no courses available as expected.

58
00:04:28,180 --> 00:04:30,490
So that corresponds here to this case.

59
00:04:30,490 --> 00:04:38,410
And if we switch over here to the courses array and this time around we delete everything except the

60
00:04:38,410 --> 00:04:43,600
first element of the list and we reload our application, we are going to get the sentence.

61
00:04:43,750 --> 00:04:45,910
One course is available.

62
00:04:46,030 --> 00:04:48,850
So everything is working as expected.

63
00:04:49,060 --> 00:04:51,580
Now, let's head over here to the terminal.

64
00:04:51,580 --> 00:04:54,790
Let's add here all our courses back as well.

65
00:04:54,790 --> 00:05:00,130
And let's see how this expression is going to get extracted here to the messages file.

66
00:05:00,130 --> 00:05:00,440
What are we?

67
00:05:00,540 --> 00:05:06,280
Stop the angular clay and we are going to run again, our internationalization extractor.

68
00:05:06,450 --> 00:05:10,130
Let's now have a look at the content of our messages file.

69
00:05:10,140 --> 00:05:13,650
So as we can see, we got here a new translation unit.

70
00:05:13,680 --> 00:05:16,330
We have here a source tagged just like before.

71
00:05:16,350 --> 00:05:20,510
And here we have the complete content of our expression.

72
00:05:20,700 --> 00:05:27,300
We can see that we also have here some indication this is going to be replaced by a variable names causes

73
00:05:27,300 --> 00:05:27,830
total.

74
00:05:27,990 --> 00:05:34,260
So the translator is going to understand the context onto which this message is getting applied.

75
00:05:34,470 --> 00:05:39,010
As we can see, angular internationalization support is very powerful.

76
00:05:39,390 --> 00:05:40,870
Let's dive deeper into it.

77
00:05:40,880 --> 00:05:43,710
Let's talk about alternative expressions.

