Merge pull request #2261 from emanuelschuetze/config-translations

Fixed missing translations of config options (Fixes #2193)
This commit is contained in:
Emanuel Schütze 2016-08-09 20:18:49 +02:00 committed by GitHub
commit 320de66783
6 changed files with 21 additions and 11 deletions

View File

@ -11,7 +11,7 @@
"angular-csv-import": "~0.0.29", "angular-csv-import": "~0.0.29",
"angular-formly": "~7.3.9", "angular-formly": "~7.3.9",
"angular-formly-templates-bootstrap": "~6.2.0", "angular-formly-templates-bootstrap": "~6.2.0",
"angular-gettext": "~2.2.0", "angular-gettext": "~2.3.4",
"angular-loading-bar": "~0.8.0", "angular-loading-bar": "~0.8.0",
"angular-messages": "~1.4.10", "angular-messages": "~1.4.10",
"angular-pdf": "~1.3.0", "angular-pdf": "~1.3.0",

View File

@ -151,6 +151,7 @@ def get_config_variables():
yield ConfigVariable( yield ConfigVariable(
name='projector_default_countdown', name='projector_default_countdown',
default_value=60, default_value=60,
input_type='integer',
label='Default countdown', label='Default countdown',
weight=185, weight=185,
group='Projector') group='Projector')

View File

@ -389,7 +389,8 @@ angular.module('OpenSlidesApp.core.site', [
.directive('osFormField', [ .directive('osFormField', [
'$parse', '$parse',
'Config', 'Config',
function($parse, Config) { 'gettextCatalog',
function($parse, Config, gettextCatalog) {
function getHtmlType(type) { function getHtmlType(type) {
return { return {
string: 'text', string: 'text',
@ -410,15 +411,19 @@ angular.module('OpenSlidesApp.core.site', [
var config = Config.get(field.key); var config = Config.get(field.key);
$scope.type = getHtmlType(field.input_type); $scope.type = getHtmlType(field.input_type);
if ($scope.type == 'choice') { if ($scope.type == 'choice') {
$scope.choices = field.choices; $scope.choices = [];
angular.forEach(field.choices, function(choice) {
choice.display_name = gettextCatalog.getString(choice.display_name);
$scope.choices.push(choice);
});
} }
$scope.label = field.label; $scope.label = field.label;
$scope.key = 'field-' + field.key; $scope.key = 'field-' + field.key;
$scope.value = config.value; $scope.value = gettextCatalog.getString(config.value);
$scope.help_text = field.help_text; $scope.help_text = field.help_text;
$scope.default_value = field.default_value; $scope.default_value = field.default_value;
$scope.reset = function () { $scope.reset = function () {
$scope.value = $scope.default_value; $scope.value = gettextCatalog.getString($scope.default_value);
$scope.save(field.key, $scope.value); $scope.save(field.key, $scope.value);
}; };
} }

View File

@ -1,10 +1,11 @@
<div class="form-group"> <div class="form-group">
<label>{{ label }}</label> <label>{{ label | translate }}</label>
<div class="input-group"> <div class="input-group">
<!-- text/number input, checkbox --> <!-- text/number input, checkbox -->
<input ng-if="type == 'text' || type == 'number' || type == 'checkbox'" <input ng-if="type == 'text' || type == 'number' || type == 'checkbox'"
ng-model="$parent.value" ng-model="$parent.value"
ng-model-options="{debounce: 1000}"
ng-change="save(configOption.key, $parent.value)" ng-change="save(configOption.key, $parent.value)"
ng-class="{ 'form-control': type != 'checkbox' }" ng-class="{ 'form-control': type != 'checkbox' }"
id="{{ key }}" id="{{ key }}"
@ -15,12 +16,14 @@
colorpicker colorpicker
class="form-control" class="form-control"
ng-model="$parent.value" ng-model="$parent.value"
ng-model-options="{debounce: 1000}"
ng-change="save(configOption.key, $parent.value)" ng-change="save(configOption.key, $parent.value)"
type="text"> type="text">
<!-- textarea --> <!-- textarea -->
<textarea ng-if="type == 'textarea'" <textarea ng-if="type == 'textarea'"
ng-model="$parent.value" ng-model="$parent.value"
ng-model-options="{debounce: 1000}"
ng-change="save(configOption.key, $parent.value)" ng-change="save(configOption.key, $parent.value)"
id="{{ key }}" class="form-control"> id="{{ key }}" class="form-control">
</textarea> </textarea>
@ -28,17 +31,18 @@
<!-- select --> <!-- select -->
<select ng-if="type == 'choice'" <select ng-if="type == 'choice'"
ng-model="$parent.value" ng-model="$parent.value"
ng-model-options="{debounce: 500}"
ng-change="save(configOption.key, $parent.value)" ng-change="save(configOption.key, $parent.value)"
id="{{ key }}" id="{{ key }}"
class="form-control" ng-options="option.value as option.display_name for option in choices"> class="form-control" ng-options="option.value as option.display_name for option in choices">
</select> </select>
<span class="input-group-btn"> <span class="input-group-btn">
<button ng-click="reset()" class="btn btn-default" title="{{ default_value }}"> <button ng-click="reset()" class="btn btn-default" title="{{ default_value | translate }}">
<i class="fa fa-undo"></i> <i class="fa fa-undo"></i>
<translate>Reset</translate> <translate>Reset</translate>
</button> </button>
</span> </span>
</div> </div>
<p ng-if="help_text" class="help-block">{{ help_text }}</p> <p ng-if="help_text" class="help-block">{{ help_text | translate }}</p>
</div> </div>

View File

@ -21,7 +21,7 @@
<div id="group{{ $index }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-group{{ $index }}"> <div id="group{{ $index }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-group{{ $index }}">
<div class="panel-body"> <div class="panel-body">
<div ng-repeat="subgroup in group.subgroups"> <div ng-repeat="subgroup in group.subgroups">
<h3>{{ subgroup.name }}</h3> <h3>{{ subgroup.name | translate }}</h3>
<div ng-repeat="configOption in subgroup.items"> <div ng-repeat="configOption in subgroup.items">
<os-form-field field="configOption"></os-form-field> <os-form-field field="configOption"></os-form-field>
</div> </div>

View File

@ -1,9 +1,9 @@
<div os-perms="core.can_see_frontpage" class="header"> <div os-perms="core.can_see_frontpage" class="header">
<div class="title"> <div class="title">
<h1>{{ config('general_event_welcome_title') }}</h1> <h1>{{ config('general_event_welcome_title') | translate }}</h1>
</div> </div>
</div> </div>
<div os-perms="core.can_see_frontpage" class="details" <div os-perms="core.can_see_frontpage" class="details"
ng-bind-html="config('general_event_welcome_text')"> ng-bind-html="config('general_event_welcome_text') | translate">
</div> </div>