SAP UI5 标准应用的多语言支持 - SAP UI5 运行时语言判定机制
SAP UI5 对多语言的支持特性如下:
The language codes according to the de facto standard BCP-47, which are used by most browsers for language identification. As of JDK 1.7 they are also supported by the Java locale class.
目前大多数浏览器都支持了事实上的标准,BCP-47 里定义的 language code,用来做语言识别。例子:de, en-US, zh-Hans-CN
The Java Locale syntax that combines a lower case ISO 639 alpha-2 or alpha-3 language code with an ISO 3166 alpha-2 country code. Both codes are combined with an underscore. An arbitrary sequence of variant identifiers (also separated by underscores) can be appended as a third component.
另一方法,Java Locale 语法,使用 underscore,即下划线,来连接 ISO 639 alpha-2 (或者alpha-3)以及 ISO 3166 alpha-2 (或者alpha-3), 前者指代 language code,后者指代 country code. 同时,这两部分之后,可以再通过下划线,连接额外的 variant identifier.
例子:de, en_US, zh_TW_Traditional
The SAP proprietary language codes - SAP 专有语言代码
SAPUI5 applications are often used to connect to ABAP-based SAP application servers. These servers use SAP proprietary language codes for compatibility reasons.
SAP UI5 应用可以用来消费 SAP ABAP 服务器上暴露出来的 OData 服务,这些服务器出于兼容性原因,使用 SAP 专有的 language code.
These language codes often match an ISO 639 alpha-2 language code, but not in all cases.
SAP 专有 Language code 通常都和 ISO 639 alpha-2 里定义的 Language code 一一对应,但并不总是如此。
If the language code for a SAPUI5 application is specified with the traditional URL parameter sap-language, SAPUI5 assumes that it is a SAP proprietary language code and converts it to a BCP-47 language tag.
注意,如果用户在 SAP UI5 URL 参数,即 sap-language 里传入一个 code,SAP UI5 会默认将其视为一个 SAP 专有 Language code,并试图将其转换成 BCP-47 对应的 code.
转换规则如下:
SAP UI5 运行时语言判定机制
SAPUI5 has the notion of a current language. It is determined from the following sources of information. The sources are ordered increasingly by priority and the last available user language/locale wins.
SAP UI5 引入了“当前语言”,即运行时语言的概念。SAP UI5 加载的所有国际化文本资源(i18n resouces),都基于该当前语言加载。SAP UI5 运行时语言,使用下列逻辑来决定。下列规则按照优先级从低到高的顺序罗列出来,即越后面的规则,优先级越高。
-
Hard-coded UI5 default locale (‘en’) - 硬编码的默认 locale
-
Potentially configured browser language (window.navigator.browserLanguage); for Internet Explorer this is the language of the Operating System.
浏览器里设置的语言。如果是IE,window.navigator.browserLanguage 指代操作系统的语言。
- Potentially configured user language (window.navigator.userLanguage); for Internet Explorer this is the language in the Region settings.
用户语言设置。在 IE 里指代 Region Settings里设置的语言。
注:Jerry 本地测试过,window.navigator.browserLanguage 和 window.navigator.userLanguage 都为空。
- General language information from the browser
浏览器语言设置:window.navigator.language,在我的机器上为:en-US
- 使用 SAP UI5 configuration API 设置语言:sap.ui.getCore().getConfiguration().setLanguage()
- Locale configured via URL parameters
采用 url 参数 sap-language=ZH 设置的语言,具有最高的优先级。如下例子所示:
https://gm4:44355/sap/bc/ui5_ui5/ui2/ushell/shells/abap/FioriLaunchpad.html?sap-language=ZH&sap-client=001#Opportunity-manageOpportunity&/detail/Opportunities(guid’FA163EE5-6C3A-1ED7-B883-0ED9A99A201F’)
SAP UI5 自动加载 i18n_zh_CN.properties 文件:
加载该 .properties 文件,使用的Content-Type为: application/octet-stream; charset=UTF-8
最后加载的 Fiori Launchpad html 里定义的content 为:text/html; charset=UTF-8
更多Jerry的原创文章,尽在:“汪子熙”:
相关文章
- SAP UI5 应用中的 sap.ui.require 使用场景
- SAP UI5 ManagedObject 的 Event 讲解
- SAP Commerce Cloud 里的 User 模型和 Restriction 的关系
- SAP UI5 sap.ui.export.Spreadsheet API 介绍
- SAP UI5 sap.ui.Device.media.RANGESETS 的使用介绍
- SAP UI5 sap.ui.Device.media 的使用介绍
- SAP UI5 sap.ui.Device.media.initRangeSet 方法的单步调试
- SAP UI5 应用的标准 Theme 和自定义 Theme 的加载讨论
- SAP UI5 sap.m.Table Manual Pop-In Mode 概述
- 澄清一些对 SAP UI5 响应式表格 sap.m.Table 的常见理解误区试读版
- 如何找出 SAP Fiori Launchpad 里点击 tile 之后,读取业务数据调用的是哪个 SAP 后台系统的 OData 服务试读版
- SAP ABAP Gateway 系统里 HTTP 请求响应头部字段 DataServiceVersion 的可能取值范围
- 如何自行查找出 SAP ABAP 标准的 OData 服务返回数据的后台数据库表和表字段名称试读版
- SAP 业务T-CODE详解编程语言
- 访问SAP的Domain的Value Range详解编程语言
- SAP Basis常用事务代码详解编程语言
- Sap SE16n 修改表数据详解编程语言
- SAP语音读汉字详解编程语言
- SAP ABAP 输出Excel文件实例—-现金流量表输出—-(备忘)详解编程语言
- SAP《MM学习指南》操作记录—-仓库盘点详解编程语言
- SAP在Linux系统的安装与使用(sap安装linux)
- 让企业受益匪浅:应用Linux环境下SAP HANA(linuxhana)
- 对比SAP VS Oracle: 哪个更适合你?(sap与oracle)
- Oracle与SAP在仓储领域的联姻(仓库oracle和sap)
- 深度比较:SAP vs Oracle(sap与oracle比较)
- 数据库解决方案如何使用SAP创建Redis数据库(sap怎么创建redis)
- Oracle和SAP技术比较优势和劣势(oracle与sap比照)
- Oracle SAP系统深入探索管理系统之魅力(oracle sap系统)
- Oracle与SAP的技术潜力比较(oracle sap比较)