最好用他们理解和喜欢的语言来沟通用户。 extjs本地化包支持超过40种语言,如德语,法语,韩语,中文等。
在extjs中实现区域设置非常简单。您将在ext-locale软件包的覆盖文件夹中找到所有捆绑的区域设置文件。 语言环境文件只是覆盖,它指示ext js替换某些组件的默认英语值。
这个程序是要显示不同区域设置的月份来看效果,试试下面的程序:
<!doctype html>
<html>
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" rel="stylesheet" />
<script type="text/javascript" src="/attachements/w3c/ext-all.js"></script>
<script type="text/javascript" src="/attachements/w3c/locale-fr.js"></script>
<script type="text/javascript">
ext.onready(function() {
var montharray = ext.array.map(ext.date.monthnames, function (e) { return [e]; });
var ds = ext.create('ext.data.store', {
fields: ['month'],
remotesort: true,
pagesize: 6,
proxy: {
type: 'memory',
enablepaging: true,
data: montharray,
reader: {type: 'array'}
}
});
ext.create('ext.grid.panel', {
renderto: 'grid',
id : 'gridid',
width: 600,
height: 200,
title:'month browser',
columns:[{
text: 'month of the year',
dataindex: 'month',
width: 300
}],
store: ds,
bbar: ext.create('ext.toolbar.paging', {
pagesize: 6,
store: ds,
displayinfo: true
})
});
ext.getcmp('gridid').getstore().load();
});
</script>
</head>
<body>
<div id="grid" />
</body>
</html>
这会产生以下结果:
描述:
对于使用不同的语言环境,除了英语,我们需要在我们的程序中添加区域设置特定的文件,我们使用https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/locale/locale-fr .js法语。 您可以对不同的语言使用不同的区域设置,例如https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/locale/locale-ko.js for korean等。
这个程序是显示日期选择器在韩国语区域查看效果,尝试以下程序:
<!doctype html>
<html>
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" rel="stylesheet" />
<script type="text/javascript" src="/attachements/w3c/ext-all.js"></script>
<script type="text/javascript" src="/attachements/w3c/locale-ko.js"></script>
<script type="text/javascript">
ext.onready(function() {
ext.create('ext.picker.date', {
renderto: 'datepicker'
});
});
</script>
</head>
<body>
<div id="datepicker" />
</body>
</html>
这会产生以下结果:
下面是extjs中可用的几个区域设置和要更改的主文件区域设置url。
| 语言环境 | 语言 | 区域设置url |
|---|---|---|
| ko | korean | https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/locale/locale-ko.js |
| fr | french | https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/locale/locale-fa.js |
| es | spanish | https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/locale/locale-es.js |
| ja | japanese | https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/locale/locale-ja.js |
| it | italian | https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/locale/locale-it.js |
| ru | russian | https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/locale/locale-ru.js |
| zh_cn | 简体中文 | https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/locale/locale-zh_cn.js |