ADROID 2.1 架构解析 语言定制

1 语言定制 1.1 ICU4C 1.1.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++两个平台下的国际化应用。 ICU4C和ICU4C区别不大,但由于ICU4C是开源的,并且紧密跟进Unicode标准,ICU4C支持的Unicode标准总是最新的;同时,因为JAVA平台的ICU4J的发布需要和JDK绑定,ICU4C支持Unicode标准改变的速度要比ICU4J快的多。 1.1.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. 1.2 定制语言 在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) 1.3 默认语言 默认语言的选择实现是在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" 所以,要改变默认语言用下面两种方法中的一种就行了: 1 在PRODUCT_LOCALES字段里,将要选择的语言放在第一位,如: PRODUCT_LOCALES := en_US zh_CN 默认语言是英语 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。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值