Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locale.getString sometimes give empty string in angular controller #115

Open
PRIYA-MAMGAIN opened this issue Aug 30, 2017 · 3 comments
Open

Comments

@PRIYA-MAMGAIN
Copy link

Hi
I am passing parameters to dataTable
oLanguage: {
"sLengthMenu": "MENU "+locale.getString('app.menu-dropdown'),
"sSearch": locale.getString('app.search'),
"sEmptyTable": locale.getString('app.emptyTable'),
"sZeroRecords": locale.getString('app.zeroRecord'),
"sInfoFiltered": locale.getString('app.filtereddevices', ['MAX'])+ ')',
"sInfo": locale.getString('app.showingdevices' ,['START','END','TOTAL']),
"sInfoEmpty": locale.getString('app.emptyRecord')
}

Most of the times i do not get the labels in my datatable and locale.getString() return blank. I tried accessing the strings when locale is ready, ie
locale.ready("app").then function(){
$scope.emptyTable=locale.getString('app.emptyTable')
}
when i access the $scope.emptyTable it still returns empty string.

@doshprompt
Copy link
Owner

Hi @PRIYA-MAMGAIN ... that is strange, could you provide a full example please?

@PRIYA-MAMGAIN
Copy link
Author

Allan most of the times it doesn't show up. If you see the locale.getString() method, it gets the bundle and check if the bundle is loading it returns empty string.

Html:

.....
JS:

$scope.myDataGrid={
rowId: 'rowIdentifier',
dataTableOptions: {

aoColumns:[
{
sType:'html',
bSortable:false,
bSearchable:false,
colTitle:'',
mData:'rowIdentifier',
mRender:function(data,type){
return ''
},
{
colTitle:locale.getString("app.devicename")
mData:'name'
}
...
..
"bDeferRender":true,
"aaSorting":[[2.'desc']],
"bSortCellsTop":true,
"aLengthMenu":[[10,25,50,100],[10,25,50,100]],
"iDisplayLength":10,

oLanguage: {
"sLengthMenu": "MENU "+locale.getString('app.menu-dropdown'),
"sSearch": locale.getString('app.search'),
"sEmptyTable": locale.getString('app.emptyTable'),
"sZeroRecords": locale.getString('app.zeroRecord'),
"sInfoFiltered": locale.getString('app.filtereddevices', ['MAX'])+ ')',
"sInfo": locale.getString('app.showingdevices' ,['START','END','TOTAL']),
"sInfoEmpty": locale.getString('app.emptyRecord')
}
]

}

If I put a check in my controller to do processing only when the locale is ready, then my dataTable is empty .

locale.ready("app").then(function(){
//Controller code inside
})

@doshprompt
Copy link
Owner

So it seems like you should be wrapping the entire $scope.myDataGrid assignment inside

locale.ready('app').then(function() {
  $scope.myDataGrid = { /* ... */ };
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants