2016-11-03 126 views
1

如何根据用户选择的语言在Ag-grid 中翻译“No Rows To Show”消息?如何在ag-grid中翻译“No Rows To Show”消息?

我厌倦了这样的事情。

gridOptions: GridOptions = <GridOptions> { 
     rowSelection: 'single', 
     enableColResize: true, 
     enableSorting: true, 
     enableFilter: true, 
     suppressCellSelection: true, 

     overlayNoRowsTemplate: '<span style="padding: 10px; border: 2px solid #444; background: lightgoldenrodyellow;">'+.......+'</span>' 
    }; 

我需要添加一些东西在那个地方。

回答

2

按照internationalization section你应该能够只指定该数值到gridOptions像这样:

gridOptions: GridOptions = <GridOptions> { 
     rowSelection: 'single', 
     enableColResize: true, 
     enableSorting: true, 
     enableFilter: true, 
     suppressCellSelection: true, 

     localeText: {noRowsToShow: 'No hay nada'} 
    }; 

也就是说一般如何处理为AG-电网国际化。

更具体地说,你问到如何根据用户选择的语言来控制这个行为,你将不得不做更多的这样的事情(我假设你已经设置了一些变量来保存选定的语言):

function internationalization(){ 
    return selectedLanguageVariable === 'es'/*or whatever code you use for spanish*/ ? {noRowsToShow: 'No hay nada'} : {noRowsToShow: 'No Rows'} 
} 

gridOptions: GridOptions = <GridOptions> { 
    rowSelection: 'single', 
    enableColResize: true, 
    enableSorting: true, 
    enableFilter: true, 
    suppressCellSelection: true, 

    localeText: internationalization() 
};