From 8760f13c77850aeddc4116f3d7cf02e8d99c0903 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Tue, 27 Dec 2016 11:16:30 +0100 Subject: [PATCH 1/2] FIX: Translate all boolean values in user index --- .../admin/templates/user-index.hbs | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/admin/templates/user-index.hbs b/app/assets/javascripts/admin/templates/user-index.hbs index baa593a9c0b..53dc3a8d999 100644 --- a/app/assets/javascripts/admin/templates/user-index.hbs +++ b/app/assets/javascripts/admin/templates/user-index.hbs @@ -221,7 +221,13 @@
{{i18n 'admin.user.admin'}}
-
{{model.admin}}
+
+ {{#if model.admin}} + {{i18n 'yes_value'}} + {{else}} + {{i18n 'no_value'}} + {{/if}} +
{{#if model.can_revoke_admin}} {{d-button action="revokeAdmin" icon="shield" label="admin.user.revoke_admin"}} @@ -234,7 +240,13 @@
{{i18n 'admin.user.moderator'}}
-
{{model.moderator}}
+
+ {{#if model.moderator}} + {{i18n 'yes_value'}} + {{else}} + {{i18n 'no_value'}} + {{/if}} +
{{#if model.can_revoke_moderation}} {{d-button action="revokeModeration" icon="shield" label="admin.user.revoke_moderation"}} @@ -272,7 +284,13 @@
{{i18n 'admin.user.suspended'}}
-
{{model.isSuspended}}
+
+ {{#if model.isSuspended}} + {{i18n 'yes_value'}} + {{else}} + {{i18n 'no_value'}} + {{/if}} +
{{#if model.isSuspended}} {{d-button class="btn-danger" action="unsuspend" icon="ban" label="admin.user.unsuspend"}} @@ -303,7 +321,13 @@
{{i18n 'admin.user.blocked'}}
-
{{model.blocked}}
+
+ {{#if model.blocked}} + {{i18n 'yes_value'}} + {{else}} + {{i18n 'no_value'}} + {{/if}} +
{{#conditional-loading-spinner size="small" condition=model.blockingUser}} {{#if model.blocked}} @@ -319,7 +343,13 @@
{{i18n 'admin.user.staged'}}
-
{{model.staged}}
+
+ {{#if model.staged}} + {{i18n 'yes_value'}} + {{else}} + {{i18n 'no_value'}} + {{/if}} +
{{i18n 'admin.user.staged_explanation'}}
From e17bd6174c3497ccb349d1a697fb013156f10213 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Wed, 28 Dec 2016 11:45:41 +0100 Subject: [PATCH 2/2] Extract helper i18n-yes-no. --- .../admin/templates/user-index.hbs | 48 +++---------------- .../discourse-common/helpers/i18n.js.es6 | 1 + 2 files changed, 7 insertions(+), 42 deletions(-) diff --git a/app/assets/javascripts/admin/templates/user-index.hbs b/app/assets/javascripts/admin/templates/user-index.hbs index 53dc3a8d999..9cc35a3dce3 100644 --- a/app/assets/javascripts/admin/templates/user-index.hbs +++ b/app/assets/javascripts/admin/templates/user-index.hbs @@ -175,13 +175,7 @@
{{i18n 'admin.users.active'}}
-
- {{#if model.active}} - {{i18n 'yes_value'}} - {{else}} - {{i18n 'no_value'}} - {{/if}} -
+
{{i18n-yes-no model.active}}
{{#if model.active}} {{#if model.can_deactivate}} @@ -221,13 +215,7 @@
{{i18n 'admin.user.admin'}}
-
- {{#if model.admin}} - {{i18n 'yes_value'}} - {{else}} - {{i18n 'no_value'}} - {{/if}} -
+
{{i18n-yes-no model.admin}}
{{#if model.can_revoke_admin}} {{d-button action="revokeAdmin" icon="shield" label="admin.user.revoke_admin"}} @@ -240,13 +228,7 @@
{{i18n 'admin.user.moderator'}}
-
- {{#if model.moderator}} - {{i18n 'yes_value'}} - {{else}} - {{i18n 'no_value'}} - {{/if}} -
+
{{i18n-yes-no model.moderator}}
{{#if model.can_revoke_moderation}} {{d-button action="revokeModeration" icon="shield" label="admin.user.revoke_moderation"}} @@ -284,13 +266,7 @@
{{i18n 'admin.user.suspended'}}
-
- {{#if model.isSuspended}} - {{i18n 'yes_value'}} - {{else}} - {{i18n 'no_value'}} - {{/if}} -
+
{{i18n-yes-no model.isSuspended}}
{{#if model.isSuspended}} {{d-button class="btn-danger" action="unsuspend" icon="ban" label="admin.user.unsuspend"}} @@ -321,13 +297,7 @@
{{i18n 'admin.user.blocked'}}
-
- {{#if model.blocked}} - {{i18n 'yes_value'}} - {{else}} - {{i18n 'no_value'}} - {{/if}} -
+
{{i18n-yes-no model.blocked}}
{{#conditional-loading-spinner size="small" condition=model.blockingUser}} {{#if model.blocked}} @@ -343,13 +313,7 @@
{{i18n 'admin.user.staged'}}
-
- {{#if model.staged}} - {{i18n 'yes_value'}} - {{else}} - {{i18n 'no_value'}} - {{/if}} -
+
{{i18n-yes-no model.staged}}
{{i18n 'admin.user.staged_explanation'}}
diff --git a/app/assets/javascripts/discourse-common/helpers/i18n.js.es6 b/app/assets/javascripts/discourse-common/helpers/i18n.js.es6 index 455cc65a355..40fd2893d52 100644 --- a/app/assets/javascripts/discourse-common/helpers/i18n.js.es6 +++ b/app/assets/javascripts/discourse-common/helpers/i18n.js.es6 @@ -1,3 +1,4 @@ import { registerUnbound } from 'discourse-common/lib/helpers'; registerUnbound('i18n', (key, params) => I18n.t(key, params)); +registerUnbound('i18n-yes-no', (value, params) => I18n.t(value ? 'yes_value' : 'no_value', params));