Failed to Call configuration.setLocale() During Page Initialization

Mayism
Huawei Developers
Published in
1 min readNov 24, 2020

--

Symptom

The global method changeLocaleConfiguration is defined in the app.ux file of a quick app to set the app language. When the changeLocaleConfiguration() method is called and configuration.setLocale() in it is successfully triggered in the lifecycle method onInit of the home page, the app language does not change.

Code in app.ux:

Code of the home page:

Cause Analysis

Page initialization takes a short time, but language setting takes a long time. As a result, the page cannot be rendered in time.

Solution

Add a delay when calling the language setting API during page initialization. The code is as follows:

Suggestions and Summary

You are advised not to call time-consuming operations in onInit. If you must call the operations, add a delay.

--

--