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

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"
    }
},

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

GET http://localhost:3000/i18n/i18n_en_US.properties 404 (Not Found)

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

我的问题:

回答

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

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

"i18n": {
"bundleName": "webapp.i18n.i18n",
"fallbackLocale": "en",
"supportedLocales": [
"en"
]
},

以上是supportedLocales 和 fallbackLocale 的组合不会阻止 UI5 请求不存在的 i18n 本地化的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>