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 指代操作系統的語言。
用戶語言設置。在 IE 里指代 Region Settings里設置的語言。
注:Jerry 本地測試過,window.navigator.browserLanguage 和 window.navigator.userLanguage 都為空。
瀏覽器語言設置:window.navigator.language,在我的機器上為:en-US
采用 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 UI5 运行时语言判定机制的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: XShell SOCK5代理 跳转机的设
- 下一篇: 乔布斯签名支票、NeXT 名片等藏品公开