1
00:00:04,400 --> 00:00:05,400
Welcome back.

2
00:00:05,600 --> 00:00:09,040
In this video we'll test the reports in different locales

3
00:00:09,040 --> 00:00:11,340
to make sure the dates appear as we'd expect.

4
00:00:16,000 --> 00:00:20,300
When I run the app and view the reports, the dates are in American format;

5
00:00:20,300 --> 00:00:22,300
month, then day, then year.

6
00:00:22,800 --> 00:00:25,700
That's because the default locale for the emulators

7
00:00:25,700 --> 00:00:28,000
is US, the United States.

8
00:00:29,100 --> 00:00:32,970
I'm in Australia, so let's see what happens when I tell my phone

9
00:00:32,970 --> 00:00:34,170
the correct locale.

10
00:00:34,720 --> 00:00:37,720
Note that locale isn't the same as location.

11
00:00:38,520 --> 00:00:41,820
I happen to be in Australia and I'm also Australian.

12
00:00:42,480 --> 00:00:46,780
If I travel to America, I don't want all my date formats to change

13
00:00:46,780 --> 00:00:48,780
just because I've changed location.

14
00:00:49,440 --> 00:00:53,540
My locale is still Australia even when my location changes.

15
00:00:54,200 --> 00:00:57,700
The locale determines things like date and number formats

16
00:00:58,060 --> 00:01:00,460
and also the language that the phone will use.

17
00:01:00,860 --> 00:01:02,360
We'll see that in a moment.

18
00:01:03,060 --> 00:01:03,660
Okay.

19
00:01:04,160 --> 00:01:08,360
I'll keep the app running and use the home button to return to the home screen.

20
00:01:11,360 --> 00:01:12,660
Then we'll go into settings.

21
00:01:15,660 --> 00:01:19,020
You can change locale from settings. Normally

22
00:01:19,520 --> 00:01:21,880
under an option called languages,

23
00:01:23,080 --> 00:01:24,380
which is in system.

24
00:01:25,480 --> 00:01:27,380
On an android pie emulator,

25
00:01:27,930 --> 00:01:31,730
you go to languages and input and then languages.

26
00:01:32,730 --> 00:01:35,090
At the moment, there's only one language in there,

27
00:01:35,090 --> 00:01:37,290
the default of the United States.

28
00:01:37,950 --> 00:01:39,450
I'll add a new language,

29
00:01:40,890 --> 00:01:42,090
I'll choose English

30
00:01:47,390 --> 00:01:48,690
then Australia.

31
00:01:49,590 --> 00:01:52,250
The default language is still United States.

32
00:01:52,250 --> 00:01:54,950
The phone uses language 1 for its locale,

33
00:01:55,350 --> 00:01:58,350
and all we've done is make swapping languages easier.

34
00:01:59,230 --> 00:02:03,030
While the display is still in English, I'll add a couple of other languages.

35
00:02:03,730 --> 00:02:06,030
I want at least one European language,

36
00:02:06,390 --> 00:02:08,690
mainly because they use different number formats.

37
00:02:09,570 --> 00:02:12,470
Note that languages appear in their own language.

38
00:02:12,970 --> 00:02:16,970
If I want German, that's Deutsch which is German for German.

39
00:02:17,960 --> 00:02:22,320
From there, I'll choose Deutschland which is German for Germany.

40
00:02:31,920 --> 00:02:35,920
Okay. I'll add another. This time, I'll choose a language

41
00:02:35,920 --> 00:02:37,520
that uses a different character set.

42
00:02:38,320 --> 00:02:40,320
They sort at the end of the list.

43
00:02:44,570 --> 00:02:48,670
Scrolling right through the list the very last one is easy to find.

44
00:02:49,170 --> 00:02:50,670
That has a few variants,

45
00:02:52,370 --> 00:02:56,370
so I'll choose the first one and add it to the list of languages.

46
00:02:58,730 --> 00:03:02,530
To make a different language the default, drag it to position one.

47
00:03:02,970 --> 00:03:06,670
I'll start by dragging English Australia to the top of the list.

48
00:03:08,330 --> 00:03:10,630
Before I go back to the task timer app,

49
00:03:11,180 --> 00:03:14,780
I'll make sure the logcat is visible and I'll also clear it.

50
00:03:19,780 --> 00:03:24,380
I'll use the multitasking button to get back to our app. It's still running, remember?

51
00:03:27,680 --> 00:03:29,040
We just switched away from it.

52
00:03:29,700 --> 00:03:31,900
The display is updated automatically.

53
00:03:31,900 --> 00:03:35,400
Changing the language counts as a configuration change

54
00:03:35,400 --> 00:03:38,700
and the activity gets destroyed and recreated.

55
00:03:39,000 --> 00:03:41,300
We can see that happening in the logcat.

56
00:03:44,900 --> 00:03:46,260
All right. That looks good

57
00:03:46,810 --> 00:03:50,010
we've now got the date in day, month and year format.

58
00:03:50,910 --> 00:03:55,210
Again, I'll use the multitasking button to switch back to the settings.

59
00:03:55,910 --> 00:03:58,570
We're still at the language preferences screen,

60
00:03:58,570 --> 00:04:01,170
which is why I'm swapping back and forth this way.

61
00:04:01,830 --> 00:04:05,330
When I change the language to using a completely different character set,

62
00:04:05,690 --> 00:04:07,690
I don't have to worry about getting back here.

63
00:04:08,490 --> 00:04:10,990
All right. I'll drag Deutsch to the top of the list

64
00:04:10,990 --> 00:04:12,990
and switch back to the tasktimer app.

65
00:04:18,290 --> 00:04:21,950
We've now got two digits for the days and the month

66
00:04:21,950 --> 00:04:24,150
and a period used as a separator.

67
00:04:25,030 --> 00:04:27,230
Because we took a bit of extra care

68
00:04:27,630 --> 00:04:30,630
and specified the default locale in our code,

69
00:04:30,630 --> 00:04:33,130
the app looks right in different languages.

70
00:04:34,030 --> 00:04:38,020
All right. I've left the one that uses a different character set till last.

71
00:04:38,720 --> 00:04:41,220
It uses a completely different character set.

72
00:04:41,580 --> 00:04:44,880
And if I get lost trying to change the emulator back to English,

73
00:04:44,880 --> 00:04:47,380
I can just delete the emulator and start again.

74
00:04:48,180 --> 00:04:52,300
If you're using a real phone and don't understand the language,

75
00:04:52,500 --> 00:04:54,700
then be really careful with this next step.

76
00:04:56,100 --> 00:05:00,400
Switch back to settings, and drag number 4 to the top of the list.

77
00:05:00,900 --> 00:05:03,300
Notice how the language preferences heading

78
00:05:03,300 --> 00:05:05,660
is now written using a different character set.

79
00:05:06,760 --> 00:05:11,120
If you close settings at this point, you could struggle to get back here.

80
00:05:11,370 --> 00:05:14,470
This applies to any language that you don't understand,

81
00:05:15,130 --> 00:05:19,530
although ones that use an unfamiliar character set are even harder to navigate.

82
00:05:20,530 --> 00:05:24,530
For that reason, make sure you don't go back from this screen.

83
00:05:25,030 --> 00:05:27,230
I'm in language preferences,

84
00:05:27,230 --> 00:05:31,030
and I'm not going to use the up or back buttons to move back in settings.

85
00:05:31,690 --> 00:05:35,190
If I did do so, getting back here is going to be tricky.

86
00:05:35,740 --> 00:05:38,740
Use the multitasking button to switch to the tasktimer.

87
00:05:40,740 --> 00:05:44,240
The date format is now year, month, day.

88
00:05:44,840 --> 00:05:48,340
That's quite sensible. Dates look much better that way when they're sorted.

89
00:05:49,140 --> 00:05:52,740
We haven't provided translations in whatever language that is,

90
00:05:53,140 --> 00:05:57,500
but at least we're displaying the dates in a format that the user will be used to.

91
00:05:58,490 --> 00:06:02,190
Remember to change your emulator back to a language that you can read

92
00:06:02,190 --> 00:06:03,990
before moving to the next video.

93
00:06:04,790 --> 00:06:08,450
I'm going to add English UK and make that the default

94
00:06:08,450 --> 00:06:10,450
by dragging it to the top of the list.

95
00:06:14,250 --> 00:06:17,850
There's a reason I've chosen English United Kingdom.

96
00:06:19,050 --> 00:06:22,350
The English part is obvious. It's a language I understand.

97
00:06:22,850 --> 00:06:27,050
The reason I've gone for UK is because that format states differently

98
00:06:27,050 --> 00:06:28,550
to the Australian locale.

99
00:06:47,850 --> 00:06:49,150
In the next video,

100
00:06:49,750 --> 00:06:52,650
we'll start to create the ViewModel for our reports.

