Add appstore category translations

This commit is contained in:
Johannes Zellner
2020-12-09 12:15:08 +01:00
parent aa2d357de5
commit fbaa3ad15f
2 changed files with 32 additions and 2 deletions
+12 -1
View File
@@ -6,7 +6,7 @@
/* global RSTATES */
/* global moment */
angular.module('Application').controller('AppStoreController', ['$scope', '$location', '$timeout', '$routeParams', 'Client', function ($scope, $location, $timeout, $routeParams, Client) {
angular.module('Application').controller('AppStoreController', ['$scope', '$translate', '$location', '$timeout', '$routeParams', 'Client', function ($scope, $translate, $location, $timeout, $routeParams, Client) {
Client.onReady(function () { if (!Client.getUserInfo().isAtLeastAdmin) $location.path('/'); });
$scope.HOST_PORT_MIN = 1024;
@@ -40,6 +40,7 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
$('.modal').modal('hide');
};
// If new categories added make sure the translation below exists
$scope.categories = [
{ id: 'analytics', icon: 'fa fa-chart-line', label: 'Analytics'},
{ id: 'blog', icon: 'fa fa-font', label: 'Blog'},
@@ -62,6 +63,16 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
{ id: 'wiki', icon: 'fab fa-wikipedia-w', label: 'Wiki'},
];
// Translation IDs are generated as "appstore.category.<categoryId>"
$translate($scope.categories.map(function (c) { return 'appstore.category.' + c.id; })).then(function (tr) {
Object.keys(tr).forEach(function (key) {
if (key === tr[key]) return; // missing translation use default label
var category = $scope.categories.find(function (c) { return key.endsWith(c.id); });
if (category) category.label = tr[key];
});
});
$scope.categoryButtonLabel = function (category) {
if (category === 'new') return 'Category';
if (category === 'recent') return 'Category';