Move translation provider setup into shared client.js

This commit is contained in:
Johannes Zellner
2020-11-08 10:41:42 +01:00
parent 5f6344f400
commit f0a5796f2e
3 changed files with 37 additions and 75 deletions
-38
View File
@@ -30,16 +30,6 @@ app.config(['NotificationProvider', function (NotificationProvider) {
});
}]);
app.config(['$translateProvider', function ($translateProvider) {
$translateProvider.useStaticFilesLoader({
prefix: 'translation/',
suffix: '.json'
});
$translateProvider.useLocalStorage();
$translateProvider.preferredLanguage('en');
$translateProvider.fallbackLanguage('en');
}]);
// configure resourceUrlWhitelist https://code.angularjs.org/1.5.8/docs/api/ng/provider/$sceDelegateProvider#resourceUrlWhitelist
app.config(function ($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
@@ -118,34 +108,6 @@ app.config(['$routeProvider', function ($routeProvider) {
}).otherwise({ redirectTo: '/'});
}]);
// Add shorthand "tr" filter to avoid having ot use "translate"
// This is a copy of the code at https://github.com/angular-translate/angular-translate/blob/master/src/filter/translate.js
// If we find out how to get that function handle somehow dynamically we can use that, otherwise the copy is required
function translateFilterFactory($parse, $translate) {
'use strict';
var translateFilter = function (translationId, interpolateParams, interpolation, forceLanguage) {
if (!angular.isObject(interpolateParams)) {
var ctx = this || {
'__SCOPE_IS_NOT_AVAILABLE': 'More info at https://github.com/angular/angular.js/commit/8863b9d04c722b278fa93c5d66ad1e578ad6eb1f'
};
interpolateParams = $parse(interpolateParams)(ctx);
}
return $translate.instant(translationId, interpolateParams, interpolation, forceLanguage);
};
if ($translate.statefulFilter()) {
translateFilter.$stateful = true;
}
return translateFilter;
}
translateFilterFactory.displayName = 'translateFilterFactory';
app.filter('tr', translateFilterFactory);
app.filter('installError', function () {
return function (app) {
if (!app) return false;