[pmg-devel] [PATCH pmg-gui] fix gettext invocations

Dominik Csapak d.csapak at proxmox.com
Thu Mar 7 14:21:58 CET 2019


using gettext the way we did, broke the jsgettext.pl in proxmox-i18n
during a 'make update'

instead of using the template way, simply replace it by using plain
gettext as a function, this way we do not skip over the getttext uses
accidentally

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 js/mobile/app.js            |  1 -
 js/mobile/loginscreen.js    |  6 +++---
 js/mobile/mailview.js       | 10 +++++-----
 js/mobile/quarantineview.js | 18 +++++++++---------
 js/mobile/utils.js          |  4 ----
 5 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/js/mobile/app.js b/js/mobile/app.js
index 68fb9e5..d11c63b 100644
--- a/js/mobile/app.js
+++ b/js/mobile/app.js
@@ -26,7 +26,6 @@ var app = new Framework7({
 	    async: function(routeTo, routeFrom, resolve, reject) {
 		let action = routeTo.params.action;
 		let mailid = routeTo.params.mailid;
-		let confirmText = gettext('')
 		app.dialog.confirm(
 		    `${action}: ${mailid}`,
 		    gettext('Confirm'),
diff --git a/js/mobile/loginscreen.js b/js/mobile/loginscreen.js
index 36dc994..cd7a370 100644
--- a/js/mobile/loginscreen.js
+++ b/js/mobile/loginscreen.js
@@ -16,7 +16,7 @@ class LoginScreen extends Component {
 			<div class="item-inner">
 			  <div class="item-title item-label">Username</div>
 			  <div class="item-input-wrap">
-			    <input type="text" name="username" placeholder="{{gettext 'Username'}}" required validate>
+			    <input type="text" name="username" placeholder="` + gettext('Username') + `" required validate>
 			    <span class="input-clear-button"></span>
 			  </div>
 			</div>
@@ -25,7 +25,7 @@ class LoginScreen extends Component {
 			<div class="item-inner">
 			  <div class="item-title item-label">Password</div>
 			  <div class="item-input-wrap">
-			    <input type="password" name="password" placeholder="{{gettext 'Password'}}" required validate>
+			    <input type="password" name="password" placeholder="` + gettext('Password') + `" required validate>
 			    <span class="input-clear-button"></span>
 			  </div>
 			</div>
@@ -35,7 +35,7 @@ class LoginScreen extends Component {
 		  <div class="list">
 		    <ul>
 		      <li>
-			<input type="submit" class="button" value='{{gettext "Log In"}}'>
+			<input type="submit" class="button" value='` + gettext("Log In") + `'>
 		      </li>
 		    </ul>
 		  </div>
diff --git a/js/mobile/mailview.js b/js/mobile/mailview.js
index c89d134..3645b81 100644
--- a/js/mobile/mailview.js
+++ b/js/mobile/mailview.js
@@ -7,7 +7,7 @@ class MailView extends Component {
 		    <div class="left">
 		  <a href="#" class="link back">
 		<i class="icon icon-back"></i>
-		<span class="ios-only">{{gettext "Back"}}</span>
+		<span class="ios-only">` + gettext("Back") + `</span>
 		  </a>
 		    </div>
 		    <div class="title">Preview</div>
@@ -26,28 +26,28 @@ class MailView extends Component {
 			  <i class="icon f7-icons ios-only">close</i>
 			  <i class="icon material-icons md-only">close</i>
 			</span>
-			<span class="fab-label">{{gettext "Blacklist"}}</span>
+			<span class="fab-label">` + gettext("Blacklist") + `</span>
 		    </a>
 		    <a href="/mail/{{mailid}}/whitelist" class="fab-label-button fab-close">
 			<span>
 			    <i class="icon f7-icons ios-only">check</i>
 			    <i class="icon material-icons md-only">check</i>
 			</span>
-			<span class="fab-label">{{gettext "Whitelist"}}</span>
+			<span class="fab-label">` + gettext("Whitelist") + `</span>
 		    </a>
 		    <a href="/mail/{{mailid}}/delete" class="fab-label-button fab-close">
 			<span>
 			    <i class="icon f7-icons ios-only">trash</i>
 			    <i class="icon material-icons md-only">delete</i>
 			</span>
-		    <span class="fab-label">{{gettext "Delete"}}</span>
+		    <span class="fab-label">` + gettext("Delete") + `</span>
 		    </a>
 		    <a href="/mail/{{mailid}}/deliver" class="fab-label-button fab-close">
 			<span>
 			    <i class="icon f7-icons ios-only">paper_plane</i>
 			    <i class="icon material-icons md-only">send</i>
 			</span>
-			<span class="fab-label">{{gettext "Deliver"}}</span>
+			<span class="fab-label">` + gettext("Deliver") + `</span>
 		    </a>
 		</div>
 	    </div>
diff --git a/js/mobile/quarantineview.js b/js/mobile/quarantineview.js
index 7113214..b6203bc 100644
--- a/js/mobile/quarantineview.js
+++ b/js/mobile/quarantineview.js
@@ -12,12 +12,12 @@ class QuarantineView extends Component {
 		    </div>
 		</div>
 		<div class="settings-form elevation-5 fab-morph-target">
-		    <div class="block-title block-title-medium">{{gettext "Range"}}</div>
+		    <div class="block-title block-title-medium">` + gettext("Range") + `</div>
 		    <div class="list no-hairlines-md">
 			<ul>
 			    <li class="item-content item-input">
 				<div class="item-inner">
-				    <div class="item-title item-label">{{gettext "From"}}</div>
+				    <div class="item-title item-label">` + gettext("From") + `</div>
 				    <div class="item-input-wrap">
 					<input type="date" name="from" placeholder="from" required validate>
 				    </div>
@@ -25,14 +25,14 @@ class QuarantineView extends Component {
 			    </li>
 			    <li class="item-content item-input">
 				<div class="item-inner">
-				    <div class="item-title item-label">{{gettext "To"}}</div>
+				    <div class="item-title item-label">` + gettext("To") + `</div>
 				    <div class="item-input-wrap">
 					<input type="date" name="to" placeholder="to" required validate>
 				    </div>
 				</div>
 			    </li>
 			</ul>
-			<a class="button fab-close range-form">{{gettext "OK"}}</a>
+			<a class="button fab-close range-form">` + gettext("OK") + `</a>
 		    </div>
 		</div>
 		<div class="fab fab-morph fab-right-bottom" data-morph-to=".settings-form">
@@ -47,7 +47,7 @@ class QuarantineView extends Component {
 			    <i class="icon f7-icons ios-only color-yellow">alert</i>
 			    <i class="icon material-icons md-only color-yellow">warning</i>
 			    <span class="subscription-text">
-			    {{gettext "No valid subscription"}}
+			    ` + gettext("No valid subscription") + `
 			    </span>
 			</a>
 			</div>
@@ -78,24 +78,24 @@ class QuarantineView extends Component {
 		    <a href="/mail/{{id}}/deliver" class="color-green swipeout-close">
 			<i class="icon f7-icons ios-only">paper_plane</i>
 			<i class="icon material-icons md-only">send</i>
-			 {{gettext "Deliver"}}
+			 ` + gettext("Deliver") + `
 		    </a>
 		    <a href="/mail/{{id}}/whitelist" class="swipeout-close">
 			<i class="icon f7-icons ios-only">check</i>
 			<i class="icon material-icons md-only">check</i>
-			 {{gettext "Whitelist"}}
+			 ` + gettext("Whitelist") + `
 		    </a>
 		</div>
 		<div class="swipeout-actions-right">
 		    <a href="/mail/{{id}}/blacklist" class="color-orange swipeout-close">
 			<i class="icon f7-icons ios-only">close</i>
 			<i class="icon material-icons md-only">close</i>
-			 {{gettext "Blacklist"}}
+			 ` + gettext("Blacklist") + `
 		    </a>
 		    <a href="/mail/{{id}}/delete" class="color-red swipeout-close">
 			<i class="icon f7-icons ios-only">trash</i>
 			<i class="icon material-icons md-only">delete</i>
-			 {{gettext "Delete"}}
+			 ` + gettext("Delete") + `
 		    </a>
 		</div>
 	    </li>`;
diff --git a/js/mobile/utils.js b/js/mobile/utils.js
index 2b27d36..50810a0 100644
--- a/js/mobile/utils.js
+++ b/js/mobile/utils.js
@@ -1,7 +1,3 @@
-Template7.registerHelper('gettext', function(value) {
-    return gettext(value);
-});
-
 var PMG = {
     Utils: {
 	getCookie(name) {
-- 
2.11.0




More information about the pmg-devel mailing list