supportedLocales 和 fallbackLocale 的组合不会阻止 UI5 请求不存在的 i18n 本地化

Mik*_* B. 1 sapui5

i18n在 UI5 中配置功能,我在 manifest.json 中使用以下代码段sap.ui5

"models": {
    "i18n": {
        "preload": true,
        "settings": {
            "bundleName": "webapp.i18n.i18n",
            "bundleUrl": "i18n/i18n.properties",
            "fallbackLocale": "en",
            "supportedLocales": [
                "en"
            ]
        },
        "type": "sap.ui.model.resource.ResourceModel"
    }
},
Run Code Online (Sandbox Code Playgroud)

感谢supportedLocales并且fallbackLocale我不希望 UI5 会请求不存在的本地化,但实际上我仍然观察到不需要的 404 请求i18n_en_US.properties

GET http://localhost:3000/i18n/i18n_en_US.properties 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)

我认为supportedLocales和背后的整个想法fallbackLocale是减少本地化请求的数量,这些请求不存在且未在supportedLocales.

我的问题:

  • 为什么 UI5 无论如何尝试请求,i18n_en_US.properties尽管en_US没有出现在supportedLocales?

  • 是否可以摆脱对不受支持的语言环境的额外请求?

Mik*_* B. 5

我找出了不需要的 404 请求的原因。最初,我已经定义fallbackLocalesupportedLocalessap.ui5/models/i18n部分,但也有一i18nsap.app,这也需要fallbackLocalesupportedLocales配置。

最终的解决方案是将以下代码片段添加到sap.appmanifest.json 的部分:

"i18n": {
    "bundleName": "webapp.i18n.i18n",
    "fallbackLocale": "en",
    "supportedLocales": [
        "en"
    ]
},
Run Code Online (Sandbox Code Playgroud)