I'm currently working on an AngularJS app and need to implement i18n. Everything is running smoothly except for error handling, specifically with utilizing translations in controller for popups.
Here is a snippet of my controller:
function showErrorPopup($ionicPopup, $ionicHistory, $location, $translate, error) {
if (error.status == 404) {
errorId = ...
$ionicPopup.show({
title: '{{ERROR.TITLE | translate}}></span>',
template: '{{ERROR.errorId| translate}}',
buttons: [{ text: 'OK' }]
});
}
else if (error.data.ExceptionMessage != null || error.data.ExceptionMessage != "" || error.data.ExceptionMessage != undefined) {
errorId = ...
$ionicPopup.show({
title: '{{ERROR.TITLE | translate}}></span>',
template: '{{ERROR.errorId| translate}}',
buttons: [{ text: 'OK' }]
});
}
else {
errorId = ...
$ionicPopup.show({
title: '{{ERROR.TITLE | translate}}></span>',
template: '{{ERROR.errorId| translate}}',
buttons: [{ text: 'OK' }]
});
}
}
This function determines which popup to display based on the error result. The title and text of the error message should be pulled from the translation file.
The ERROR object includes its TITLE and ID (e.g. 100, 200...) which are stored in a JSON file.
If you can assist me in resolving this issue, or need any further information, please let me know.