1# Globalization Subsystem ChangeLog
2
3## cl.global.1 Support of Error Codes for the Internalization Module
4
5APIs provided by the internationalization component of the globalization subsystem are changed to support error codes in the following scenarios. The following changes are made in API version 9 and later:
6 - Obtaining the local expression of a country or language
7 - Obtaining the list of languages supported by the system and the list of areas supported by a language
8 - Checking whether a language matches an area
9 - Obtaining and setting the system language, country or region, and area
10 - Obtaining and setting the 24-hour format of the system
11 - Obtaining, adding, and removing the preferred language
12 - Obtaining and setting localized numbers
13
14You need to adapt your applications based on the following information:
15
16**Change Impacts**
17
18The preceding APIs are changed to the static methods of the **System** class. When such an API is called, add the class name to the end of the module name.
19The return value data type of the setting APIs (for example, **setSystemLanguage**) is changed from boolean to void.
20When a call to an API fails, an error code is returned according to the failure cause. For example, when permissions are not correctly configured for an application, **201** is returned.
21
22**Key API/Component Changes**
23
24Involved APIs:
25- getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string;
26- getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string;
27- getSystemLanguages(): Array<string>;
28- getSystemCountries(language: string): Array<string>;
29- isSuggested(language: string, region?: string): boolean;
30- getSystemLanguage(): string;
31- setSystemLanguage(language: string): void;
32- getSystemRegion(): string;
33- setSystemRegion(region: string): void;
34- getSystemLocale(): string;
35- setSystemLocale(locale: string): void;
36- is24HourClock(): boolean;
37- set24HourClock(option: boolean): void;
38- addPreferredLanguage(language: string, index?: number): void;
39- removePreferredLanguage(index: number): void;
40- getPreferredLanguageList(): Array<string>;
41- getFirstPreferredLanguage(): string;
42- getAppPreferredLanguage(): string;
43- setUsingLocalDigit(flag: boolean): void;
44- getUsingLocalDigit(): boolean;
45
46**Adaptation Guide**
47
48Use the **try-catch** block to capture errors returned by an API.
49```
50import I18n from '@ohos.i18n'
51
52try {
53  I18n.System.setSystemLanguage('zh');
54} catch(error) {
55  console.error(`call System.setSystemLanguage failed, error code: ${error.code}, message: ${error.message}.`)
56}
57```
58