怎麼樣修改android中語言

來源:互聯網
上載者:User

 

          查了很多的網頁,上面都只有寫要修改PRODUCT_LOCALES欄位.

          但.MK檔案太多的,我找了很久都沒有找到這個欄位在哪裡定義的.

          最後發現的結果:

          ./device/rockchip/sdkdemo/boardconfig.mk中.

          這個檔案夾在標準的android代碼中屬於定製檔案目錄,可以在相應的項目中找到對應的檔案夾.修改此項.

 

          修改的方法是將預設的國家放在此欄位的第一個位置.一般預設的是英語.

          例如韓國:PRODUCT_LOCALES := ko_KR en_US zh_CN

 

另附轉文一篇:

這個講得詳細一些,還包含另一種修改方法,可參考.

轉自:

http://www.ziyouku.com/archives/android-custom-system-language-to-simplified-chinese.html

 

Android系統原版預設的語言為英文,而我們定製系統可能需要使用者一開機就是簡體中文。
我們可以通過修改系統屬性來達到預設語言的作用。
這裡有兩種方法,需要的可以借鑒下:
1、在init.rc或者在其他的開機初始設定檔案如:default.prop中加入如下設定系統屬性的代碼:
[persist.sys.language]: [zh]
[persist.sys.country]: [CN]
[persist.sys.localevar]: []
[persist.sys.timezone]: [Asia/Shanghai]
[ro.product.locale.language]: [zh]
[ro.product.locale.region]: [CN]

2、編譯的時候,通過指明編譯參數為簡體中文,這樣編譯傳統就會編譯出來的系統屬性檔案,在
系統初始化的時候將會把上面的屬性給進行正確的初始化,例如:
make PRODUCT-machineID-eng-zh_CN

其他相關資料:
1、ICU4C簡介
ICU4C(ICU for C, http://site.icu-project.org/ ) 是ICU在C/C++平台下的版本, ICU(International Component for Unicode)是基於"IBM公用許可證"的,與開源組織合作研究的, 用於支援軟體國際化的開源項目。ICU4C提供了C/C++平台強大的國際化開發能力,軟體開發人員幾乎可以使用ICU4C解決任何國際化的問題,根據各地 的風俗和語言習慣,實現對數字、貨幣、時間、日期、和訊息的格式化、解析,對字串進行大小寫轉換、整理、搜尋和排序等功能,必須一提的是,ICU4C提
供了強大的BIDI演算法,對阿拉伯語等BIDI語言提供了完善的支援。

ICU首先是由Taligent公司開發的,Taligent公司現在被合并為IBM?公司全球化認證中心的Unicode研究組,然後ICU由IBM和 開源組織合作繼續開發,開源組織給與了ICU極大的協助。
開始ICU只有Java平台的版本,後來這個平台下的ICU類被吸納入SUN公司開發的JDK1.1,並在JDK以後的版本中不斷改進。C++和C平台下 的ICU是由JAVA平台下的ICU移植過來的,移植過的版本被稱為ICU4C,來支援這C/C++兩個平台下的國際化應用。 ICU4J和ICU4C區別不大,但由於ICU4C是開源的,並且緊密跟進Unicode標準,ICU4C支援的Unicode標準總是最新的;同時,因 為JAVA平台的ICU4J的發布需要和JDK綁定,ICU4C支援Unicode標準改變的速度要比ICU4J快的多。

2、 ANDROID語言套件
Android 使用的語言套件就是ICU4C,位置:external/icu4c。Android支援的語言有: Locale CANADA
Locale constant for en_CA.
Locale CANADA_FRENCH
Locale constant for fr_CA.
Locale CHINA
Locale constant for zh_CN.
Locale CHINESE
Locale constant for zh.
Locale ENGLISH
Locale constant for en.
Locale FRANCE
Locale constant for fr_FR.
Locale FRENCH
Locale constant for fr.
Locale GERMAN
Locale constant for de.
Locale GERMANY
Locale constant for de_DE.
Locale ITALIAN
Locale constant for it.
Locale ITALY
Locale constant for it_IT.
Locale JAPAN
Locale constant for ja_JP.
Locale JAPANESE
Locale constant for ja.
Locale KOREA
Locale constant for ko_KR.
Locale KOREAN
Locale constant for ko.
Locale PRC
Locale constant for zh_CN.
Locale SIMPLIFIED_CHINESE
Locale constant for zh_CN.
Locale TAIWAN
Locale constant for zh_TW.
Locale TRADITIONAL_CHINESE
Locale constant for zh_TW.
Locale UK
Locale constant for en_GB.
Locale US
Locale constant for en_US.

3、定製語言
定製語言在PRODUCT_LOCALES欄位裡添加需要語言,如: PRODUCT_LOCALES := en_US zh_CN,則系統裡只有英語和漢語兩種語言。然後語言的選擇處理是在external/icu4c/stubdata/Android.mk裡進行的, 如下:
config := $(word 1, \ $(if $(findstring ar,$(PRODUCT_LOCALES)),large) \
$(if $(findstring da,$(PRODUCT_LOCALES)),large) \
$(if $(findstring el,$(PRODUCT_LOCALES)),large) \
$(if $(findstring fi,$(PRODUCT_LOCALES)),large) \
$(if $(findstring he,$(PRODUCT_LOCALES)),large) \
$(if $(findstring hr,$(PRODUCT_LOCALES)),large) \
$(if $(findstring hu,$(PRODUCT_LOCALES)),large) \
$(if $(findstring id,$(PRODUCT_LOCALES)),large) \
$(if $(findstring ko,$(PRODUCT_LOCALES)),large) \
$(if $(findstring nb,$(PRODUCT_LOCALES)),large) \
$(if $(findstring pt,$(PRODUCT_LOCALES)),large) \
$(if $(findstring ro,$(PRODUCT_LOCALES)),large) \
$(if $(findstring ru,$(PRODUCT_LOCALES)),large) \
$(if $(findstring sk,$(PRODUCT_LOCALES)),large) \
$(if $(findstring sr,$(PRODUCT_LOCALES)),large) \
$(if $(findstring sv,$(PRODUCT_LOCALES)),large) \
$(if $(findstring th,$(PRODUCT_LOCALES)),large) \
$(if $(findstring tr,$(PRODUCT_LOCALES)),large) \
$(if $(findstring uk,$(PRODUCT_LOCALES)),large) \
$(if $(findstring zh,$(PRODUCT_LOCALES)),large) \
$(if $(findstring ja,$(PRODUCT_LOCALES)),us-japan) \
$(if $(findstring it,$(PRODUCT_LOCALES)),us-euro) \
$(if $(findstring pl,$(PRODUCT_LOCALES)),us-euro) \
$(if $(findstring cs,$(PRODUCT_LOCALES)),default) \
$(if $(findstring de,$(PRODUCT_LOCALES)),default) \
$(if $(findstring fr,$(PRODUCT_LOCALES)),default) \
$(if $(findstring nl,$(PRODUCT_LOCALES)),default) \
us)

4、預設語言
預設語言的選擇實現是在build/core/Makefile裡,從PRODUCT_LOCALES裡選擇第一個語言作為預設語言,如下:
define default-locale $(subst _, , $(firstword $(1)))
endef
# Selects the first locale in the list given as the argument
# and returns the language (or the region)
define default-locale-language $(word 2, 2, $(call default-locale, $(1)))
endef
define default-locale-region $(word 3, 3, $(call default-locale, $(1)))
Endef ... PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))"
然後通過build/tool/buildinfo.sh檔案將如下段寫到檔案build.prop,如下:
echo "ro.product.locale.language=$PRODUCT_DEFAULT_LANGUAGE"
echo "ro.product.locale.region=$PRODUCT_DEFAULT_REGION" 。

因此,要改變預設語言用下面兩種方法中的一種就行了:
4.1、在PRODUCT_LOCALES欄位裡,將要選擇的語言放在第一位,如: PRODUCT_LOCALES := en_US zh_CN 預設語言是英語;
4.2、在persist.sys.language 和persist.sys.country 裡指定語言,如下: PRODUCT_PROPERTY_OVERRIDES := \
persist.sys.language=zh \
persist.sys.country=CN build.prop檔案的處理是在system/core/init/property_service.c

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.