I have implemented Angular Datatable and Angular Translate in my latest project.
In the datatable, I have customized the pagination & info section as shown below:
var language = {
"sEmptyTable": "<div class='alert alert-primary text-center m-auto w-25'>" + $filter('translate')('TABLE.S_EMPTY_TABLE') + "</div>",
...
};
The datatable's options are set like this:
$rootScope.dtOptions = DTOptionsBuilder.fromSource()
.withLanguage(language)
...
});
app.config
$translateProvider.useStaticFilesLoader({
prefix: 'app/resources/lang-',
suffix: '.json'
});
$translateProvider.preferredLanguage('en');
$translateProvider.useSanitizeValueStrategy('sanitize');
$translateProvider.useLocalStorage();
lang-en.json
...
{
"TABLE": {
"S_PROCESSING": "peoesing...",
...
}
...
Currently, I am trying to integrate Angular translate into the custom pagination and info section (refer to var language= {}
).
I have utilized
$filter('translate')('GLOBAL.LOADING')
And $translate.instant('TABLE.S_PROCESSING')
However, both of them are not functioning correctly, and instead of the translation, they display the string of each translate variable such as: GLOBAL.LOADING
or TABLE.S_PROCESSING
.
Where could the issue lie?