背景:
- 在使用zipkin-server的UI的时候,发现页面上会报错从404问题:
原因:
- 这是因为使用了i18n的国际化语言加载能力,参见:
https://www.ibm.com/developerworks/cn/web/1305_hezj_jqueryi18n/
其使用了jQuery.i18n.properties 插件,动态的根据浏览器的语言去加载相应的语言。
比如,浏览器是中文,它会去查找nav.properties、nav_zh.properties、nav_zh_CN.properties三个,其中,匹配顺序为:nav_zh>nav_zh_CN>nav,先匹配上后语言会应用,因此会出现404
* zipkin中的代码位置为:i18n.js
export function i18nInit(file) {
// https://github.com/jquery-i18n-properties/jquery-i18n-properties
$.i18n.properties({
name: file,
path: contextRoot,
mode: 'map',
// do not append a unix timestamp when requesting the language (.properties) files
// this allows them to be cached by the browser
cache: true,
// do not perform blocking XHR requests, as it blocks the entire browser, including
// rendering
async: true,
callback: () => {
$('[data-i18n]').each((index, item) => {
if (item.tagName === 'INPUT' || item.tagName === 'SELECT') {
$(item).attr('placeholder', $.i18n.prop($(item).attr('data-i18n')));
} else {
$(item).html($.i18n.prop($(item).attr('data-i18n')));
}
});
}
});
}