harmony 鸿蒙Globalization Subsystem ChangeLog
Globalization Subsystem ChangeLog
cl.global.1 Runtime Authentication Added for System APIs
The internationalization component of the globalization subsystem adds runtime authentication for system APIs in certain scenarios. The following changes are made in API version 9 and later: - Setting the system language, country or region, and area - Setting the 24-hour format of the system - Adding and removing the preferred language - Setting localized numbers
You need to adapt your application based on the following information.
Change Impacts
APIs involved in the preceding scenarios can be properly called only by system applications that have the UPDATE_CONFIGURATION permission.
Key API/Component Changes
- Involved APIs:
- setSystemLanguage(language: string): void;
- setSystemRegion(region: string): void;
- setSystemLocale(locale: string): void;
- set24HourClock(option: boolean): void;
- addPreferredLanguage(language: string, index?: number): void;
- removePreferredLanguage(index: number): void;
- setUsingLocalDigit(flag: boolean): void;
Adaptation Guide
Make sure the application trying to call any of the above APIs is a system application. Non-system applications are not allowed to call the APIs. An exception will be thrown upon lack of a necessary permission or a call request from a non-system application. The exception can be captured via try-catch.
import I18n from '@ohos.i18n'
try {
I18n.System.setSystemLanguage('zh');
} catch(error) {
console.error(`call System.setSystemLanguage failed, error code: ${error.code}, message: ${error.message}.`)
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Web Subsystem ChangeLog
harmony 鸿蒙Ability Subsystem ChangeLog
harmony 鸿蒙Bluetooth Subsystem ChangeLog
harmony 鸿蒙Distributed Data Management Subsystem JS API Changelog
harmony 鸿蒙File Management Subsystem ChangeLog
harmony 鸿蒙Media Subsystem ChangeLog
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦