Use _() as shorthand for translations

Used commonly when gettext is used for translations. Avoids cluttering
the code.
This commit is contained in:
Pierre Ossman 2016-11-14 21:58:14 +01:00
parent e1f853e5ae
commit f28e248d3f
2 changed files with 14 additions and 10 deletions

View File

@ -51,6 +51,8 @@ var UI;
window.onscriptsload = function () { UI.load(); }; window.onscriptsload = function () { UI.load(); };
/* [end skip-as-module] */ /* [end skip-as-module] */
var _ = Util.Localisation.get;
UI = { UI = {
connected: false, connected: false,
@ -390,26 +392,26 @@ var UI;
switch (state) { switch (state) {
case 'connecting': case 'connecting':
document.getElementById("noVNC_transition_text").innerHTML = Util.Localisation.get("Connecting..."); document.getElementById("noVNC_transition_text").innerHTML = _("Connecting...");
document.documentElement.classList.add("noVNC_connecting"); document.documentElement.classList.add("noVNC_connecting");
break; break;
case 'connected': case 'connected':
UI.connected = true; UI.connected = true;
document.documentElement.classList.add("noVNC_connected"); document.documentElement.classList.add("noVNC_connected");
if (rfb && rfb.get_encrypt()) { if (rfb && rfb.get_encrypt()) {
msg = Util.Localisation.get("Connected (encrypted) to ") + UI.desktopName; msg = _("Connected (encrypted) to ") + UI.desktopName;
} else { } else {
msg = Util.Localisation.get("Connected (unencrypted) to ") + UI.desktopName; msg = _("Connected (unencrypted) to ") + UI.desktopName;
} }
UI.showStatus(msg); UI.showStatus(msg);
break; break;
case 'disconnecting': case 'disconnecting':
document.getElementById("noVNC_transition_text").innerHTML = Util.Localisation.get("Disconnecting..."); document.getElementById("noVNC_transition_text").innerHTML = _("Disconnecting...");
document.documentElement.classList.add("noVNC_disconnecting"); document.documentElement.classList.add("noVNC_disconnecting");
break; break;
case 'disconnected': case 'disconnected':
UI.connected = false; UI.connected = false;
UI.showStatus(Util.Localisation.get("Disconnected")); UI.showStatus(_("Disconnected"));
break; break;
default: default:
msg = "Invalid UI state"; msg = "Invalid UI state";
@ -994,7 +996,7 @@ var UI;
} }
if ((!host) || (!port)) { if ((!host) || (!port)) {
var msg = Util.Localisation.get("Must set host and port"); var msg = _("Must set host and port");
Util.Error(msg); Util.Error(msg);
UI.showStatus(msg, 'error'); UI.showStatus(msg, 'error');
return; return;
@ -1260,7 +1262,7 @@ var UI;
// The browser is IE and we are in fullscreen mode. // The browser is IE and we are in fullscreen mode.
// - We need to force clipping while in fullscreen since // - We need to force clipping while in fullscreen since
// scrollbars doesn't work. // scrollbars doesn't work.
var msg = Util.Localisation.get("Forcing clipping mode since " + var msg = _("Forcing clipping mode since " +
"scrollbars aren't supported " + "scrollbars aren't supported " +
"by IE in fullscreen"); "by IE in fullscreen");
Util.Debug(msg); Util.Debug(msg);

View File

@ -263,6 +263,8 @@
}; };
(function() { (function() {
var _ = Util.Localisation.get;
RFB.prototype = { RFB.prototype = {
// Public methods // Public methods
connect: function (host, port, password, path) { connect: function (host, port, password, path) {
@ -273,7 +275,7 @@
if (!this._rfb_host || !this._rfb_port) { if (!this._rfb_host || !this._rfb_port) {
return this._fail( return this._fail(
Util.Localisation.get("Must set host and port")); _("Must set host and port"));
} }
this._rfb_init_state = ''; this._rfb_init_state = '';