Framework development - system default language modification

        The default language of the original Android system is English, but for Android product manufacturers in mainland China, our customized system may require users to speak Simplified Chinese as soon as they turn on the system. Therefore, factory setting the Android system to Simplified Chinese is very important for the commercialization of the Android system. We can achieve the role of the default language by modifying the system properties. This article is mainly verified on the Android 11 source code.

1. Language pack modification

        By looking for relevant modification solutions, most of them are modifying the language order of the Android language pack. The default language selection is implemented in build/core/Makefile. Select the first language from PRODUCT_LOCALES as the default language, as follows:

$(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
			……
			PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \
    		……

        Then write the following paragraph to the file build.prop through the build/tool/buildinfo.sh file, as follows:

if [ -n "$PRODUCT_DEFAULT_LOCALE" ] ; then
  echo "ro.product.locale=$PRODUCT_DEFAULT_LOCALE"
fi

1. Language pack sorting modification

        As you can see from the above code, the default language just takes out the first language of PRODUCT_LOCALES as the default language. So we only need to modify the language order in PRODUCT_LOCALES.

Common solutions

        Found via web search

Guess you like

Origin blog.csdn.net/c19344881x/article/details/132693513