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

View File

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