Reputation: 41
When i set headerName or displayName with "$filter('translate')('HostName')", like following
export default (($filter, modalHelper, $translate) => [{
displayName:$filter('translate')('HostName'),
headerCellFilter: 'translate',
headerFilter:'translate',
field: 'name',
width: 130,
filter: 'text'}]
const en = {
'HEADLINE': 'This is a test',
'HostName': 'This is Host Name',
'IPAddress': 'IP Address'}
export default {
en
}
const cn = {
'HEADLINE': '这是一个测试',
'HostName': '主机名',
'IPAddress': 'IP 地址'
}
export default {
cn
}
headerName just can show once,can not dynamic change, when i run changeLanguage function, like bellow
function changeLanguage() {
$translate.use($scope.lang)
})
}
$scope.langs = ['English', '中文(简体)'];
$scope.lang = '中文(简体)';
$translateProvider.translations('English', translateEN.en)
.translations('中文(简体)', translateCN.cn)
.preferredLanguage('中文(简体)') // 默认 EN
If there have any solution to fix it? Thank you.
Upvotes: 4
Views: 3158
Reputation: 5113
Seems that it could be done with headerValueGetter
Use
headerValueGetter
instead ofcolDef.headerName
to allow dynamic header names.
inside headerValueGetter
function you can handle translations
Upvotes: 1
Reputation: 228202
You probably have to change the headerName
manually.
There's a function named refreshHeader()
, here's an example from the docs.
Or, you can reload your entire columns definitions with setColumnDefs()
, if it's easier.
Upvotes: 0