Started to implement a localization method to support multible languages

canary
WolverinDEV 2018-12-05 20:46:33 +01:00
parent 923de09df4
commit a29b2bf850
41 changed files with 467 additions and 432 deletions

View File

@ -48,7 +48,7 @@ class DownloadFileTransfer {
return;
}
console.debug("Create new file download to " + this.remoteHost + ":" + this.remotePort + " (Key: " + this.transferKey + ", Expect " + this.totalSize + " bytes)");
console.debug(tr("Create new file download to %s:%s (Key: %s, Expect %d bytes)"), this.remoteHost, this.remotePort, this.transferId, this.totalSize);
this._active = true;
this._socket = new WebSocket("wss://" + this.remoteHost + ":" + this.remotePort);
this._socket.onopen = this.onOpen.bind(this);
@ -66,7 +66,7 @@ class DownloadFileTransfer {
private onMessage(data: MessageEvent) {
if(!this._active) {
console.error("Got data, but socket closed?");
console.error(tr("Got data, but socket closed?"));
return;
}
this._parseActive = true;
@ -92,14 +92,14 @@ class DownloadFileTransfer {
private onError() {
if(!this._active) return;
this.on_fail("an error occurent");
this.on_fail(tr("an error occurent"));
this.disconnect();
}
private onClose() {
if(!this._active) return;
if(!this._parseActive) this.on_fail("unexpected close (remote closed)");
if(!this._parseActive) this.on_fail(tr("unexpected close (remote closed)"));
this.disconnect();
}
@ -164,7 +164,7 @@ class FileManager {
}
if(!entry) {
console.error("Invalid file list entry. Path: " + json[0]["path"]);
console.error(tr("Invalid file list entry. Path: %s"), json[0]["path"]);
return;
}
for(let e of (json as Array<FileEntry>))
@ -183,7 +183,7 @@ class FileManager {
}
if(!entry) {
console.error("Invalid file list entry finish. Path: " + json[0]["path"]);
console.error(tr("Invalid file list entry finish. Path: "), json[0]["path"]);
return;
}
entry.callback(entry.entries);
@ -333,8 +333,8 @@ class IconManager {
let array = new Uint8Array(0);
ft.on_fail = reason => {
this.load_finished(id);
console.error("Could not download icon " + id + " -> " + reason);
chat.serverChat().appendError("Fail to download icon {0}. ({1})", id, JSON.stringify(reason));
console.error(tr("Could not download icon %s -> %s"), id, tr(reason));
chat.serverChat().appendError(tr("Fail to download icon {0}. ({1})"), id, JSON.stringify(reason));
reject(reason);
};
ft.on_start = () => {};
@ -355,8 +355,8 @@ class IconManager {
ft.startTransfer();
}).catch(reason => {
console.error("Error while downloading icon! (" + JSON.stringify(reason) + ")");
chat.serverChat().appendError("Failed to request download for icon {0}. ({1})", id, JSON.stringify(reason));
console.error(tr("Error while downloading icon! (%s)"), tr(JSON.stringify(reason)));
chat.serverChat().appendError(tr("Failed to request download for icon {0}. ({1})"), id, tr(JSON.stringify(reason)));
reject(reason);
});
});
@ -382,7 +382,7 @@ class IconManager {
if(icon) {
const type = image_type(icon.base64);
const media = media_image_type(type);
console.debug("Icon has an image type of %o (media: %o)", type, media);
console.debug(tr("Icon has an image type of %o (media: %o)"), type, media);
img.attr("src", "data:image/" + media + ";base64," + icon.base64);
tag.append(img);
} else {
@ -395,9 +395,9 @@ class IconManager {
this.loadIcon(id).then(icon => {
const type = image_type(icon.base64);
const media = media_image_type(type);
console.debug("Icon has an image type of %o (media: %o)", type, media);
console.debug(tr("Icon has an image type of %o (media: %o)"), type, media);
img.attr("src", "data:image/" + media + ";base64," + icon.base64);
console.debug("Icon " + id + " loaded :)");
console.debug(tr("Icon %o loaded :)"), id);
img.css("opacity", 0);
tag.append(img);
@ -406,7 +406,7 @@ class IconManager {
img.animate({opacity: 1}, 150);
});
}).catch(reason => {
console.error("Could not load icon " + id + ". Reason: " + reason);
console.error(tr("Could not load icon %o. Reason: %p"), id, reason);
loader.removeClass("icon_loading").addClass("icon client-warning").attr("tag", "Could not load icon " + id);
});
}
@ -433,7 +433,7 @@ class AvatarManager {
}
downloadAvatar(client: ClientEntry) : Promise<DownloadFileTransfer> {
console.log("Downloading avatar %s", client.avatarId());
console.log(tr("Downloading avatar %s"), client.avatarId());
return this.handle.requestFileDownload("", "/avatar_" + client.avatarId());
}
@ -480,8 +480,8 @@ class AvatarManager {
let array = new Uint8Array(0);
ft.on_fail = reason => {
this.load_finished(name);
console.error("Could not download avatar " + client.properties.client_flag_avatar + " -> " + reason);
chat.serverChat().appendError("Fail to download avatar for {0}. ({1})", client.clientNickName(), JSON.stringify(reason));
console.error(tr("Could not download avatar %o -> %s"), client.properties.client_flag_avatar, reason);
chat.serverChat().appendError(tr("Fail to download avatar for {0}. ({1})"), client.clientNickName(), JSON.stringify(reason));
reject(reason);
};
ft.on_start = () => {};
@ -509,8 +509,8 @@ class AvatarManager {
ft.startTransfer();
}).catch(reason => {
this.load_finished(name);
console.error("Error while downloading avatar! (" + JSON.stringify(reason) + ")");
chat.serverChat().appendError("Failed to request avatar download for {0}. ({1})", client.clientNickName(), JSON.stringify(reason));
console.error(tr("Error while downloading avatar! (%s)"), JSON.stringify(reason));
chat.serverChat().appendError(tr("Failed to request avatar download for {0}. ({1})"), client.clientNickName(), JSON.stringify(reason));
reject(reason);
});
});
@ -532,7 +532,7 @@ class AvatarManager {
else {
const type = image_type(avatar.base64);
const media = media_image_type(type);
console.debug("Avatar has an image type of %o (media: %o)", type, media);
console.debug(tr("avatar has an image type of %o (media: %o)"), type, media);
img.attr("src", "data:image/" + media + ";base64," + avatar.base64);
}
tag.append(img);
@ -547,7 +547,7 @@ class AvatarManager {
else {
const type = image_type(avatar.base64);
const media = media_image_type(type);
console.debug("Avatar has an image type of %o (media: %o)", type, media);
console.debug(tr("Avatar has an image type of %o (media: %o)"), type, media);
img.attr("src", "data:image/" + media + ";base64," + avatar.base64);
}
console.debug("Avatar " + client.clientNickName() + " loaded :)");
@ -559,9 +559,9 @@ class AvatarManager {
img.animate({opacity: 1}, 150);
});
}).catch(reason => {
console.error("Could not load avatar for " + client.clientNickName() + ". Reason: " + reason);
console.error(tr("Could not load avatar for %s. Reason: %s"), client.clientNickName(), reason);
//TODO Broken image
loader.addClass("icon client-warning").attr("tag", "Could not load avatar " + client.clientNickName());
loader.addClass("icon client-warning").attr("tag", tr("Could not load avatar ") + client.clientNickName());
});
}

View File

@ -43,7 +43,7 @@ namespace TSIdentityHelper {
if(str == "") return "";
try {
if(!$.isFunction(window.Pointer_stringify)) {
displayCriticalError("Missing required wasm function!<br>Please reload the page!");
displayCriticalError(tr("Missing required wasm function!<br>Please reload the page!"));
}
let message: string = window.Pointer_stringify(str);
functionDestroyString(str);

View File

@ -38,15 +38,15 @@ namespace ppt {
export function key_description(key: KeyDescriptor) {
let result = "";
if(key.key_shift)
result += " + Shift";
result += " + " + tr("Shift");
if(key.key_alt)
result += " + Alt";
result += " + " + tr("Alt");
if(key.key_ctrl)
result += " + CTRL";
result += " + " + tr("CTRL");
if(key.key_windows)
result += " + Win";
result += " + " + tr("Win");
result += " + " + (key.key_code ? key.key_code : "unset");
result += " + " + (key.key_code ? key.key_code : tr("unset"));
return result.substr(3);
}

View File

@ -62,12 +62,12 @@ namespace MessageHelper {
}
if(objects.length < number)
console.warn("Message to format contains invalid index (" + number + ")");
console.warn(tr("Message to format contains invalid index (%o)"), number);
result.push(...this.formatElement(objects[number]));
found = found + 1 + offset;
begin = found + 1;
console.log("Offset: " + offset + " Number: " + number);
console.log(tr("Offset: %d Number: %d"), offset, number);
} while(found++);
return result;
@ -201,7 +201,7 @@ class ChatEntry {
actions.push({
type: MenuEntryType.ENTRY,
icon: "",
name: "Clear",
name: tr("Clear"),
callback: () => {
_this.history = [];
_this.displayHistory();
@ -211,7 +211,7 @@ class ChatEntry {
actions.push({
type: MenuEntryType.ENTRY,
icon: "client-tab_close_button",
name: "Close",
name: tr("Close"),
callback: () => {
chat.deleteChat(_this);
}
@ -221,7 +221,7 @@ class ChatEntry {
actions.push({
type: MenuEntryType.ENTRY,
icon: "client-tab_close_button",
name: "Close all private tabs",
name: tr("Close all private tabs"),
callback: () => {
//TODO Implement this?
}
@ -244,7 +244,7 @@ class ChatEntry {
}
set name(newName : string) {
console.log("Change name!");
console.log(tr("Change name!"));
this._name = newName;
this.htmlTag.find(".name").text(this._name);
}
@ -253,7 +253,7 @@ class ChatEntry {
if(this._closeable == flag) return;
this._closeable = flag;
console.log("Set closeable: " + this._closeable);
console.log(tr("Set closeable: ") + this._closeable);
if(flag) this.htmlTag.find(".btn_close").show();
else this.htmlTag.find(".btn_close").hide();
}
@ -318,14 +318,14 @@ class ChatBox {
this.createChat("chat_server", ChatType.SERVER).onMessageSend = (text: string) => {
if(!globalClient.serverConnection) {
chat.serverChat().appendError("Could not send chant message (Not connected)");
chat.serverChat().appendError(tr("Could not send chant message (Not connected)"));
return;
}
globalClient.serverConnection.sendMessage(text, ChatType.SERVER);
};
this.createChat("chat_channel", ChatType.CHANNEL).onMessageSend = (text: string) => {
if(!globalClient.serverConnection) {
chat.channelChat().appendError("Could not send chant message (Not connected)");
chat.channelChat().appendError(tr("Could not send chant message (Not connected)"));
return;
}

View File

@ -91,14 +91,14 @@ class TSClient {
host = addr;
port = 9987;
}
console.log("Start connection to " + host + ":" + port);
console.log(tr("Start connection to %s:%d"), host, port);
this.channelTree.initialiseHead(addr, {host, port});
if(password && !password.hashed) {
helpers.hashPassword(password.password).then(password => {
this.serverConnection.startConnection({host, port}, new HandshakeHandler(identity, name, password));
}).catch(error => {
createErrorModal("Error while hashing password", "Failed to hash server password!<br>" + error).open();
createErrorModal(tr("Error while hashing password"), tr("Failed to hash server password!<br>" + error).open();
})
} else
this.serverConnection.startConnection({host, port}, new HandshakeHandler(identity, name, password ? password.password : undefined));
@ -133,7 +133,7 @@ class TSClient {
this.groups.requestGroups();
this.controlBar.updateProperties();
if(!this.voiceConnection.current_encoding_supported())
createErrorModal("Codec encode type not supported!", "Codec encode type " + VoiceConnectionType[this.voiceConnection.type] + " not supported by this browser!<br>Choose another one!").open();
createErrorModal(tr("Codec encode type not supported!"), tr("Codec encode type " + VoiceConnectionType[this.voiceConnection.type] + " not supported by this browser!<br>Choose another one!")).open(); //TODO tr
}
get connected() : boolean {
@ -166,17 +166,18 @@ class TSClient {
case DisconnectReason.REQUESTED:
break;
case DisconnectReason.CONNECT_FAILURE:
console.error("Could not connect to remote host! Exception");
console.error(tr("Could not connect to remote host! Exception"));
console.error(data);
if(native_client) {
createErrorModal(
"Could not connect",
"Could not connect to remote host (Connection refused)"
tr("Could not connect"),
tr("Could not connect to remote host (Connection refused)")
).open();
} else {
//TODO tr
createErrorModal(
"Could not connect",
tr("Could not connect"),
"Could not connect to remote host (Connection refused)<br>" +
"If you're sure that the remote host is up, than you may not allow unsigned certificates.<br>" +
"Click <a href='" + this.certAcceptUrl() + "'>here</a> to accept the remote certificate"
@ -185,33 +186,33 @@ class TSClient {
sound.play(Sound.CONNECTION_REFUSED);
break;
case DisconnectReason.CONNECTION_CLOSED:
console.error("Lost connection to remote server!");
console.error(tr("Lost connection to remote server!"));
createErrorModal(
"Connection closed",
"The connection was closed by remote host"
tr("Connection closed"),
tr("The connection was closed by remote host")
).open();
sound.play(Sound.CONNECTION_DISCONNECTED);
break;
case DisconnectReason.CONNECTION_PING_TIMEOUT:
console.error("Connection ping timeout");
console.error(tr("Connection ping timeout"));
sound.play(Sound.CONNECTION_DISCONNECTED_TIMEOUT);
createErrorModal(
"Connection lost",
"Lost connection to remote host (Ping timeout)<br>Even possible?"
tr("Connection lost"),
tr("Lost connection to remote host (Ping timeout)<br>Even possible?")
).open();
break;
case DisconnectReason.SERVER_CLOSED:
chat.serverChat().appendError("Server closed ({0})", data.reasonmsg);
chat.serverChat().appendError(tr("Server closed ({0})"), data.reasonmsg);
createErrorModal(
"Server closed",
"The server is closed.<br>" +
tr("Server closed"),
"The server is closed.<br>" + //TODO tr
"Reason: " + data.reasonmsg
).open();
sound.play(Sound.CONNECTION_DISCONNECTED);
break;
case DisconnectReason.SERVER_REQUIRES_PASSWORD:
chat.serverChat().appendError("Server requires password");
createInputModal("Server password", "Enter server password:", password => password.length != 0, password => {
chat.serverChat().appendError(tr("Server requires password"));
createInputModal(tr("Server password"), tr("Enter server password:"), password => password.length != 0, password => {
if(!(typeof password === "string")) return;
this.startConnection(this.serverConnection._remote_address.host + ":" + this.serverConnection._remote_address.port,
this.serverConnection._handshakeHandler.identity,
@ -220,20 +221,20 @@ class TSClient {
}).open();
break;
case DisconnectReason.CLIENT_KICKED:
chat.serverChat().appendError("You got kicked from the server by {0}{1}",
chat.serverChat().appendError(tr("You got kicked from the server by {0}{1}"),
ClientEntry.chatTag(data["invokerid"], data["invokername"], data["invokeruid"]),
data["reasonmsg"] ? " (" + data["reasonmsg"] + ")" : "");
sound.play(Sound.SERVER_KICKED);
break;
case DisconnectReason.CLIENT_BANNED:
chat.serverChat().appendError("You got banned from the server by {0}{1}",
chat.serverChat().appendError(tr("You got banned from the server by {0}{1}"),
ClientEntry.chatTag(data["invokerid"], data["invokername"], data["invokeruid"]),
data["reasonmsg"] ? " (" + data["reasonmsg"] + ")" : "");
sound.play(Sound.CONNECTION_BANNED); //TODO findout if it was a disconnect or a connect refuse
break;
default:
console.error("Got uncaught disconnect!");
console.error("Type: " + type + " Data:");
console.error(tr("Got uncaught disconnect!"));
console.error(tr("Type: %o Data:"), type);
console.error(data);
break;
}

View File

@ -49,8 +49,8 @@ abstract class BasicCodec implements Codec {
encodeSamples(cache: CodecClientCache, pcm: AudioBuffer) {
this._encodeResampler.resample(pcm).catch(error => console.error("Could not resample PCM data for codec. Error:" + error))
.then(buffer => this.encodeSamples0(cache, buffer as any)).catch(error => console.error("Could not encode PCM data for codec. Error:" + error))
this._encodeResampler.resample(pcm).catch(error => console.error(tr("Could not resample PCM data for codec. Error: %o"), error))
.then(buffer => this.encodeSamples0(cache, buffer as any)).catch(error => console.error(tr("Could not encode PCM data for codec. Error: %o"), error))
}
@ -74,12 +74,12 @@ abstract class BasicCodec implements Codec {
if(result instanceof Uint8Array) {
let time = Date.now() - encodeBegin;
if(time > 20)
console.error("Required time: %d", time);
console.error(tr("Required time: %d"), time);
//if(time > 20)
// chat.serverChat().appendMessage("Required decode time: " + time);
this.on_encoded_data(result);
}
else console.error("[Codec][" + this.name() + "] Could not encode buffer. Result: " + result);
else console.error("[Codec][" + this.name() + "] Could not encode buffer. Result: " + result); //TODO tr
});
}
return true;

View File

@ -153,15 +153,15 @@ class CodecWrapperWorker extends BasicCodec {
private onWorkerMessage(message: any) {
if(Date.now() - message["timestamp"] > 5)
console.warn("Worker message stock time: %d", Date.now() - message["timestamp"]);
console.warn(tr("Worker message stock time: %d"), Date.now() - message["timestamp"]);
if(!message["token"]) {
console.error("Invalid worker token!");
console.error(tr("Invalid worker token!"));
return;
}
if(message["token"] == this._workerCallbackToken) {
if(message["type"] == "loaded") {
console.log("[Codec] Got worker init response: Success: %o Message: %o", message["success"], message["message"]);
console.log(tr("[Codec] Got worker init response: Success: %o Message: %o"), message["success"], message["message"]);
if(message["success"]) {
if(this._workerCallbackResolve)
this._workerCallbackResolve();
@ -176,7 +176,7 @@ class CodecWrapperWorker extends BasicCodec {
chat.serverChat().appendMessage(message["message"]);
return;
}
console.log("Costume callback! (%o)", message);
console.log(tr("Costume callback! (%o)"), message);
return;
}
@ -188,6 +188,7 @@ class CodecWrapperWorker extends BasicCodec {
}
}
//TODO tr
console.error("Could not find worker token entry! (" + message["token"] + ")");
}
@ -198,7 +199,7 @@ class CodecWrapperWorker extends BasicCodec {
this._worker = new Worker(settings.static("worker_directory", "js/workers/") + "WorkerCodec.js");
this._worker.onmessage = event => this.onWorkerMessage(event.data);
this._worker.onerror = (error: ErrorEvent) => reject("Failed to load worker (" + error.message + ")");
this._worker.onerror = (error: ErrorEvent) => reject("Failed to load worker (" + error.message + ")"); //TODO tr
});
}
}

View File

@ -56,8 +56,8 @@ class ServerConnection {
}
on_connect: () => void = () => {
console.log("Socket connected");
chat.serverChat().appendMessage("Logging in...");
console.log(tr("Socket connected"));
chat.serverChat().appendMessage(tr("Logging in..."));
this._handshakeHandler.startHandshake();
};
@ -76,12 +76,12 @@ class ServerConnection {
this._handshakeHandler = handshake;
this._handshakeHandler.setConnection(this);
this._connected = false;
chat.serverChat().appendMessage("Connecting to " + address.host + ":" + address.port);
chat.serverChat().appendMessage(tr("Connecting to {0}:{1}"), true, address.host, address.port);
const self = this;
try {
this._connectTimeoutHandler = setTimeout(() => {
console.log("Connect timeout triggered!");
console.log(tr("Connect timeout triggered!"));
this.disconnect();
this._client.handleDisconnect(DisconnectReason.CONNECT_FAILURE);
}, timeout);
@ -108,7 +108,7 @@ class ServerConnection {
this._socket.onerror = e => {
if(this._socket != sockCpy) return;
console.log("Got error: (" + self._socket.readyState + ")");
console.log(tr("Got error: (%s)"), self._socket.readyState);
console.log(e);
};
@ -132,10 +132,10 @@ class ServerConnection {
if(this._connectionState == ConnectionState.UNCONNECTED) return false;
this.updateConnectionState(ConnectionState.UNCONNECTED);
if(this._socket) this._socket.close(3000 + 0xFF, "request disconnect");
if(this._socket) this._socket.close(3000 + 0xFF, tr("request disconnect"));
this._socket = null;
for(let future of this._retListener)
future.reject("Connection closed");
future.reject(tr("Connection closed"));
this._retListener = [];
this._retCodeIdx = 0;
this._connected = false;
@ -148,31 +148,31 @@ class ServerConnection {
try {
json = JSON.parse(data);
} catch(e) {
console.error("Could not parse message json!");
console.error(tr("Could not parse message json!"));
alert(e); // error in the above string (in this case, yes)!
return;
}
if(json["type"] === undefined) {
console.log("Missing data type!");
console.log(tr("Missing data type!"));
return;
}
if(json["type"] === "command") this.handleCommand(json);
else if(json["type"] === "WebRTC") this._client.voiceConnection.handleControlPacket(json);
else {
console.log("Unknown command type " + json["type"]);
console.log(tr("Unknown command type %o"), json["type"]);
}
}
}
handleCommand(json) {
let group = log.group(log.LogType.DEBUG, LogCategory.NETWORKING, "Handling command '%s'", json["command"]);
group.log("Handling command '" + json["command"] + "'");
group.group(log.LogType.TRACE, "Json:").collapsed(true).log("%o", json).end();
let group = log.group(log.LogType.DEBUG, LogCategory.NETWORKING, tr("Handling command '%s'"), json["command"]);
group.log(tr("Handling command '%s'"), json["command"]);
group.group(log.LogType.TRACE, tr("Json:")).collapsed(true).log("%o", json).end();
try {
let fn = this.commandHandler[json["command"]];
if(fn === undefined) {
group.log("Missing command '" + json["command"] + "'");
group.log(tr("Missing command '%s'"), json["command"]);
return;
}
fn.call(this.commandHandler, json["data"]);
@ -227,17 +227,17 @@ class ServerConnection {
let res = ex;
if(!res.success) {
if(res.id == 2568) { //Permission error
res.message = "Insufficient client permissions. Failed on permission " + this._client.permissions.resolveInfo(res.json["failed_permid"] as number).name;
chat.serverChat().appendError("Insufficient client permissions. Failed on permission {}", this._client.permissions.resolveInfo(res.json["failed_permid"] as number).name);
res.message = tr("Insufficient client permissions. Failed on permission ") + this._client.permissions.resolveInfo(res.json["failed_permid"] as number).name;
chat.serverChat().appendError(tr("Insufficient client permissions. Failed on permission {}"), this._client.permissions.resolveInfo(res.json["failed_permid"] as number).name);
sound.play(Sound.ERROR_INSUFFICIENT_PERMISSIONS);
} else {
chat.serverChat().appendError(res.extra_message.length == 0 ? res.message : res.extra_message);
}
}
} else if(typeof(ex) == "string") {
chat.serverChat().appendError("Command execution results in " + ex);
} else if(typeof(ex) === "string") {
chat.serverChat().appendError(tr("Command execution results in ") + ex);
} else {
console.error("Invalid promise result type: " + typeof (ex) + ". Result:");
console.error(tr("Invalid promise result type: %o. Result:"), typeof (ex));
console.error(ex);
}
}
@ -327,7 +327,7 @@ class HandshakeHandler {
//FIXME handle error this should never happen!
}
this.connection.sendCommand("handshakeindentityproof", {proof: proof}).catch(error => {
console.error("Got login error");
console.error(tr("Got login error"));
console.log(error);
}).then(() => this.handshake_finished()); //TODO handle error
}
@ -337,7 +337,7 @@ class HandshakeHandler {
native.client_version()
.then( this.handshake_finished.bind(this))
.catch(error => {
console.error("Failed to get version:");
console.error(tr("Failed to get version:"));
console.error(error);
this.handshake_finished("?.?.?");
});
@ -493,7 +493,7 @@ class ConnectionCommandHandler {
let code : string = json["return_code"];
if(code.length == 0) {
console.log("Invalid return code! (" + json + ")");
console.log(tr("Invalid return code! (%o)"), json);
return;
}
let retListeners = this.connection["_retListener"];
@ -512,7 +512,7 @@ class ConnectionCommandHandler {
handleCommandServerInit(json){
//We could setup the voice channel
console.log("Setting up voice ");
console.log(tr("Setting up voice"));
this.connection._client.voiceConnection.createSession();
@ -535,7 +535,7 @@ class ConnectionCommandHandler {
chat.serverChat().name = this.connection._client.channelTree.server.properties["virtualserver_name"];
chat.serverChat().appendMessage("Connected as {0}", true, this.connection._client.getClient().createChatTag(true));
chat.serverChat().appendMessage(tr("Connected as {0}"), true, this.connection._client.getClient().createChatTag(true));
sound.play(Sound.CONNECTION_CONNECTED);
globalClient.onConnected();
}
@ -549,14 +549,14 @@ class ConnectionCommandHandler {
let prev = tree.findChannel(json["channel_order"]);
if(!prev && json["channel_order"] != 0) {
if(!ignoreOrder) {
console.error("Invalid channel order id!");
console.error(tr("Invalid channel order id!"));
return;
}
}
let parent = tree.findChannel(json["cpid"]);
if(!parent && json["cpid"] != 0) {
console.error("Invalid channel parent");
console.error(tr("Invalid channel parent"));
return;
}
tree.moveChannel(channel, prev, parent); //TODO test if channel exists!
@ -587,7 +587,7 @@ class ConnectionCommandHandler {
}
handleCommandChannelList(json) {
console.log("Got " + json.length + " new channels");
console.log(tr("Got %d new channels"), json.length);
for(let index = 0; index < json.length; index++)
this.createChannelFromJson(json[index], true);
}
@ -603,11 +603,11 @@ class ConnectionCommandHandler {
handleCommandChannelDelete(json) {
let tree = this.connection._client.channelTree;
console.log("Got " + json.length + " channel deletions");
console.log(tr("Got %d channel deletions"), json.length);
for(let index = 0; index < json.length; index++) {
let channel = tree.findChannel(json[index]["cid"]);
if(!channel) {
console.error("Invalid channel onDelete (Unknown channel)");
console.error(tr("Invalid channel onDelete (Unknown channel)"));
continue;
}
tree.deleteChannel(channel);
@ -617,11 +617,11 @@ class ConnectionCommandHandler {
handleCommandChannelHide(json) {
let tree = this.connection._client.channelTree;
console.log("Got " + json.length + " channel hides");
console.log(tr("Got %d channel hides"), json.length);
for(let index = 0; index < json.length; index++) {
let channel = tree.findChannel(json[index]["cid"]);
if(!channel) {
console.error("Invalid channel on hide (Unknown channel)");
console.error(tr("Invalid channel on hide (Unknown channel)"));
continue;
}
tree.deleteChannel(channel);
@ -659,15 +659,15 @@ class ConnectionCommandHandler {
else
sound.play(Sound.USER_ENTERED_CONNECT);
if(old_channel) {
chat.serverChat().appendMessage("{0} appeared from {1} to {2}", true, client.createChatTag(true), old_channel.createChatTag(true), channel.createChatTag(true));
chat.serverChat().appendMessage(tr("{0} appeared from {1} to {2}"), true, client.createChatTag(true), old_channel.createChatTag(true), channel.createChatTag(true));
} else {
chat.serverChat().appendMessage("{0} connected to channel {1}", true, client.createChatTag(true), channel.createChatTag(true));
chat.serverChat().appendMessage(tr("{0} connected to channel {1}"), true, client.createChatTag(true), channel.createChatTag(true));
}
} else if(json["reasonid"] == ViewReasonId.VREASON_MOVED) {
if(own_channel == channel)
sound.play(Sound.USER_ENTERED_MOVED);
chat.serverChat().appendMessage("{0} appeared from {1} to {2}, moved by {3}", true,
chat.serverChat().appendMessage(tr("{0} appeared from {1} to {2}, moved by {3}"), true,
client.createChatTag(true),
old_channel ? old_channel.createChatTag(true) : undefined,
channel.createChatTag(true),
@ -677,7 +677,7 @@ class ConnectionCommandHandler {
if(own_channel == channel)
sound.play(Sound.USER_ENTERED_KICKED);
chat.serverChat().appendMessage("{0} appeared from {1} to {2}, kicked by {3}{4}", true,
chat.serverChat().appendMessage(tr("{0} appeared from {1} to {2}, kicked by {3}{4}"), true,
client.createChatTag(true),
old_channel ? old_channel.createChatTag(true) : undefined,
channel.createChatTag(true),
@ -685,7 +685,7 @@ class ConnectionCommandHandler {
json["reasonmsg"] > 0 ? " (" + json["msg"] + ")" : ""
);
} else {
console.warn("Unknown reasonid for " + json["reasonid"]);
console.warn(tr("Unknown reasonid for %o"), json["reasonid"]);
}
let updates: {
@ -715,7 +715,7 @@ class ConnectionCommandHandler {
let tree = this.connection._client.channelTree;
let client = tree.findClient(json["clid"]);
if(!client) {
console.error("Unknown client left!");
console.error(tr("Unknown client left!"));
return 0;
}
if(client == this.connection._client.getClient()) {
@ -738,12 +738,12 @@ class ConnectionCommandHandler {
if(json["reasonid"] == ViewReasonId.VREASON_USER_ACTION) {
chat.serverChat().appendMessage("{0} disappeared from {1} to {2}", true, client.createChatTag(true), channel_from.createChatTag(true), channel_to.createChatTag(true));
chat.serverChat().appendMessage(tr("{0} disappeared from {1} to {2}"), true, client.createChatTag(true), channel_from.createChatTag(true), channel_to.createChatTag(true));
if(channel_from == own_channel)
sound.play(Sound.USER_LEFT);
} else if(json["reasonid"] == ViewReasonId.VREASON_SERVER_LEFT) {
chat.serverChat().appendMessage("{0} left the server{1}", true,
chat.serverChat().appendMessage(tr("{0} left the server{1}"), true,
client.createChatTag(true),
json["reasonmsg"] ? " (" + json["reasonmsg"] + ")" : ""
);
@ -751,7 +751,7 @@ class ConnectionCommandHandler {
if(channel_from == own_channel)
sound.play(Sound.USER_LEFT_DISCONNECT);
} else if(json["reasonid"] == ViewReasonId.VREASON_SERVER_KICK) {
chat.serverChat().appendError("{0} was kicked from the server by {1}.{2}",
chat.serverChat().appendError(tr("{0} was kicked from the server by {1}.{2}"),
client.createChatTag(true),
ClientEntry.chatTag(json["invokerid"], json["invokername"], json["invokeruid"]),
json["reasonmsg"] ? " (" + json["reasonmsg"] + ")" : ""
@ -759,7 +759,7 @@ class ConnectionCommandHandler {
if(channel_from == own_channel)
sound.play(Sound.USER_LEFT_KICKED_SERVER);
} else if(json["reasonid"] == ViewReasonId.VREASON_CHANNEL_KICK) {
chat.serverChat().appendError("{0} was kicked from your channel by {1}.{2}",
chat.serverChat().appendError(tr("{0} was kicked from your channel by {1}.{2}"),
client.createChatTag(true),
ClientEntry.chatTag(json["invokerid"], json["invokername"], json["invokeruid"]),
json["reasonmsg"] ? " (" + json["reasonmsg"] + ")" : ""
@ -773,7 +773,7 @@ class ConnectionCommandHandler {
if(json["bantime"])
duration = "for " + formatDate(Number.parseInt(json["bantime"]));
chat.serverChat().appendError("{0} was banned {1} by {2}.{3}",
chat.serverChat().appendError(tr("{0} was banned {1} by {2}.{3}"),
client.createChatTag(true),
duration,
ClientEntry.chatTag(json["invokerid"], json["invokername"], json["invokeruid"]),
@ -783,7 +783,7 @@ class ConnectionCommandHandler {
if(channel_from == own_channel)
sound.play(Sound.USER_LEFT_BANNED);
} else {
console.error("Unknown client left reason!");
console.error(tr("Unknown client left reason!"));
}
tree.deleteClient(client);
@ -797,16 +797,16 @@ class ConnectionCommandHandler {
let channel_from = tree.findChannel(json["cfid"]);
if(!client) {
console.error("Unknown client move (Client)!");
console.error(tr("Unknown client move (Client)!"));
return 0;
}
if(!channel_to) {
console.error("Unknown client move (Channel to)!");
console.error(tr("Unknown client move (Channel to)!"));
return 0;
}
if(!channel_from) //Not critical
console.error("Unknown client move (Channel from)!");
console.error(tr("Unknown client move (Channel from)!"));
let self = client instanceof LocalClientEntry;
let current_clients;
@ -822,7 +822,7 @@ class ConnectionCommandHandler {
const own_channel = this.connection._client.getClient().currentChannel();
if(json["reasonid"] == ViewReasonId.VREASON_MOVED) {
chat.serverChat().appendMessage(self ? "You was moved by {3} from channel {1} to {2}" : "{0} was moved from channel {1} to {2} by {3}", true,
chat.serverChat().appendMessage(self ? tr("You was moved by {3} from channel {1} to {2}") : tr("{0} was moved from channel {1} to {2} by {3}"), true,
client.createChatTag(true),
channel_from ? channel_from.createChatTag(true) : undefined,
channel_to.createChatTag(true),
@ -835,7 +835,7 @@ class ConnectionCommandHandler {
else if(own_channel == channel_from)
sound.play(Sound.USER_LEFT_MOVED);
} else if(json["reasonid"] == ViewReasonId.VREASON_USER_ACTION) {
chat.serverChat().appendMessage(self ? "You switched from channel {1} to {2}" : "{0} switched from channel {1} to {2}", true,
chat.serverChat().appendMessage(self ? tr("You switched from channel {1} to {2}") : tr("{0} switched from channel {1} to {2}"), true,
client.createChatTag(true),
channel_from ? channel_from.createChatTag(true) : undefined,
channel_to.createChatTag(true)
@ -846,7 +846,7 @@ class ConnectionCommandHandler {
else if(own_channel == channel_from)
sound.play(Sound.USER_LEFT);
} else if(json["reasonid"] == ViewReasonId.VREASON_CHANNEL_KICK) {
chat.serverChat().appendMessage(self ? "You got kicked out of the channel {1} to channel {2} by {3}{4}" : "{0} got kicked from channel {1} to {2} by {3}{4}", true,
chat.serverChat().appendMessage(self ? tr("You got kicked out of the channel {1} to channel {2} by {3}{4}") : tr("{0} got kicked from channel {1} to {2} by {3}{4}"), true,
client.createChatTag(true),
channel_from ? channel_from.createChatTag(true) : undefined,
channel_to.createChatTag(true),
@ -860,7 +860,7 @@ class ConnectionCommandHandler {
else if(own_channel == channel_from)
sound.play(Sound.USER_LEFT_KICKED_CHANNEL);
} else {
console.warn("Unknown reason id " + json["reasonid"]);
console.warn(tr("Unknown reason id %o"), json["reasonid"]);
}
}
@ -872,19 +872,19 @@ class ConnectionCommandHandler {
let tree = this.connection._client.channelTree;
let channel = tree.findChannel(json["cid"]);
if(!channel) {
console.error("Unknown channel move (Channel)!");
console.error(tr("Unknown channel move (Channel)!"));
return 0;
}
let prev = tree.findChannel(json["order"]);
if(!prev && json["order"] != 0) {
console.error("Unknown channel move (prev)!");
console.error(tr("Unknown channel move (prev)!"));
return 0;
}
let parent = tree.findChannel(json["cpid"]);
if(!parent && json["cpid"] != 0) {
console.error("Unknown channel move (parent)!");
console.error(tr("Unknown channel move (parent)!"));
return 0;
}
@ -897,7 +897,7 @@ class ConnectionCommandHandler {
let tree = this.connection._client.channelTree;
let channel = tree.findChannel(json["cid"]);
if(!channel) {
console.error("Unknown channel edit (Channel)!");
console.error(tr("Unknown channel edit (Channel)!"));
return 0;
}
@ -925,11 +925,11 @@ class ConnectionCommandHandler {
let invoker = this.connection._client.channelTree.findClient(json["invokerid"]);
let target = this.connection._client.channelTree.findClient(json["target"]);
if(!invoker) { //TODO spawn chat (Client is may invisible)
console.error("Got private message from invalid client!");
console.error(tr("Got private message from invalid client!"));
return;
}
if(!target) { //TODO spawn chat (Client is may invisible)
console.error("Got private message from invalid client!");
console.error(tr("Got private message from invalid client!"));
return;
}
if(invoker == this.connection._client.getClient()) {
@ -955,7 +955,7 @@ class ConnectionCommandHandler {
let client = this.connection._client.channelTree.findClient(json["clid"]);
if(!client) {
console.error("Tried to update an non existing client");
console.error(tr("Tried to update an non existing client"));
return;
}
@ -1018,7 +1018,7 @@ class ConnectionCommandHandler {
let bot = this.connection._client.channelTree.find_client_by_dbid(json["botid"]);
if(!bot || !(bot instanceof MusicClientEntry)) {
log.warn(LogCategory.CLIENT, "Got music player info for unknown or invalid bot! (ID: %i, Entry: %o)", json["botid"], bot);
log.warn(LogCategory.CLIENT, tr("Got music player info for unknown or invalid bot! (ID: %i, Entry: %o)"), json["botid"], bot);
return;
}

View File

@ -0,0 +1,8 @@
namespace i18n {
export function tr(message: string, key?: string) {
console.log("Translating \"%s\". Default: \"%s\"", key, message);
return message;
}
}
const tr: typeof i18n.tr = i18n.tr;

View File

@ -1,3 +1,5 @@
//FIXME fix display critical error before load
namespace app {
export enum Type {
UNDEFINED,
@ -157,6 +159,7 @@ function loadDebug() {
["wasm/TeaWeb-Identity.js"],
//Load general API's
"js/i18n/localize.js",
"js/log.js",
"js/sound/Sounds.js",

View File

@ -17,6 +17,7 @@ namespace log {
ERROR
}
//TODO add translation
let category_mapping = new Map<number, string>([
[LogCategory.CHANNEL, "Channel "],
[LogCategory.CLIENT, "Client "],

View File

@ -92,7 +92,10 @@ function main() {
//http://localhost:63343/Web-Client/index.php?_ijt=omcpmt8b9hnjlfguh8ajgrgolr&default_connect_url=true&default_connect_type=teamspeak&default_connect_url=localhost%3A9987&disableUnloadDialog=1&loader_ignore_age=1
AudioController.initializeAudioController();
if(!TSIdentityHelper.setup()) { console.error("Could not setup the TeamSpeak identity parser!"); return; }
if(!TSIdentityHelper.setup()) {
console.error(tr( "Could not setup the TeamSpeak identity parser!"));
return;
}
settings = new Settings();
globalClient = new TSClient();
@ -144,7 +147,7 @@ function main() {
}
ppt.initialize().catch(error => {
console.error("Failed to initialize ppt!");
console.error(tr("Failed to initialize ppt!"));
//TODO error notification?
});
@ -180,9 +183,9 @@ app.loadedListener.push(() => {
try {
main();
if(!audio.player.initialized()) {
log.info(LogCategory.VOICE, "Initialize audio controller later!");
log.info(LogCategory.VOICE, tr("Initialize audio controller later!"));
if(!audio.player.initializeFromGesture) {
console.error("Missing audio.player.initializeFromGesture");
console.error(tr("Missing audio.player.initializeFromGesture"));
} else
$(document).one('click', event => audio.player.initializeFromGesture());
}

View File

@ -112,7 +112,7 @@ class GroupManager {
if(json[0]["sgid"]) target = GroupTarget.SERVER;
else if(json[0]["cgid"]) target = GroupTarget.CHANNEL;
else {
console.error("Could not resolve group target! => " + json[0]);
console.error(tr("Could not resolve group target! => %o"), json[0]);
return;
}
@ -128,6 +128,7 @@ class GroupManager {
case 1: type = GroupType.NORMAL; break;
case 2: type = GroupType.QUERY; break;
default:
//TODO tr
console.error("Invalid group type: " + groupData["type"] + " for group " + groupData["name"]);
continue;
}
@ -179,7 +180,7 @@ class GroupManager {
private onPermissionList(json: any[]) {
let group = json[0]["sgid"] ? this.serverGroup(parseInt(json[0]["sgid"])) : this.channelGroup(parseInt(json[0]["cgid"]));
if(!group) {
log.error(LogCategory.PERMISSIONS, "Got group permissions for group %o/%o, but its not a registered group!", json[0]["sgid"], json[0]["cgid"]);
log.error(LogCategory.PERMISSIONS, tr("Got group permissions for group %o/%o, but its not a registered group!"), json[0]["sgid"], json[0]["cgid"]);
return;
}
let requests: GroupPermissionRequest[] = [];
@ -188,7 +189,7 @@ class GroupManager {
requests.push(req);
if(requests.length == 0) {
log.warn(LogCategory.PERMISSIONS, "Got group permissions for group %o/%o, but it was never requested!", json[0]["sgid"], json[0]["cgid"]);
log.warn(LogCategory.PERMISSIONS, tr("Got group permissions for group %o/%o, but it was never requested!"), json[0]["sgid"], json[0]["cgid"]);
return;
}

View File

@ -323,7 +323,7 @@ class PermissionValue {
granted(requiredValue: number, required: boolean = true) : boolean {
let result;
result = this.value == -1 || this.value >= requiredValue || (this.value == -2 && requiredValue == -2 && !required);
log.trace(LogCategory.PERMISSIONS, "Test needed required: %o | %i | %o => " + result , this, requiredValue, required);
log.trace(LogCategory.PERMISSIONS, tr("Test needed required: %o | %i | %o => %o"), this, requiredValue, required, result);
return result;
}
@ -368,6 +368,7 @@ class PermissionManager {
private _cacheNeededPermissions: any;
/* Static info mapping until TeaSpeak implements a detailed info */
//TODO tr
static readonly group_mapping: {name: string, deep: number}[] = [
{name: "Global", deep: 0},
{name: "Information", deep: 1},
@ -409,7 +410,7 @@ class PermissionManager {
let perm_info = manager.resolveInfo(perm_id);
if(!perm_info) {
log.warn(LogCategory.PERMISSIONS, "Got unknown permission id (%o/%o (%o))!", perm["permid"], perm_id, perm["permsid"]);
log.warn(LogCategory.PERMISSIONS, tr("Got unknown permission id (%o/%o (%o))!"), perm["permid"], perm_id, perm["permsid"]);
return;
}
@ -459,14 +460,14 @@ class PermissionManager {
this.permissionGroups = [];
this._group_mapping = PermissionManager.group_mapping.slice();
let group = log.group(log.LogType.TRACE, LogCategory.PERMISSIONS, "Permission mapping");
let group = log.group(log.LogType.TRACE, LogCategory.PERMISSIONS, tr("Permission mapping"));
for(let e of json) {
if(e["group_id_end"]) {
let group = new PermissionGroup();
group.begin = this.permissionGroups.length ? this.permissionGroups.last().end : 0;
group.end = parseInt(e["group_id_end"]);
group.deep = 0;
group.name = "Group " + e["group_id_end"];
group.name = tr("Group ") + e["group_id_end"];
let info = this._group_mapping.pop_front();
if(info) {
@ -480,12 +481,12 @@ class PermissionManager {
perm.name = e["permname"];
perm.id = parseInt(e["permid"]);
perm.description = e["permdesc"];
group.log("%i <> %s -> %s", perm.id, perm.name, perm.description);
group.log(tr("%i <> %s -> %s"), perm.id, perm.name, perm.description);
this.permissionList.push(perm);
}
group.end();
log.info(LogCategory.PERMISSIONS, "Got %i permissions", this.permissionList.length);
log.info(LogCategory.PERMISSIONS, tr("Got %i permissions"), this.permissionList.length);
if(this._cacheNeededPermissions)
this.onNeededPermissions(this._cacheNeededPermissions);
for(let listener of this.initializedListener)
@ -494,7 +495,7 @@ class PermissionManager {
private onNeededPermissions(json) {
if(this.permissionList.length == 0) {
log.warn(LogCategory.PERMISSIONS, "Got needed permissions but don't have a permission list!");
log.warn(LogCategory.PERMISSIONS, tr("Got needed permissions but don't have a permission list!"));
this._cacheNeededPermissions = json;
return;
}
@ -503,7 +504,7 @@ class PermissionManager {
let copy = this.neededPermissions.slice();
let addcount = 0;
let group = log.group(log.LogType.TRACE, LogCategory.PERMISSIONS, "Got " + json.length + " needed permissions.");
let group = log.group(log.LogType.TRACE, LogCategory.PERMISSIONS, tr("Got %d needed permissions."), json.length);
for(let e of json) {
let entry: NeededPermissionValue = undefined;
for(let p of copy) {
@ -519,7 +520,7 @@ class PermissionManager {
entry = new NeededPermissionValue(info, -2);
this.neededPermissions.push(entry);
} else {
log.warn(LogCategory.PERMISSIONS, "Could not resolve perm for id %s (%o|%o)", e["permid"], e, info);
log.warn(LogCategory.PERMISSIONS, tr("Could not resolve perm for id %s (%o|%o)"), e["permid"], e, info);
continue;
}
addcount++;
@ -527,12 +528,15 @@ class PermissionManager {
if(entry.value == parseInt(e["permvalue"])) continue;
entry.value = parseInt(e["permvalue"]);
//TODO tr
group.log("Update needed permission " + entry.type.name + " to " + entry.value);
for(let listener of entry.changeListener)
listener(entry.value);
}
group.end();
//TODO tr
log.debug(LogCategory.PERMISSIONS, "Dropping " + copy.length + " needed permissions and added " + addcount + " permissions.");
for(let e of copy) {
e.value = -2;
@ -545,7 +549,7 @@ class PermissionManager {
let channelId: number = parseInt(json[0]["cid"]);
let permissions = PermissionManager.parse_permission_bulk(json, this.handle.permissions);
log.debug(LogCategory.PERMISSIONS, "Got channel permissions for channel %o", channelId);
log.debug(LogCategory.PERMISSIONS, tr("Got channel permissions for channel %o"), channelId);
for(let element of this.requests_channel_permissions) {
if(element.channel_id == channelId) {
for(let l of element.callback_success)
@ -554,7 +558,7 @@ class PermissionManager {
return;
}
}
log.debug(LogCategory.PERMISSIONS, "Missing channel permission handle for requested channel id %o", channelId);
log.debug(LogCategory.PERMISSIONS, tr("Missing channel permission handle for requested channel id %o"), channelId);
}
resolveInfo?(key: number | string | PermissionType) : PermissionInfo {
@ -640,10 +644,10 @@ class PermissionManager {
for(let perm of this.neededPermissions)
if(perm.type.id == key || perm.type.name == key || perm.type == key)
return perm;
log.debug(LogCategory.PERMISSIONS, "Could not resolve grant permission %o. Creating a new one.", key);
log.debug(LogCategory.PERMISSIONS, tr("Could not resolve grant permission %o. Creating a new one."), key);
let info = key instanceof PermissionInfo ? key : this.resolveInfo(key);
if(!info) {
log.warn(LogCategory.PERMISSIONS, "Requested needed permission with invalid key! (%o)", key);
log.warn(LogCategory.PERMISSIONS, tr("Requested needed permission with invalid key! (%o)"), key);
return undefined;
}
let result = new NeededPermissionValue(info, -2);
@ -665,7 +669,7 @@ class PermissionManager {
result.push(current);
} else {
if(!current) {
throw "invalid order!";
throw tr("invalid order!");
} else {
while(group.deep <= current.group.deep)
current = current.parent;

View File

@ -45,11 +45,11 @@ if(!JSON.map_to) {
for (let field of variables) {
if (!json[field]) {
console.trace("Json does not contains %s", field);
console.trace(tr("Json does not contains %s"), field);
continue;
}
if (!validator(field, json[field])) {
console.trace("Validator results in false for %s", field);
console.trace(tr("Validator results in false for %s"), field);
continue;
}
@ -68,7 +68,7 @@ if(!JSON.map_field_to) {
object[field as string] = parseFloat(value);
else if(field_type == "boolean")
object[field as string] = value == "1" || value == "true";
else console.warn("Invalid object type %s for entry %s", field_type, field);
else console.warn(tr("Invalid object type %s for entry %s"), field_type, field);
return object;
}
@ -163,17 +163,17 @@ function formatDate(secs: number) : string {
let result = "";
if(years > 0)
result += years + " years ";
result += years + " " + tr("years") + " ";
if(years > 0 || days > 0)
result += days + " days ";
result += days + " " + tr("days") + " ";
if(years > 0 || days > 0 || hours > 0)
result += hours + " hours ";
result += hours + " " + tr("hours") + " ";
if(years > 0 || days > 0 || hours > 0 || minutes > 0)
result += minutes + " minutes ";
result += minutes + " " + tr("minutes") + " ";
if(years > 0 || days > 0 || hours > 0 || minutes > 0 || seconds > 0)
result += seconds + " seconds ";
result += seconds + " " + tr("seconds") + " ";
else
result = "now ";
result = tr("now") + " ";
return result.substr(0, result.length - 1);
}

View File

@ -119,10 +119,10 @@ namespace sound {
export function play(sound: Sound, options?: {
background_notification?: boolean
}) {
console.log("playback sound " + sound);
console.log(tr("playback sound %o"), sound);
const file: SpeechFile = speech_mapping[sound];
if(!file) {
console.warn("Missing sound " + sound);
console.warn(tr("Missing sound %o"), sound);
return;
}
if(file.not_supported) {
@ -138,7 +138,7 @@ namespace sound {
if(context.decodeAudioData) {
if(file.cached) {
console.log("Using cached buffer: %o", file.cached);
console.log(tr("Using cached buffer: %o"), file.cached);
const player = context.createBufferSource();
player.buffer = file.cached;
player.start(0);
@ -158,13 +158,13 @@ namespace sound {
const decode_data = buffer => {
console.log(buffer);
try {
console.log("Decoding data");
console.log(tr("Decoding data"));
context.decodeAudioData(buffer, result => {
console.log("Got decoded data");
console.log(tr("Got decoded data"));
file.cached = result;
play(sound, options);
}, error => {
console.error("Failed to decode audio data for " + sound);
console.error(tr("Failed to decode audio data for %o"), sound);
console.error(error);
file.not_supported = true;
file.not_supported_timeout = Date.now() + 1000 * 60 * 60; //Try in 2min again!
@ -184,14 +184,14 @@ namespace sound {
if (this.status == 200) {
decode_data(this.response);
} else {
console.error("Failed to load audio file. (Response code " + this.status + ")");
console.error(tr("Failed to load audio file. (Response code %o)"), this.status);
file.not_supported = true;
file.not_supported_timeout = Date.now() + 1000 * 60 * 60; //Try in 2min again!
}
};
xhr.onerror = error => {
console.error("Failed to load audio file " + sound);
console.error(tr("Failed to load audio file "), sound);
console.error(error);
file.not_supported = true;
file.not_supported_timeout = Date.now() + 1000 * 60 * 60; //Try in 2min again!
@ -200,14 +200,14 @@ namespace sound {
xhr.send();
}
} else {
console.log("Replaying " + path);
console.log(tr("Replaying %s"), path);
if(file.node) {
file.node.currentTime = 0;
file.node.play();
} else {
if(!warned) {
warned = true;
console.warn("Your browser does not support decodeAudioData! Using a node to playback! This bypasses the audio output and volume regulation!");
console.warn(tr("Your browser does not support decodeAudioData! Using a node to playback! This bypasses the audio output and volume regulation!"));
}
const container = $("#sounds");
const node = $.spawn("audio").attr("src", path);

View File

@ -377,21 +377,21 @@ class ChannelEntry {
spawn_context_menu(x, y, {
type: MenuEntryType.ENTRY,
icon: "client-channel_switch",
name: "<b>Switch to channel</b>",
name: tr("<b>Switch to channel</b>"),
callback: () => this.joinChannel()
},
MenuEntry.HR(),
{
type: MenuEntryType.ENTRY,
icon: "client-channel_edit",
name: "Edit channel",
name: tr("Edit channel"),
invalidPermission: !channelModify,
callback: () => {
Modals.createChannelModal(this, undefined, this.channelTree.client.permissions, (changes?, permissions?) => {
if(changes) {
changes["cid"] = this.channelId;
this.channelTree.client.serverConnection.sendCommand("channeledit", changes);
log.info(LogCategory.CHANNEL, "Changed channel properties of channel %s: %o", this.channelName(), changes);
log.info(LogCategory.CHANNEL, tr("Changed channel properties of channel %s: %o"), this.channelName(), changes);
}
if(permissions && permissions.length > 0) {
@ -416,7 +416,7 @@ class ChannelEntry {
{
type: MenuEntryType.ENTRY,
icon: "client-channel_delete",
name: "Delete channel",
name: tr("Delete channel"),
invalidPermission: !flagDelete,
callback: () => {
this.channelTree.client.serverConnection.sendCommand("channeldelete", {cid: this.channelId}).then(() => {
@ -428,15 +428,17 @@ class ChannelEntry {
{
type: MenuEntryType.ENTRY,
icon: "client-addon-collection",
name: "Create music bot",
name: tr("Create music bot"),
callback: () => {
this.channelTree.client.serverConnection.sendCommand("musicbotcreate", {cid: this.channelId}).then(() => {
createInfoModal("Bot successfully created", "But has been successfully created.").open();
createInfoModal(tr("Bot successfully created"), tr("But has been successfully created.")).open();
}).catch(error => {
if(error instanceof CommandResult) {
error = error.extra_message || error.message;
}
createErrorModal("Failed to create bot", "Failed to create the music bot:<br>" + error).open();
//TODO tr
createErrorModal(tr("Failed to create bot"), "Failed to create the music bot:<br>" + error).open();
});
}
},
@ -444,13 +446,13 @@ class ChannelEntry {
{
type: MenuEntryType.ENTRY,
icon: "client-channel_create_sub",
name: "Create sub channel",
name: tr("Create sub channel"),
invalidPermission: !(channelCreate && this.channelTree.client.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_CHILD).granted(1)),
callback: () => this.channelTree.spawnCreateChannel(this)
}, {
type: MenuEntryType.ENTRY,
icon: "client-channel_create",
name: "Create channel",
name: tr("Create channel"),
invalidPermission: !channelCreate,
callback: () => this.channelTree.spawnCreateChannel()
},
@ -473,7 +475,7 @@ class ChannelEntry {
if(options.indexOf("spacer") == -1) break parseType;
options = options.substr(0, options.indexOf("spacer"));
console.log("Channel options: '" + options + "'");
console.log(tr("Channel options: '%o'"), options);
if(options.length == 0) options = "l";
else if(options.length > 1) options = options[0];
@ -482,7 +484,7 @@ class ChannelEntry {
else break parseType;
this._formatedChannelName = this.properties.channel_name.substr(end + 1);
console.log("Got channel name: " + this._formatedChannelName);
console.log(tr("Got channel name: %o"), this._formatedChannelName);
}
let self = this.channelTag();
@ -505,25 +507,25 @@ class ChannelEntry {
do {
channelName.text(name = name + name);
} while (channelName.parent().width() >= channelName.width() && ++index < 64);
if(index == 64) console.warn(LogCategory.CHANNEL, "Repeating spacer took too much repeats!");
if(index == 64) console.warn(LogCategory.CHANNEL, tr("Repeating spacer took too much repeats!"));
if(lastSuccess.length > 0) {
channelName.text(lastSuccess);
self.addClass("c");
}
}
}
console.log("Align: " + this._channelAlign);
console.log(tr("Align: %s"), this._channelAlign);
}
updateVariables(...variables: {key: string, value: string}[]) {
let group = log.group(log.LogType.DEBUG, LogCategory.CHANNEL, "Update properties (%i) of %s (%i)", variables.length, this.channelName(), this.getChannelId());
let group = log.group(log.LogType.DEBUG, LogCategory.CHANNEL, tr("Update properties (%i) of %s (%i)"), variables.length, this.channelName(), this.getChannelId());
for(let variable of variables) {
let key = variable.key;
let value = variable.value;
JSON.map_field_to(this.properties, value, variable.key);
group.log("Updating property " + key + " = '%s' -> %o", value, this.properties[key]);
group.log(tr("Updating property %s = '%s' -> %o"), key, value, this.properties[key]);
if(key == "channel_name") {
this.__updateChannelName();
@ -611,7 +613,7 @@ class ChannelEntry {
if(this.properties.channel_flag_password == true &&
!this._cachedPassword &&
!this.channelTree.client.permissions.neededPermission(PermissionType.B_CHANNEL_JOIN_IGNORE_PASSWORD).granted(1)) {
createInputModal("Channel password", "Channel password:", () => true, text => {
createInputModal(tr("Channel password"), tr("Channel password:"), () => true, text => {
if(typeof(text) == typeof(true)) return;
helpers.hashPassword(text as string).then(result => {
this._cachedPassword = result;
@ -638,7 +640,6 @@ function chat_channel_contextmenu(_element: any, event: any) {
event.preventDefault();
let element = $(_element);
console.log("Context menue for " + element.attr("channelName"));
let chid : number = Number.parseInt(element.attr("channelId"));
let channel = globalClient.channelTree.findChannel(chid);
if(!channel) {

View File

@ -209,7 +209,7 @@ class ClientEntry {
return [{
type: MenuEntryType.SUB_MENU,
icon: "client-permission_server_groups",
name: "Set server group",
name: tr("Set server group"),
sub_menu: [
{
type: MenuEntryType.ENTRY,
@ -236,14 +236,14 @@ class ClientEntry {
},{
type: MenuEntryType.SUB_MENU,
icon: "client-permission_channel",
name: "Set channel group",
name: tr("Set channel group"),
sub_menu: [
...channel_groups
]
},{
type: MenuEntryType.SUB_MENU,
icon: "client-permission_client",
name: "Permissions",
name: tr("Permissions"),
disabled: true,
sub_menu: [ ]
}];
@ -256,7 +256,7 @@ class ClientEntry {
{
type: MenuEntryType.ENTRY,
icon: "client-change_nickname",
name: "<b>Open text chat</b>",
name: tr("<b>Open text chat</b>"),
callback: function () {
chat.activeChat = _this.chat(true);
chat.focus();
@ -264,10 +264,11 @@ class ClientEntry {
}, {
type: MenuEntryType.ENTRY,
icon: "client-poke",
name: "Poke client",
name: tr("Poke client"),
callback: function () {
createInputModal("Poke client", "Poke message:<br>", text => true, result => {
createInputModal(tr("Poke client"), tr("Poke message:<br>"), text => true, result => {
if(typeof(result) === "string") {
//TODO tr
console.log("Poking client " + _this.clientNickName() + " with message " + result);
_this.channelTree.client.serverConnection.sendCommand("clientpoke", {
clid: _this.clientId(),
@ -280,10 +281,11 @@ class ClientEntry {
}, {
type: MenuEntryType.ENTRY,
icon: "client-edit",
name: "Change description",
name: tr("Change description"),
callback: function () {
createInputModal("Change client description", "New description:<br>", text => true, result => {
createInputModal(tr("Change client description"), tr("New description:<br>"), text => true, result => {
if(typeof(result) === "string") {
//TODO tr
console.log("Changing " + _this.clientNickName() + "'s description to " + result);
_this.channelTree.client.serverConnection.sendCommand("clientedit", {
clid: _this.clientId(),
@ -299,7 +301,7 @@ class ClientEntry {
MenuEntry.HR(), {
type: MenuEntryType.ENTRY,
icon: "client-move_client_to_own_channel",
name: "Move client to your channel",
name: tr("Move client to your channel"),
callback: () => {
this.channelTree.client.serverConnection.sendCommand("clientmove", {
clid: this.clientId(),
@ -309,10 +311,11 @@ class ClientEntry {
}, {
type: MenuEntryType.ENTRY,
icon: "client-kick_channel",
name: "Kick client from channel",
name: tr("Kick client from channel"),
callback: () => {
createInputModal("Kick client from channel", "Kick reason:<br>", text => true, result => {
createInputModal(tr("Kick client from channel"), tr("Kick reason:<br>"), text => true, result => {
if(result) {
//TODO tr
console.log("Kicking client " + _this.clientNickName() + " from channel with reason " + result);
_this.channelTree.client.serverConnection.sendCommand("clientkick", {
clid: _this.clientId(),
@ -326,10 +329,11 @@ class ClientEntry {
}, {
type: MenuEntryType.ENTRY,
icon: "client-kick_server",
name: "Kick client fom server",
name: tr("Kick client fom server"),
callback: () => {
createInputModal("Kick client from server", "Kick reason:<br>", text => true, result => {
createInputModal(tr("Kick client from server"), tr("Kick reason:<br>"), text => true, result => {
if(result) {
//TODO tr
console.log("Kicking client " + _this.clientNickName() + " from server with reason " + result);
_this.channelTree.client.serverConnection.sendCommand("clientkick", {
clid: _this.clientId(),
@ -343,7 +347,7 @@ class ClientEntry {
}, {
type: MenuEntryType.ENTRY,
icon: "client-ban_client",
name: "Ban client",
name: tr("Ban client"),
invalidPermission: !this.channelTree.client.permissions.neededPermission(PermissionType.I_CLIENT_BAN_MAX_BANTIME).granted(1),
callback: () => {
Modals.spawnBanClient(this.properties.client_nickname, (data) => {
@ -379,7 +383,7 @@ class ClientEntry {
{
type: MenuEntryType.ENTRY,
icon: "client-volume",
name: "Change Volume",
name: tr("Change Volume"),
callback: () => {
Modals.spawnChangeVolume(this.audioController.volume, volume => {
settings.changeServer("volume_client_" + this.clientUid(), volume);
@ -519,7 +523,7 @@ class ClientEntry {
}
updateVariables(...variables: {key: string, value: string}[]) {
let group = log.group(log.LogType.DEBUG, LogCategory.CLIENT, "Update properties (%i) of %s (%i)", variables.length, this.clientNickName(), this.clientId());
let group = log.group(log.LogType.DEBUG, LogCategory.CLIENT, tr("Update properties (%i) of %s (%i)"), variables.length, this.clientNickName(), this.clientId());
let update_icon_status = false;
let update_icon_speech = false;
@ -529,6 +533,7 @@ class ClientEntry {
for(let variable of variables) {
JSON.map_field_to(this._properties, variable.value, variable.key);
//TODO tr
group.log("Updating client " + this.clientId() + ". Key " + variable.key + " Value: '" + variable.value + "' (" + typeof (this.properties[variable.key]) + ")");
if(variable.key == "client_nickname") {
this.tag.find(".name").text(variable.value);
@ -545,6 +550,7 @@ class ClientEntry {
}
if(variable.key == "client_unique_identifier") {
this.audioController.volume = parseFloat(settings.server("volume_client_" + this.clientUid(), "1"));
//TODO tr
console.error("Updated volume from config " + this.audioController.volume + " - " + "volume_client_" + this.clientUid() + " - " + settings.server("volume_client_" + this.clientUid(), "1"));
console.log(this.avatarId());
}
@ -705,17 +711,17 @@ class LocalClientEntry extends ClientEntry {
spawn_context_menu(x, y,
{
name: "<b>Change name</b>",
name: tr("<b>Change name</b>"),
icon: "client-change_nickname",
callback: () =>_self.openRename(),
type: MenuEntryType.ENTRY
}, {
name: "Change description",
name: tr("Change description"),
icon: "client-edit",
callback: () => {
createInputModal("Change own description", "New description:<br>", text => true, result => {
createInputModal(tr("Change own description"), tr("New description:<br>"), text => true, result => {
if(result) {
console.log("Changing own description to " + result);
console.log(tr("Changing own description to %s"), result);
_self.channelTree.client.serverConnection.sendCommand("clientedit", {
clid: _self.clientId(),
client_description: result
@ -773,9 +779,9 @@ class LocalClientEntry extends ClientEntry {
elm.text(_self.clientNickName());
_self.handle.serverConnection.updateClient("client_nickname", text).then((e) => {
chat.serverChat().appendMessage("Nickname successfully changed");
chat.serverChat().appendMessage(tr("Nickname successfully changed"));
}).catch((e: CommandResult) => {
chat.serverChat().appendError("Could not change nickname (" + e.extra_message + ")");
chat.serverChat().appendError(tr("Could not change nickname ({})"), e.extra_message);
_self.openRename();
});
});
@ -825,11 +831,11 @@ class MusicClientEntry extends ClientEntry {
showContextMenu(x: number, y: number, on_close: () => void = undefined): void {
spawn_context_menu(x, y,
{
name: "<b>Change bot name</b>",
name: tr("<b>Change bot name</b>"),
icon: "client-change_nickname",
disabled: false,
callback: () => {
createInputModal("Change music bots nickname", "New nickname:<br>", text => text.length >= 3 && text.length <= 31, result => {
createInputModal(tr("Change music bots nickname"), tr("New nickname:<br>"), text => text.length >= 3 && text.length <= 31, result => {
if(result) {
this.channelTree.client.serverConnection.sendCommand("clientedit", {
clid: this.clientId(),
@ -841,11 +847,11 @@ class MusicClientEntry extends ClientEntry {
},
type: MenuEntryType.ENTRY
}, {
name: "Change bot description",
name: tr("Change bot description"),
icon: "client-edit",
disabled: false,
callback: () => {
createInputModal("Change music bots description", "New description:<br>", text => true, result => {
createInputModal(tr("Change music bots description"), tr("New description:<br>"), text => true, result => {
if(typeof(result) === 'string') {
this.channelTree.client.serverConnection.sendCommand("clientedit", {
clid: this.clientId(),
@ -857,17 +863,17 @@ class MusicClientEntry extends ClientEntry {
},
type: MenuEntryType.ENTRY
}, {
name: "Open music panel",
name: tr("Open music panel"),
icon: "client-edit",
disabled: true,
callback: () => {},
type: MenuEntryType.ENTRY
}, {
name: "Quick url replay",
name: tr("Quick url replay"),
icon: "client-edit",
disabled: false,
callback: () => {
createInputModal("Please enter the URL", "URL:", text => true, result => {
createInputModal(tr("Please enter the URL"), tr("URL:"), text => true, result => {
if(result) {
this.channelTree.client.serverConnection.sendCommand("musicbotqueueadd", {
bot_id: this.properties.client_database_id,
@ -877,7 +883,8 @@ class MusicClientEntry extends ClientEntry {
if(error instanceof CommandResult) {
error = error.extra_message || error.message;
}
createErrorModal("Failed to replay url", "Failed to enqueue url:<br>" + error).open();
//TODO tr
createErrorModal(tr("Failed to replay url"), "Failed to enqueue url:<br>" + error).open();
});
}
}, { width: 400, maxLength: 255 }).open();
@ -889,7 +896,7 @@ class MusicClientEntry extends ClientEntry {
MenuEntry.HR(),{
type: MenuEntryType.ENTRY,
icon: "client-move_client_to_own_channel",
name: "Move client to your channel",
name: tr("Move client to your channel"),
callback: () => {
this.channelTree.client.serverConnection.sendCommand("clientmove", {
clid: this.clientId(),
@ -899,11 +906,11 @@ class MusicClientEntry extends ClientEntry {
}, {
type: MenuEntryType.ENTRY,
icon: "client-kick_channel",
name: "Kick client from channel",
name: tr("Kick client from channel"),
callback: () => {
createInputModal("Kick client from channel", "Kick reason:<br>", text => true, result => {
createInputModal(tr("Kick client from channel"), tr("Kick reason:<br>"), text => true, result => {
if(result) {
console.log("Kicking client " + this.clientNickName() + " from channel with reason " + result);
console.log(tr("Kicking client %o from channel with reason %o"), this.clientNickName(), result);
this.channelTree.client.serverConnection.sendCommand("clientkick", {
clid: this.clientId(),
reasonid: ViewReasonId.VREASON_CHANNEL_KICK,
@ -917,7 +924,7 @@ class MusicClientEntry extends ClientEntry {
{
type: MenuEntryType.ENTRY,
icon: "client-volume",
name: "Change Volume",
name: tr("Change Volume"),
callback: () => {
Modals.spawnChangeVolume(this.audioController.volume, volume => {
settings.changeServer("volume_client_" + this.clientUid(), volume);
@ -929,12 +936,12 @@ class MusicClientEntry extends ClientEntry {
},
MenuEntry.HR(),
{
name: "Delete bot",
name: tr("Delete bot"),
icon: "client-delete",
disabled: false,
callback: () => {
const tag = $.spawn("div").append(MessageHelper.formatMessage("Do you really want to delete {0}", this.createChatTag(false)));
Modals.spawnYesNo("Are you sure?", $.spawn("div").append(tag), result => {
const tag = $.spawn("div").append(MessageHelper.formatMessage(tr("Do you really want to delete {0}"), this.createChatTag(false)));
Modals.spawnYesNo(tr("Are you sure?"), $.spawn("div").append(tag), result => {
if(result) {
this.channelTree.client.serverConnection.sendCommand("musicbotdelete", {
bot_id: this.properties.client_database_id

View File

@ -25,7 +25,7 @@ class ClientMover {
this.selected_client = client;
this.callback = callback;
console.log("Starting mouse move");
console.log(tr("Starting mouse move"));
ClientMover.listener_root.on('mouseup', this._bound_finish = this.finish_listener.bind(this)).on('mousemove', this._bound_move = this.move_listener.bind(this));

View File

@ -77,7 +77,7 @@ class ControlBar {
}
on_away_set_message() {
createInputModal("Set away message", "Please enter the away message", message => true, message => {
createInputModal(tr("Set away message"), tr("Please enter the away message"), message => true, message => {
if(message)
this.away = message;
}).open();
@ -198,7 +198,7 @@ class ControlBar {
});
if(!this.codec_supported)
createErrorModal("Channel codec unsupported", "This channel has an unsupported codec.<br>You cant speak or listen to anybody within this channel!").open();
createErrorModal(tr("Channel codec unsupported"), tr("This channel has an unsupported codec.<br>You cant speak or listen to anybody within this channel!")).open();
/* Update these properties anyways (for case the server fails to handle the command) */
client.updateVariables(
@ -239,21 +239,22 @@ class ControlBar {
}
private on_token_use() {
createInputModal("Use token", "Please enter your token/priviledge key", message => message.length > 0, result => {
createInputModal(tr("Use token"), tr("Please enter your token/priviledge key"), message => message.length > 0, result => {
if(!result) return;
if(this.handle.serverConnection.connected)
this.handle.serverConnection.sendCommand("tokenuse", {
token: result
}).then(() => {
createInfoModal("Use token", "Toke successfully used!").open();
createInfoModal(tr("Use token"), tr("Toke successfully used!")).open();
}).catch(error => {
createErrorModal("Use token", "Failed to use token: " + (error instanceof CommandResult ? error.message : error)).open();
//TODO tr
createErrorModal(tr("Use token"), "Failed to use token: " + (error instanceof CommandResult ? error.message : error)).open();
});
}).open();
}
private on_token_list() {
createErrorModal("Not implemented", "Token list is not implemented yet!").open();
createErrorModal(tr("Not implemented"), tr("Token list is not implemented yet!")).open();
}
private onPermission() {

View File

@ -92,7 +92,7 @@ class InfoBar<AvailableTypes = ServerEntry | ChannelEntry | ClientEntry | undefi
}
}
console.log("Using info manager: %o", this.current_manager);
console.log(tr("Using info manager: %o"), this.current_manager);
if(this.current_manager)
(this.current_manager as InfoManager<AvailableTypes>).createFrame(this, this.current_selected, this._tag_info);
}
@ -136,7 +136,7 @@ class Hostbanner {
this.html_tag.append(element).removeClass("disabled");
}).catch(error => {
console.warn("Failed to load hostbanner: %o", error);
console.warn(tr("Failed to load hostbanner: %o"), error);
this.html_tag.empty().addClass("disabled");
})
} else {
@ -160,7 +160,7 @@ class Hostbanner {
return new Promise<JQuery<HTMLElement>>((resolve, reject) => {
const node_image = image[0] as HTMLImageElement;
node_image.onload = () => {
console.debug("Hostbanner has been loaded");
console.debug(tr("Hostbanner has been loaded"));
if(server.properties.virtualserver_hostbanner_gfx_interval > 0)
this.updater = setTimeout(() => this.update(), Math.min(server.properties.virtualserver_hostbanner_gfx_interval, 60) * 1000);
resolve(rendered);
@ -395,9 +395,9 @@ class MusicInfoManager extends ClientInfoManager {
if(bot.properties.player_state < MusicPlayerState.PLAYING) {
properties["music_player"] = $("#tmpl_music_frame_empty").renderTag().css("align-self", "center");
} else {
let frame = $.spawn("div").text("loading...") as JQuery<HTMLElement>;
let frame = $.spawn("div").text(tr("loading...")) as JQuery<HTMLElement>;
properties["music_player"] = frame;
properties["song_url"] = $.spawn("a").text("loading...");
properties["song_url"] = $.spawn("a").text(tr("loading..."));
bot.requestPlayerInfo().then(info => {
let timestamp = Date.now();
@ -405,7 +405,7 @@ class MusicInfoManager extends ClientInfoManager {
console.log(info);
let _frame = $("#tmpl_music_frame").renderTag({
song_name: info.player_title ? info.player_title :
info.song_url ? info.song_url : "No title or url",
info.song_url ? info.song_url : tr("No title or url"),
song_url: info.song_url,
thumbnail: info.song_thumbnail && info.song_thumbnail.length > 0 ? info.song_thumbnail : undefined
}).css("align-self", "center");
@ -425,7 +425,7 @@ class MusicInfoManager extends ClientInfoManager {
bot_id: bot.properties.client_database_id,
action: 1
}).then(updated => this.triggerUpdate()).catch(error => {
createErrorModal("Failed to execute play", MessageHelper.formatMessage("Failed to execute play.<br>{}", error)).open();
createErrorModal(tr("Failed to execute play"), MessageHelper.formatMessage(tr("Failed to execute play.<br>{}"), error)).open();
this.triggerUpdate();
});
}
@ -438,7 +438,7 @@ class MusicInfoManager extends ClientInfoManager {
bot_id: bot.properties.client_database_id,
action: 2
}).then(updated => this.triggerUpdate()).catch(error => {
createErrorModal("Failed to execute pause", MessageHelper.formatMessage("Failed to execute pause.<br>{}", error)).open();
createErrorModal(tr("Failed to execute pause"), MessageHelper.formatMessage(tr("Failed to execute pause.<br>{}"), error)).open();
this.triggerUpdate();
});
}
@ -450,7 +450,7 @@ class MusicInfoManager extends ClientInfoManager {
bot_id: bot.properties.client_database_id,
action: 0
}).then(updated => this.triggerUpdate()).catch(error => {
createErrorModal("Failed to execute stop", MessageHelper.formatMessage("Failed to execute stop.<br>{}", error)).open();
createErrorModal(tr("Failed to execute stop"), MessageHelper.formatMessage(tr("Failed to execute stop.<br>{}"), error)).open();
this.triggerUpdate();
});
});
@ -473,7 +473,7 @@ class MusicInfoManager extends ClientInfoManager {
bot_id: bot.properties.client_database_id,
action: 3
}).then(updated => this.triggerUpdate()).catch(error => {
createErrorModal("Failed to execute forward", "Failed to execute pause.<br>{}".format(error)).open();
createErrorModal(tr("Failed to execute forward"), tr("Failed to execute pause.<br>{}").format(error)).open();
this.triggerUpdate();
});
});
@ -482,12 +482,12 @@ class MusicInfoManager extends ClientInfoManager {
bot_id: bot.properties.client_database_id,
action: 4
}).then(updated => this.triggerUpdate()).catch(error => {
createErrorModal("Failed to execute rewind", "Failed to execute pause.<br>{}".format(error)).open();
createErrorModal(tr("Failed to execute rewind"),tr( "Failed to execute pause.<br>{}").format(error)).open();
this.triggerUpdate();
});
});
_frame.find(".btn-settings").click(() => {
createErrorModal("Not implemented", "This function is not implemented yet!").open();
createErrorModal(tr("Not implemented"), tr("This function is not implemented yet!")).open();
});
}
@ -624,9 +624,9 @@ class MusicInfoManager extends ClientInfoManager {
//const translate_y = scale_y != scale || scale_y > 1 ? 0 : undefined || 50 - (50 * ((parent.height() - padding) / player_height));
const transform = ("translate(0%, " + (scale * 50 - 50) + "%) scale(" + scale.toPrecision(2) + ")");
console.log("Parents: %o | %o", parent.width(), parent.height());
console.log("Player: %o | %o", player_width, player_height);
console.log("Scale: %f => translate: %o | %o", scale, translate_x, translate_y);
console.log(tr("Parents: %o | %o"), parent.width(), parent.height());
console.log(tr("Player: %o | %o"), player_width, player_height);
console.log(tr("Scale: %f => translate: %o | %o"), scale, translate_x, translate_y);
player.css({
transform: transform
});

View File

@ -12,7 +12,7 @@ namespace Modals {
}) => void) {
const connectModal = createModal({
header: function() {
return "Ban client";
return tr("Ban client");
},
body: function () {
let tag = $("#tmpl_client_ban").renderTag({

View File

@ -5,7 +5,7 @@ namespace Modals {
let modal: Modal;
modal = createModal({
header: base && base.banid > 0 ? "Edit ban" : "Add ban",
header: base && base.banid > 0 ? tr("Edit ban") : tr("Add ban"),
body: () => {
let template = $("#tmpl_ban_create").renderTag();
template = $.spawn("div").append(template);

View File

@ -32,7 +32,7 @@ namespace Modals {
const modal = spawnBanListModal(() => update(), () => {
spawnBanCreate(undefined, result => {
if(result.server_id < 0) result.server_id = undefined;
console.log("Adding ban %o", result);
console.log(tr("Adding ban %o"), result);
client.serverConnection.sendCommand("banadd", {
ip: result.ip,
@ -45,13 +45,14 @@ namespace Modals {
}).then(() => {
update();
}).catch(error => {
createErrorModal("Failed to add ban", "Failed to add ban.<br>Reason: " + (error instanceof CommandResult ? error.extra_message || error.message : error)).open();
//TODO tr
createErrorModal(tr("Failed to add ban"), "Failed to add ban.<br>Reason: " + (error instanceof CommandResult ? error.extra_message || error.message : error)).open();
});
});
}, ban => {
console.log("Editing ban %o", ban);
console.log(tr("Editing ban %o"), ban);
spawnBanCreate(ban, result => {
console.log("Apply edit changes %o", result);
console.log(tr("Apply edit changes %o"), result);
if(result.server_id < 0) result.server_id = undefined;
client.serverConnection.sendCommand("banedit", {
@ -66,24 +67,26 @@ namespace Modals {
}).then(() => {
update();
}).catch(error => {
createErrorModal("Failed to edit ban", "Failed to edit ban.<br>Reason: " + (error instanceof CommandResult ? error.extra_message || error.message : error)).open();
//TODO tr
createErrorModal(tr("Failed to edit ban"), "Failed to edit ban.<br>Reason: " + (error instanceof CommandResult ? error.extra_message || error.message : error)).open();
});
});
}, ban => {
console.log("Deleting ban %o", ban);
console.log(tr("Deleting ban %o"), ban);
client.serverConnection.sendCommand("bandel", {
banid: ban.banid,
sid: ban.server_id
}).then(() => {
update();
}).catch(error => {
createErrorModal("Failed to delete ban", "Failed to delete ban.<br>Reason: " + (error instanceof CommandResult ? error.extra_message || error.message : error)).open();
//TODO tr
createErrorModal(tr("Failed to delete ban"), "Failed to delete ban.<br>Reason: " + (error instanceof CommandResult ? error.extra_message || error.message : error)).open();
});
});
update = () => {
client.serverConnection.commandHandler["notifybanlist"] = json => {
console.log("Got banlist: ", json);
console.log(tr("Got banlist: %o"), json);
let bans: BanEntry[] = [];
for(const entry of json) {
@ -159,7 +162,7 @@ namespace Modals {
callback_edit(entry);
return;
}
console.warn("Missing ban entry with id " + ban_id);
console.warn(tr("Missing ban entry with id %d"), ban_id);
};
const _callback_delete = ban_id => {
@ -168,13 +171,13 @@ namespace Modals {
callback_delete(entry);
return;
}
console.warn("Missing ban entry with id " + ban_id);
console.warn(tr("Missing ban entry with id %d"), ban_id);
};
let update_function: () => any;
let modal: Modal;
modal = createModal({
header: "Banlist",
header: tr("Banlist"),
body: () => {
let template = $("#tmpl_ban_list").renderTag();
template = $.spawn("div").append(template);
@ -215,7 +218,7 @@ namespace Modals {
const show_own_only = show_own_bans.prop("checked");
const highlight_own = highlight_own_bans.prop("checked");
console.log("Search for filter %s", filter);
console.log(tr("Search for filter %s"), filter);
let shown = 0, hidden = 0;
elements.find(".ban-entry").each((_idx, _entry) => {

View File

@ -7,7 +7,7 @@ namespace Modals {
const connectModal = createModal({
header: function() {
let header = $.spawn("div");
header.text("Change volume");
header.text(tr("Change volume"));
return header;
},
body: function () {
@ -26,7 +26,7 @@ namespace Modals {
let buttonReset = $.spawn("button");
buttonReset.text("Reset");
buttonReset.text(tr("Reset"));
buttonReset.on("click", function () {
updateCallback(100);
});
@ -34,7 +34,7 @@ namespace Modals {
let buttonCancel = $.spawn("button");
buttonCancel.text("Cancel");
buttonCancel.text(tr("Cancel"));
buttonCancel.on("click", function () {
updateCallback(current * 100);
connectModal.close();
@ -43,7 +43,7 @@ namespace Modals {
let buttonOk = $.spawn("button");
buttonOk.text("OK");
buttonOk.text(tr("OK"));
buttonOk.on("click", function () {
connectModal.close();
});

View File

@ -6,7 +6,7 @@ namespace Modals {
const connectModal = createModal({
header: function() {
let header = $.spawn("div");
header.text("Create a new connection");
header.text(tr("Create a new connection"));
return header;
},
body: function () {
@ -81,7 +81,7 @@ namespace Modals {
connectIdentity = TSIdentityHelper.loadIdentityFromFileContains(reader.result as string);
console.log(connectIdentity.uid());
if(!connectIdentity) tag.find(".error_message").text("Could not read identity! " + TSIdentityHelper.last_error());
if(!connectIdentity) tag.find(".error_message").text(tr("Could not read identity! ") + TSIdentityHelper.last_error());
else {
tag.find(".identity_string").val((connectIdentity as TeamSpeakIdentity).exported());
settings.changeGlobal("connect_identity_teamspeak_identity", (connectIdentity as TeamSpeakIdentity).exported());
@ -91,7 +91,7 @@ namespace Modals {
updateFields();
};
reader.onerror = ev => {
tag.find(".error_message").text("Could not read identity file!").show();
tag.find(".error_message").text(tr("Could not read identity file!")).show();
updateFields();
};
reader.readAsText(this.files[0]);
@ -99,7 +99,7 @@ namespace Modals {
tag.find(".identity_string").on('change', function (this: HTMLInputElement) {
if(this.value.length == 0){
tag.find(".error_message").text("Please select an identity!");
tag.find(".error_message").text(tr("Please select an identity!"));
connectIdentity = undefined;
} else {
connectIdentity = TSIdentityHelper.loadIdentity(this.value);
@ -119,7 +119,7 @@ namespace Modals {
{
const element = tag.find(".identity_config_" + IdentitifyType[IdentitifyType.TEAFORO]);
element.on('shown', ev => {
console.log("Updating via shown");
console.log(tr("Updating via shown"));
connectIdentity = forumIdentity;
if(connectIdentity) {
@ -162,7 +162,6 @@ namespace Modals {
});
if(!settings.static("localhost_debug", false)) {
console.trace("Removing debug connect option");
tag.find(".identity_select option[value=" + IdentitifyType[IdentitifyType.NICKNAME] + "]").remove();
}
}
@ -179,7 +178,7 @@ namespace Modals {
let button = $.spawn("button");
button.addClass("connect_connect_button");
button.text("Connect");
button.text(tr("Connect"));
button.on("click", function () {
connectModal.close();

View File

@ -4,7 +4,7 @@ namespace Modals {
export function createChannelModal(channel: ChannelEntry | undefined, parent: ChannelEntry | undefined, permissions: PermissionManager, callback: (properties?: ChannelProperties, permissions?: PermissionValue[]) => any) {
let properties: ChannelProperties = { } as ChannelProperties; //The changes properties
const modal = createModal({
header: channel ? "Edit channel" : "Create channel",
header: channel ? tr("Edit channel") : tr("Create channel"),
body: () => {
let template = $("#tmpl_channel_edit").renderTag(channel ? channel.properties : {
channel_flag_maxfamilyclients_unlimited: true,
@ -19,10 +19,10 @@ namespace Modals {
footer.css("margin", "5px");
let buttonCancel = $.spawn("button");
buttonCancel.text("Cancel").addClass("button_cancel");
buttonCancel.text(tr("Cancel")).addClass("button_cancel");
let buttonOk = $.spawn("button");
buttonOk.text("Ok").addClass("button_ok");
buttonOk.text(tr("Ok")).addClass("button_ok");
footer.append(buttonCancel);
footer.append(buttonOk);
@ -46,14 +46,14 @@ namespace Modals {
if(!element.prop("changed")) return;
let permission = permissions.resolveInfo(element.attr("permission"));
if(!permission) {
log.error(LogCategory.PERMISSIONS, "Failed to resolve channel permission for name %o", element.attr("permission"));
log.error(LogCategory.PERMISSIONS, tr("Failed to resolve channel permission for name %o"), element.attr("permission"));
element.prop("disabled", true);
return;
}
updated.push(new PermissionValue(permission, element.val()));
});
console.log("Updated permissions %o", updated);
console.log(tr("Updated permissions %o"), updated);
}).click(() => {
modal.close();
callback(properties, updated); //First may create the channel
@ -171,7 +171,7 @@ namespace Modals {
function applyPermissionListener(properties: ChannelProperties, tag: JQuery, button: JQuery, permissions: PermissionManager, channel?: ChannelEntry) {
let apply_permissions = (channel_permissions: PermissionValue[]) => {
console.log("Got permissions: %o", channel_permissions);
console.log(tr("Got permissions: %o"), channel_permissions);
let required_power = -2;
for(let cperm of channel_permissions)
if(cperm.type.name == PermissionType.I_CHANNEL_NEEDED_MODIFY_POWER) {
@ -183,14 +183,14 @@ namespace Modals {
let element = $(_element);
let permission = permissions.resolveInfo(element.attr("permission"));
if(!permission) {
log.error(LogCategory.PERMISSIONS, "Failed to resolve channel permission for name %o", element.attr("permission"));
log.error(LogCategory.PERMISSIONS, tr("Failed to resolve channel permission for name %o"), element.attr("permission"));
element.prop("disabled", true);
return;
}
let old_value: number = 0;
element.on("click keyup", () => {
console.log("Permission triggered! %o", element.val() != old_value);
console.log(tr("Permission triggered! %o"), element.val() != old_value);
element.prop("changed", element.val() != old_value);
});

View File

@ -59,7 +59,7 @@ namespace Modals {
export function spawnPermissionEdit() : Modal {
const connectModal = createModal({
header: function() {
return "Server Permissions";
return tr("Server Permissions");
},
body: function () {
let properties: any = {};
@ -96,9 +96,9 @@ namespace Modals {
task_queue.pop_front()().then(() => setTimeout(task_invokder, 0));
};
setTimeout(task_invokder, 5);
}, 1000);
}, 5);
});
}, 1000);
}, 5);
return tag;
},
@ -110,7 +110,7 @@ namespace Modals {
tag.addClass("modal-button-group");
let buttonOk = $.spawn("button");
buttonOk.text("Close").addClass("btn_close");
buttonOk.text(tr("Close")).addClass("btn_close");
tag.append(buttonOk);
return tag;
},
@ -268,22 +268,22 @@ namespace Modals {
spawn_context_menu(event.pageX, event.pageY, {
type: MenuEntryType.ENTRY,
icon: "",
name: "Expend group",
name: tr("Expend group"),
callback: () => expend_all.bind(this, entry)
}, {
type: MenuEntryType.ENTRY,
icon: "",
name: "Expend all",
name: tr("Expend all"),
callback: () => expend_all.bind(this, undefined)
}, {
type: MenuEntryType.ENTRY,
icon: "",
name: "Collapse group",
name: tr("Collapse group"),
callback: collapse_all.bind(this, entry)
}, {
type: MenuEntryType.ENTRY,
icon: "",
name: "Collapse all",
name: tr("Collapse all"),
callback: () => expend_all.bind(this, undefined)
});
});
@ -321,14 +321,14 @@ namespace Modals {
entries.push({
type: MenuEntryType.ENTRY,
icon: "",
name: "Add permission",
name: tr("Add permission"),
callback: () => entry.trigger('dblclick')
});
} else {
entries.push({
type: MenuEntryType.ENTRY,
icon: "",
name: "Remove permission",
name: tr("Remove permission"),
callback: () => {
entry.addClass("unset");
entry.find(".permission-value input").val("").trigger('change');
@ -339,7 +339,7 @@ namespace Modals {
entries.push({
type: MenuEntryType.ENTRY,
icon: "",
name: "Add grant permission",
name: tr("Add grant permission"),
callback: () => {
let value = entry.find("> .permission-grant input");
value.focus().val(default_number).trigger('change');
@ -349,7 +349,7 @@ namespace Modals {
entries.push({
type: MenuEntryType.ENTRY,
icon: "",
name: "Remove permission",
name: tr("Remove permission"),
callback: () => {
entry.find("> .permission-grant input").val("").trigger('change');
}
@ -359,28 +359,28 @@ namespace Modals {
entries.push({
type: MenuEntryType.ENTRY,
icon: "",
name: "Expend all",
name: tr("Expend all"),
callback: () => expend_all.bind(this, undefined)
});
entries.push({
type: MenuEntryType.ENTRY,
icon: "",
name: "Collapse all",
name: tr("Collapse all"),
callback: collapse_all.bind(this, undefined)
});
entries.push(MenuEntry.HR());
entries.push({
type: MenuEntryType.ENTRY,
icon: "",
name: "Show permission description",
name: tr("Show permission description"),
callback: () => {
createErrorModal("Not implemented!", "This function isnt implemented yet!").open();
createErrorModal(tr("Not implemented!"), tr("This function isnt implemented yet!")).open();
}
});
entries.push({
type: MenuEntryType.ENTRY,
icon: "",
name: "Copy permission name",
name: tr("Copy permission name"),
callback: () => {
copy_to_clipboard(entry.find(".permission-name").text() as string);
}
@ -392,7 +392,7 @@ namespace Modals {
entry.find(".permission-value input, .permission-negate input, .permission-skip input").on('change', event => {
let permission = globalClient.permissions.resolveInfo(entry.find(".permission-name").text());
if(!permission) {
console.error("Attempted to edit a not known permission! (%s)", entry.find(".permission-name").text());
console.error(tr("Attempted to edit a not known permission! (%s)"), entry.find(".permission-name").text());
return;
}
@ -417,7 +417,7 @@ namespace Modals {
entry.find(".permission-grant input").on('change', event => {
let permission = globalClient.permissions.resolveInfo(entry.find(".permission-name").text());
if(!permission) {
console.error("Attempted to edit a not known permission! (%s)", entry.find(".permission-name").text());
console.error(tr("Attempted to edit a not known permission! (%s)"), entry.find(".permission-name").text());
return;
}
@ -469,12 +469,12 @@ namespace Modals {
let channel_id: number = parseInt(channel_list.find(".selected").attr("channel-id"));
let channel = globalClient.channelTree.findChannel(channel_id);
if(!channel) {
console.warn("Missing selected channel id for permission editor action!");
return Promise.reject("invalid channel");
console.warn(tr("Missing selected channel id for permission editor action!"));
return Promise.reject(tr("invalid channel"));
}
if(value != undefined) {
console.log("Added permission " + type.name + " with properties: %o %o %o", value, skip, negate);
console.log(tr("Added permission %s with properties: %o %o %o"), type.name, value, skip, negate);
return new Promise<boolean>((resolve, reject) => {
globalClient.serverConnection.sendCommand("channelclientaddperm", {
cldbid: cldbid,
@ -486,7 +486,7 @@ namespace Modals {
}).then(resolve.bind(undefined, true)).catch(reject);
});
} else {
console.log("Removed permission " + type.name);
console.log(tr("Removed permission %s"), type.name);
return new Promise<boolean>((resolve, reject) => {
return globalClient.serverConnection.sendCommand("channelclientdelperm", {
cldbid: cldbid,
@ -502,12 +502,12 @@ namespace Modals {
let channel_id: number = parseInt(channel_list.find(".selected").attr("channel-id"));
let channel = globalClient.channelTree.findChannel(channel_id);
if(!channel) {
console.warn("Missing selected channel id for permission editor action!");
return Promise.reject("invalid channel");
console.warn(tr("Missing selected channel id for permission editor action!"));
return Promise.reject(tr("invalid channel"));
}
if(value != undefined) {
console.log("Added grant of %o for " + type.name, value);
console.log(tr("Added grant of %o for %s"),type.name, value);
return new Promise<boolean>((resolve, reject) => {
globalClient.serverConnection.sendCommand("channelclientaddperm", {
cldbid: cldbid,
@ -519,7 +519,7 @@ namespace Modals {
}).then(resolve.bind(undefined, true)).catch(reject);
});
} else {
console.log("Removed grant permission for %s", type.name);
console.log(tr("Removed grant permission for %s"), type.name);
return new Promise<boolean>((resolve, reject) => {
return globalClient.serverConnection.sendCommand("channelclientdelperm", {
cldbid: cldbid,
@ -544,7 +544,7 @@ namespace Modals {
let channel_id: number = parseInt(channel_list.find(".selected").attr("channel-id"));
let channel = globalClient.channelTree.findChannel(channel_id);
if(!channel) {
console.warn("Missing selected channel id for permission editor action!");
console.warn(tr("Missing selected channel id for permission editor action!"));
return Promise.reject();
}
@ -567,7 +567,7 @@ namespace Modals {
let cldbid = parseInt(tag.find(".client-dbid").val() as string);
if(isNaN(cldbid)) return Promise.reject("invalid cldbid");
if(value != undefined) {
console.log("Added permission " + type.name + " with properties: %o %o %o", value, skip, negate);
console.log(tr("Added permission %s with properties: %o %o %o"), type.name, value, skip, negate);
return new Promise<boolean>((resolve, reject) => {
globalClient.serverConnection.sendCommand("clientaddperm", {
cldbid: cldbid,
@ -578,7 +578,7 @@ namespace Modals {
}).then(resolve.bind(undefined, true)).catch(reject);
});
} else {
console.log("Removed permission " + type.name);
console.log(tr("Removed permission %s"), type.name);
return new Promise<boolean>((resolve, reject) => {
return globalClient.serverConnection.sendCommand("clientdelperm", {
cldbid: cldbid,
@ -591,7 +591,7 @@ namespace Modals {
if(isNaN(cldbid)) return Promise.reject("invalid cldbid");
if(value != undefined) {
console.log("Added grant of %o for " + type.name, value);
console.log(tr("Added grant of %o for %s"), type.name, value);
return new Promise<boolean>((resolve, reject) => {
globalClient.serverConnection.sendCommand("clientaddperm", {
cldbid: cldbid,
@ -602,7 +602,7 @@ namespace Modals {
}).then(resolve.bind(undefined, true)).catch(reject);
});
} else {
console.log("Removed grant permission for %s", type.name);
console.log(tr("Removed grant permission for %s"), type.name);
return new Promise<boolean>((resolve, reject) => {
return globalClient.serverConnection.sendCommand("clientdelperm", {
cldbid: cldbid,
@ -642,12 +642,12 @@ namespace Modals {
let channel_id: number = parseInt(channel_list.find(".selected").attr("channel-id"));
let channel = globalClient.channelTree.findChannel(channel_id);
if(!channel) {
console.warn("Missing selected channel id for permission editor action!");
console.warn(tr("Missing selected channel id for permission editor action!"));
return;
}
if(value != undefined) {
console.log("Added permission " + type.name + " with properties: %o %o %o", value, skip, negate);
console.log(tr("Added permission %o with properties: %o %o %o"), type.name, value, skip, negate);
return new Promise<boolean>((resolve, reject) => {
globalClient.serverConnection.sendCommand("channeladdperm", {
cid: channel.channelId,
@ -658,7 +658,7 @@ namespace Modals {
}).then(resolve.bind(undefined, true)).catch(reject);
});
} else {
console.log("Removed permission " + type.name);
console.log(tr("Removed permission %s"), type.name);
return new Promise<boolean>((resolve, reject) => {
return globalClient.serverConnection.sendCommand("channeldelperm", {
cid: channel.channelId,
@ -670,12 +670,12 @@ namespace Modals {
let channel_id: number = parseInt(channel_list.find(".selected").attr("channel-id"));
let channel = globalClient.channelTree.findChannel(channel_id);
if(!channel) {
console.warn("Missing selected channel id for permission editor action!");
console.warn(tr("Missing selected channel id for permission editor action!"));
return;
}
if(value != undefined) {
console.log("Added grant of %o for " + type.name, value);
console.log(tr("Added grant of %o for %s"), type.name, value);
return new Promise<boolean>((resolve, reject) => {
globalClient.serverConnection.sendCommand("channeladdperm", {
cid: channel.channelId,
@ -686,7 +686,7 @@ namespace Modals {
}).then(resolve.bind(undefined, true)).catch(reject);
});
} else {
console.log("Removed grant permission for %s", type.name);
console.log(tr("Removed grant permission for %s"), type.name);
return new Promise<boolean>((resolve, reject) => {
return globalClient.serverConnection.sendCommand("channeldelperm", {
cid: channel.channelId,
@ -701,7 +701,7 @@ namespace Modals {
let channel_id: number = parseInt(channel_list.find(".selected").attr("channel-id"));
let channel = globalClient.channelTree.findChannel(channel_id);
if(!channel) {
console.warn("Missing selected channel id for permission editor action!");
console.warn(tr("Missing selected channel id for permission editor action!"));
return;
}
@ -719,12 +719,12 @@ namespace Modals {
let group_id: number = parseInt(group_list.find(".selected").attr("group-id"));
let group = globalClient.groups.channelGroup(group_id);
if(!group) {
console.warn("Missing selected group id for permission editor action!");
console.warn(tr("Missing selected group id for permission editor action!"));
return;
}
if(value != undefined) {
console.log("Added permission " + type.name + " with properties: %o %o %o", value, skip, negate);
console.log(tr("Added permission %s with properties: %o %o %o"), type.name, value, skip, negate);
return new Promise<boolean>((resolve, reject) => {
globalClient.serverConnection.sendCommand("channelgroupaddperm", {
cgid: group.id,
@ -735,7 +735,7 @@ namespace Modals {
}).then(resolve.bind(undefined, true)).catch(reject);
});
} else {
console.log("Removed permission " + type.name);
console.log(tr("Removed permission %s"), type.name);
return new Promise<boolean>((resolve, reject) => {
return globalClient.serverConnection.sendCommand("channelgroupdelperm", {
cgid: group.id,
@ -747,12 +747,12 @@ namespace Modals {
let group_id: number = parseInt(group_list.find(".selected").attr("group-id"));
let group = globalClient.groups.channelGroup(group_id);
if(!group) {
console.warn("Missing selected group id for permission editor action!");
console.warn(tr("Missing selected group id for permission editor action!"));
return;
}
if(value != undefined) {
console.log("Added grant of %o for " + type.name, value);
console.log(tr("Added grant of %o for %s"), type.name, value);
return new Promise<boolean>((resolve, reject) => {
globalClient.serverConnection.sendCommand("channelgroupaddperm", {
cgid: group.id,
@ -764,7 +764,7 @@ namespace Modals {
});
}
else {
console.log("Removed grant permission for %s", type.name);
console.log(tr("Removed grant permission for %s"), type.name);
return new Promise<boolean>((resolve, reject) => {
return globalClient.serverConnection.sendCommand("channelgroupdelperm", {
cgid: group.id,
@ -801,7 +801,7 @@ namespace Modals {
let group_id: number = parseInt(group_list.find(".selected").attr("group-id"));
let group = globalClient.groups.channelGroup(group_id);
if(!group) {
console.warn("Missing selected group id for permission editor!");
console.warn(tr("Missing selected group id for permission editor!"));
return;
}
globalClient.groups.request_permissions(group).then(result => display_permissions(permission_tag, result)).catch(error => {
@ -820,12 +820,12 @@ namespace Modals {
let group_id: number = parseInt(group_list.find(".selected").attr("group-id"));
let group = globalClient.groups.serverGroup(group_id);
if(!group) {
console.warn("Missing selected group id for permission editor action!");
console.warn(tr("Missing selected group id for permission editor action!"));
return;
}
if(value != undefined) {
console.log("Added permission " + type.name + " with properties: %o %o %o", value, skip, negate);
console.log(tr("Added permission %s with properties: %o %o %o"), type.name, value, skip, negate);
return new Promise<boolean>((resolve, reject) => {
globalClient.serverConnection.sendCommand("servergroupaddperm", {
sgid: group.id,
@ -836,7 +836,7 @@ namespace Modals {
}).then(resolve.bind(undefined, true)).catch(reject);
});
} else {
console.log("Removed permission " + type.name);
console.log(tr("Removed permission %s"), type.name);
return new Promise<boolean>((resolve, reject) => {
return globalClient.serverConnection.sendCommand("servergroupdelperm", {
sgid: group.id,
@ -848,12 +848,12 @@ namespace Modals {
let group_id: number = parseInt(group_list.find(".selected").attr("group-id"));
let group = globalClient.groups.serverGroup(group_id);
if(!group) {
console.warn("Missing selected group id for permission editor action!");
console.warn(tr("Missing selected group id for permission editor action!"));
return;
}
if(value != undefined) {
console.log("Added grant of %o for " + type.name, value);
console.log(tr("Added grant of %o for %s"), value, type.name);
return new Promise<boolean>((resolve, reject) => {
globalClient.serverConnection.sendCommand("servergroupaddperm", {
sgid: group.id,
@ -902,7 +902,7 @@ namespace Modals {
let group_id: number = parseInt(group_list.find(".selected").attr("group-id"));
let group = globalClient.groups.serverGroup(group_id);
if(!group) {
console.warn("Missing selected group id for permission editor!");
console.warn(tr("Missing selected group id for permission editor!"));
return;
}
globalClient.groups.request_permissions(group).then(result => display_permissions(permission_tag, result)).catch(error => {

View File

@ -10,7 +10,7 @@ namespace Modals {
}, message) {
let modal;
modal = createModal({
header: "You have been poked!",
header: tr("You have been poked!"),
body: () => {
let template = $("#tmpl_poke_popup").renderTag({
"invoker": ClientEntry.chatTag(invoker.id, invoker.name, invoker.unique_id, true),

View File

@ -4,7 +4,7 @@ namespace Modals {
export function createServerModal(server: ServerEntry, callback: (properties?: ServerProperties) => any) {
let properties: ServerProperties = {} as ServerProperties; //The changes properties
const modal = createModal({
header: "Manager the Virtual Server",
header: tr("Manager the Virtual Server"),
body: () => {
let template = $("#tmpl_server_edit").renderTag(server.properties);
template = $.spawn("div").append(template);
@ -16,10 +16,10 @@ namespace Modals {
footer.css("margin", "5px");
let buttonCancel = $.spawn("button");
buttonCancel.text("Cancel").addClass("button_cancel");
buttonCancel.text(tr("Cancel")).addClass("button_cancel");
let buttonOk = $.spawn("button");
buttonOk.text("Ok").addClass("button_ok");
buttonOk.text(tr("Ok")).addClass("button_ok");
footer.append(buttonCancel);
footer.append(buttonOk);

View File

@ -1,7 +1,7 @@
namespace Modals {
export function createServerGroupAssignmentModal(client: ClientEntry, callback: (group: Group, flag: boolean) => Promise<boolean>) {
const modal = createModal({
header: "Server Groups",
header: tr("Server Groups"),
body: () => {
let tag: any = {};
let groups = tag["groups"] = [];
@ -28,7 +28,7 @@ namespace Modals {
let group_id = parseInt(entry.attr("group-id"));
let group = client.channelTree.client.groups.serverGroup(group_id);
if(!group) {
console.warn("Could not resolve target group!");
console.warn(tr("Could not resolve target group!"));
return false;
}
@ -45,7 +45,7 @@ namespace Modals {
footer.css("margin", "5px");
let button_close = $.spawn("button");
button_close.text("Close").addClass("button_close");
button_close.text(tr("Close")).addClass("button_close");
footer.append(button_close);

View File

@ -7,7 +7,7 @@ namespace Modals {
export function spawnSettingsModal() {
let modal;
modal = createModal({
header: "Settings",
header: tr("Settings"),
body: () => {
let template = $("#tmpl_settings").renderTag();
template = $.spawn("div").append(template);
@ -82,7 +82,7 @@ namespace Modals {
body: "",
header: () => {
let head = $.spawn("div");
head.text("Type the key you wish");
head.text(tr("Type the key you wish"));
head.css("background-color", "blue");
return head;
},
@ -92,7 +92,7 @@ namespace Modals {
let listener = (event: ppt.KeyEvent) => {
if(event.type == ppt.EventType.KEY_TYPED) {
settings.changeGlobal('vad_ppt_key', undefined); //TODO remove that because its legacy shit
console.log("Got key %o", event);
console.log(tr("Got key %o"), event);
let ppt_settings: PPTKeySettings = settings.global('vad_ppt_settings', undefined);
ppt_settings = ppt_settings ? JSON.parse(ppt_settings as any as string) : {};
@ -130,6 +130,7 @@ namespace Modals {
let target_tag = vad_tag.find('input[type=radio][name="vad_type"][value="' + currentVAD + '"]');
if(target_tag.length == 0) {
//TODO tr
console.warn("Failed to find tag for " + currentVAD + ". Using latest tag!");
target_tag = vad_tag.find('input[type=radio][name="vad_type"]').last();
}
@ -149,14 +150,14 @@ namespace Modals {
$.spawn("option")
.attr("device-id", "")
.attr("device-group", "")
.text("No device")
.text(tr("No device"))
.appendTo(tag_select);
navigator.mediaDevices.enumerateDevices().then(devices => {
const active_device = globalClient.voiceConnection.voiceRecorder.device_id();
for(const device of devices) {
console.debug("Got device %s (%s): %s", device.deviceId, device.kind, device.label);
console.debug(tr("Got device %s (%s): %s"), device.deviceId, device.kind, device.label);
if(device.kind !== 'audioinput') continue;
$.spawn("option")
@ -167,10 +168,10 @@ namespace Modals {
.appendTo(tag_select);
}
}).catch(error => {
console.error("Could not enumerate over devices!");
console.error(tr("Could not enumerate over devices!"));
console.error(error);
setting_tag.find(".settings-device-error")
.text("Could not get device list!")
.text(tr("Could not get device list!"))
.css("display", "block");
});
@ -184,7 +185,7 @@ namespace Modals {
let selected_tag = tag_select.find("option:selected");
let deviceId = selected_tag.attr("device-id");
let groupId = selected_tag.attr("device-group");
console.log("Selected microphone device: id: %o group: %o", deviceId, groupId);
console.log(tr("Selected microphone device: id: %o group: %o"), deviceId, groupId);
globalClient.voiceConnection.voiceRecorder.change_device(deviceId, groupId);
});
}
@ -204,10 +205,10 @@ namespace Modals {
.appendTo(tag_select);
}
}).catch(error => {
console.error("Could not enumerate over devices!");
console.error(tr("Could not enumerate over devices!"));
console.error(error);
setting_tag.find(".settings-device-error")
.text("Could not get device list!")
.text(tr("Could not get device list!"))
.css("display", "block");
});
@ -220,11 +221,11 @@ namespace Modals {
tag_select.on('change', event => {
let selected_tag = tag_select.find("option:selected");
let deviceId = selected_tag.attr("device-id");
console.log("Selected speaker device: id: %o", deviceId);
console.log(tr("Selected speaker device: id: %o"), deviceId);
audio.player.set_device(deviceId).then(() => error_tag.css("display", "none")).catch(error => {
console.error(error);
error_tag
.text("Failed to change device!")
.text(tr("Failed to change device!"))
.css("display", "block");
});
});

View File

@ -14,7 +14,7 @@ namespace Modals {
footer.css("text-align", "right");
let button_yes = $.spawn("button");
button_yes.text("Yes");
button_yes.text(tr("Yes"));
button_yes.click(() => {
modal.close();
callback(true);
@ -22,7 +22,7 @@ namespace Modals {
footer.append(button_yes);
let button_no = $.spawn("button");
button_no.text("No");
button_no.text(tr("No"));
button_no.click(() => {
modal.close();
callback(false);

View File

@ -132,11 +132,11 @@ class ServerEntry {
spawn_context_menu(x, y, {
type: MenuEntryType.ENTRY,
icon: "client-virtualserver_edit",
name: "Edit",
name: tr("Edit"),
callback: () => {
Modals.createServerModal(this, properties => {
log.info(LogCategory.SERVER, "Changing server properties %o", properties);
console.log("Changed properties: %o", properties);
log.info(LogCategory.SERVER, tr("Changing server properties %o"), properties);
console.log(tr("Changed properties: %o"), properties);
if (properties)
this.channelTree.client.serverConnection.sendCommand("serveredit", properties).then(() => {
sound.play(Sound.SERVER_EDITED_SELF);
@ -149,12 +149,13 @@ class ServerEntry {
}
updateVariables(is_self_notify: boolean, ...variables: {key: string, value: string}[]) {
let group = log.group(log.LogType.DEBUG, LogCategory.SERVER, "Update properties (%i)", variables.length);
let group = log.group(log.LogType.DEBUG, LogCategory.SERVER, tr("Update properties (%i)"), variables.length);
let update_bannner = false;
for(let variable of variables) {
JSON.map_field_to(this.properties, variable.value, variable.key);
//TODO tr
group.log("Updating server " + this.properties.virtualserver_name + ". Key " + variable.key + " Value: '" + variable.value + "' (" + typeof (this.properties[variable.key]) + ")");
if(variable.key == "virtualserver_name") {
this.htmlTag.find(".name").text(variable.value);

View File

@ -72,7 +72,7 @@ class ChannelTree {
{
type: MenuEntryType.ENTRY,
icon: "client-channel_create",
name: "Create channel",
name: tr("Create channel"),
invalidPermission: !channelCreate,
callback: () => this.spawnCreateChannel()
},
@ -207,7 +207,7 @@ class ChannelTree {
moveChannel(channel: ChannelEntry, channel_previus: ChannelEntry, parent: ChannelEntry) {
if(channel_previus != null && channel_previus.parent != parent) {
console.error("Invalid channel move (different parents! (" + channel_previus.parent + "|" + parent + ")");
console.error(tr("Invalid channel move (different parents! (%o|%o)"), channel_previus.parent, parent);
return;
}
@ -409,23 +409,23 @@ class ChannelTree {
}
private callback_multiselect_channel(event) {
console.log("Multiselect channel");
console.log(tr("Multiselect channel"));
}
private callback_multiselect_client(event) {
console.log("Multiselect client");
console.log(tr("Multiselect client"));
const clients = this.currently_selected as ClientEntry[];
const music_only = clients.map(e => e instanceof MusicClientEntry ? 0 : 1).reduce((a, b) => a + b, 0) == 0;
const music_entry = clients.map(e => e instanceof MusicClientEntry ? 1 : 0).reduce((a, b) => a + b, 0) > 0;
const local_client = clients.map(e => e instanceof LocalClientEntry ? 1 : 0).reduce((a, b) => a + b, 0) > 0;
console.log("Music only: %o | Container music: %o | Container local: %o", music_entry, music_entry, local_client);
console.log(tr("Music only: %o | Container music: %o | Container local: %o"), music_entry, music_entry, local_client);
let entries: ContextMenuEntry[] = [];
if (!music_entry && !local_client) { //Music bots or local client cant be poked
entries.push({
type: MenuEntryType.ENTRY,
icon: "client-poke",
name: "Poke clients",
name: tr("Poke clients"),
callback: () => {
createInputModal("Poke clients", "Poke message:<br>", text => true, result => {
createInputModal(tr("Poke clients"), tr("Poke message:<br>"), text => true, result => {
if (typeof(result) === "string") {
for (const client of this.currently_selected as ClientEntry[])
this.client.serverConnection.sendCommand("clientpoke", {
@ -441,7 +441,7 @@ class ChannelTree {
entries.push({
type: MenuEntryType.ENTRY,
icon: "client-move_client_to_own_channel",
name: "Move clients to your channel",
name: tr("Move clients to your channel"),
callback: () => {
const target = this.client.getClient().currentChannel().getChannelId();
for(const client of clients)
@ -456,9 +456,9 @@ class ChannelTree {
entries.push({
type: MenuEntryType.ENTRY,
icon: "client-kick_channel",
name: "Kick clients from channel",
name: tr("Kick clients from channel"),
callback: () => {
createInputModal("Kick clients from channel", "Kick reason:<br>", text => true, result => {
createInputModal(tr("Kick clients from channel"), tr("Kick reason:<br>"), text => true, result => {
if (result) {
for (const client of clients)
this.client.serverConnection.sendCommand("clientkick", {
@ -476,9 +476,9 @@ class ChannelTree {
entries.push({
type: MenuEntryType.ENTRY,
icon: "client-kick_server",
name: "Kick clients fom server",
name: tr("Kick clients fom server"),
callback: () => {
createInputModal("Kick clients from server", "Kick reason:<br>", text => true, result => {
createInputModal(tr("Kick clients from server"), tr("Kick reason:<br>"), text => true, result => {
if (result) {
for (const client of clients)
this.client.serverConnection.sendCommand("clientkick", {
@ -493,7 +493,7 @@ class ChannelTree {
}, {
type: MenuEntryType.ENTRY,
icon: "client-ban_client",
name: "Ban clients",
name: tr("Ban clients"),
invalidPermission: !this.client.permissions.neededPermission(PermissionType.I_CLIENT_BAN_MAX_BANTIME).granted(1),
callback: () => {
Modals.spawnBanClient((clients).map(entry => entry.clientNickName()), (data) => {
@ -512,15 +512,15 @@ class ChannelTree {
if(music_only) {
entries.push(MenuEntry.HR());
entries.push({
name: "Delete bots",
name: tr("Delete bots"),
icon: "client-delete",
disabled: false,
callback: () => {
const param_string = clients.map((_, index) => "{" + index + "}").join(', ');
const param_values = clients.map(client => client.createChatTag(true));
const tag = $.spawn("div").append(...MessageHelper.formatMessage("Do you really want to delete " + param_string, ...param_values));
const tag = $.spawn("div").append(...MessageHelper.formatMessage(tr("Do you really want to delete ") + param_string, ...param_values));
const tag_container = $.spawn("div").append(tag);
Modals.spawnYesNo("Are you sure?", tag_container, result => {
Modals.spawnYesNo(tr("Are you sure?"), tag_container, result => {
if(result) {
for(const client of clients)
this.client.serverConnection.sendCommand("musicbotdelete", {
@ -572,11 +572,11 @@ class ChannelTree {
Modals.createChannelModal(undefined, parent, this.client.permissions, (properties?, permissions?) => {
if(!properties) return;
properties["cpid"] = parent ? parent.channelId : 0;
log.debug(LogCategory.CHANNEL, "Creating a new channel.\nProperties: %o\nPermissions: %o", properties);
log.debug(LogCategory.CHANNEL, tr("Creating a new channel.\nProperties: %o\nPermissions: %o"), properties);
this.client.serverConnection.sendCommand("channelcreate", properties).then(() => {
let channel = this.find_channel_by_name(properties.channel_name, parent, true);
if(!channel) {
log.error(LogCategory.CHANNEL, "Failed to resolve channel after creation. Could not apply permissions!");
log.error(LogCategory.CHANNEL, tr("Failed to resolve channel after creation. Could not apply permissions!"));
return;
}
if(permissions && permissions.length > 0) {
@ -596,7 +596,7 @@ class ChannelTree {
return new Promise<ChannelEntry>(resolve => { resolve(channel); })
}).then(channel => {
chat.serverChat().appendMessage("Channel {} successfully created!", true, channel.createChatTag());
chat.serverChat().appendMessage(tr("Channel {} successfully created!"), true, channel.createChatTag());
sound.play(Sound.CHANNEL_CREATED);
});
});

View File

@ -23,10 +23,10 @@ const ModalFunctions = {
case "string": return $("<div>" + val + "</div>");
case "object": return val as JQuery;
case "undefined":
console.warn("Got undefined type!");
console.warn(tr("Got undefined type!"));
return $.spawn("div");
default:
console.error("Invalid type " + typeof val);
console.error(("Invalid type %o"), typeof val);
return $();
}
},

View File

@ -17,7 +17,7 @@ if(typeof (customElements) !== "undefined") {
customElements.define('x-tag', X_Tag, { extends: 'div' });
customElements.define('x-content', X_Content, { extends: 'div' });
} else {
console.warn("Could not defied tab customElements!");
console.warn(tr("Could not defied tab customElements!"));
}
var TabFunctions = {

View File

@ -14,9 +14,9 @@ class AudioController {
static initializeAudioController() {
if(!audio.player.initialize())
console.warn("Failed to initialize audio controller!");
console.warn(tr("Failed to initialize audio controller!"));
sound.initialize().then(() => {
console.log("Sounds initialitzed");
console.log(tr("Sounds initialitzed"));
});
//this._globalReplayScheduler = setInterval(() => { AudioController.invokeNextReplay(); }, 20); //Fix me
}
@ -105,20 +105,20 @@ class AudioController {
playBuffer(buffer: AudioBuffer) {
if(!buffer) {
console.warn("[AudioController] Got empty or undefined buffer! Dropping it");
console.warn(tr("[AudioController] Got empty or undefined buffer! Dropping it"));
return;
}
if(!this.speakerContext) {
console.warn("[AudioController] Failed to replay audio. Global audio context not initialized yet!");
console.warn(tr("[AudioController] Failed to replay audio. Global audio context not initialized yet!"));
return;
}
if (buffer.sampleRate != this.speakerContext.sampleRate)
console.warn("[AudioController] Source sample rate isn't equal to playback sample rate! (" + buffer.sampleRate + " | " + this.speakerContext.sampleRate + ")");
console.warn(tr("[AudioController] Source sample rate isn't equal to playback sample rate! (%o | %o)"), buffer.sampleRate, this.speakerContext.sampleRate);
this.applyVolume(buffer);
this.audioCache.push(buffer);
if(this.playerState == PlayerState.STOPPED || this.playerState == PlayerState.STOPPING) {
console.log("[Audio] Starting new playback");
console.log(tr("[Audio] Starting new playback"));
this.playerState = PlayerState.PREBUFFERING;
//New audio
}
@ -134,11 +134,11 @@ class AudioController {
} else break;
}
if(this.playerState == PlayerState.PREBUFFERING) {
console.log("[Audio] Prebuffering succeeded (Replaying now)");
console.log(tr("[Audio] Prebuffering succeeded (Replaying now)"));
this.onSpeaking();
} else {
if(this.allowBuffering)
console.log("[Audio] Buffering succeeded (Replaying now)");
console.log(tr("[Audio] Buffering succeeded (Replaying now)"));
}
this.playerState = PlayerState.PLAYING;
case PlayerState.PLAYING:
@ -153,7 +153,7 @@ class AudioController {
let buffer: AudioBuffer;
while(buffer = this.audioCache.pop_front()) {
if(this.playingAudioCache.length >= this._latencyBufferLength * 1.5 + 3) {
console.log("Dropping buffer because playing queue grows to much");
console.log(tr("Dropping buffer because playing queue grows to much"));
continue; /* drop the data (we're behind) */
}
if(this._timeIndex < this.speakerContext.currentTime) this._timeIndex = this.speakerContext.currentTime;
@ -196,7 +196,7 @@ class AudioController {
this.playerState = PlayerState.BUFFERING;
if(!this.allowBuffering)
console.warn("[Audio] Detected a buffer underflow!");
console.warn(tr("[Audio] Detected a buffer underflow!"));
this.reset_buffer_timeout(true);
} else {
this.playerState = PlayerState.STOPPED;
@ -211,7 +211,7 @@ class AudioController {
if(restart)
this._buffer_timeout = setTimeout(() => {
if(this.playerState == PlayerState.PREBUFFERING || this.playerState == PlayerState.BUFFERING) {
console.warn("[Audio] Buffering exceeded timeout. Flushing and stopping replay");
console.warn(tr("[Audio] Buffering exceeded timeout. Flushing and stopping replay"));
this.stopAudio();
}
this._buffer_timeout = undefined;

View File

@ -4,12 +4,12 @@ class AudioResampler {
constructor(targetSampleRate: number){
this.targetSampleRate = targetSampleRate;
if(this.targetSampleRate < 3000 || this.targetSampleRate > 384000) throw "The target sample rate is outside the range [3000, 384000].";
if(this.targetSampleRate < 3000 || this.targetSampleRate > 384000) throw tr("The target sample rate is outside the range [3000, 384000].");
}
resample(buffer: AudioBuffer) : Promise<AudioBuffer> {
if(!buffer) {
console.warn("Received empty buffer as input! Returning empty output!");
console.warn(tr("Received empty buffer as input! Returning empty output!"));
return Promise.resolve(buffer);
}
//console.log("Encode from %i to %i", buffer.sampleRate, this.targetSampleRate);

View File

@ -23,12 +23,12 @@ class CodecPool {
initialize(cached: number) {
for(let i = 0; i < cached; i++)
this.ownCodec(i + 1).then(codec => {
console.log("Release again! (%o)", codec);
console.log(tr("Release again! (%o)"), codec);
this.releaseCodec(i + 1);
}).catch(error => {
console.warn("Disabling codec support for " + this.name);
console.warn(tr("Disabling codec support for "), this.name);
if(this._supported) {
createErrorModal("Could not load codec driver", "Could not load or initialize codec " + this.name + "<br>" +
createErrorModal(tr("Could not load codec driver"), tr("Could not load or initialize codec ") + this.name + "<br>" +
"Error: <code>" + JSON.stringify(error) + "</code>").open();
}
this._supported = false;
@ -41,7 +41,7 @@ class CodecPool {
ownCodec?(clientId: number, create: boolean = true) : Promise<BasicCodec | undefined> {
return new Promise<BasicCodec>((resolve, reject) => {
if(!this._supported) {
reject("unsupported codec!");
reject(tr("unsupported codec!"));
return;
}
@ -55,8 +55,8 @@ class CodecPool {
//TODO test success flag
this.ownCodec(clientId, false).then(resolve).catch(reject);
}).catch(error => {
console.error("Could not initialize codec!\nError: %o", error);
reject("Could not initialize codec!");
console.error(tr("Could not initialize codec!\nError: %o"), error);
reject(tr("Could not initialize codec!"));
});
}
return;
@ -129,12 +129,12 @@ class VoiceConnection {
local_audio_stream: any;
private codec_pool: CodecPool[] = [
new CodecPool(this,0,"Speex Narrowband", CodecType.SPEEX_NARROWBAND),
new CodecPool(this,1,"Speex Wideband", CodecType.SPEEX_WIDEBAND),
new CodecPool(this,2,"Speex Ultra Wideband", CodecType.SPEEX_ULTRA_WIDEBAND),
new CodecPool(this,3,"CELT Mono", CodecType.CELT_MONO),
new CodecPool(this,4,"Opus Voice", CodecType.OPUS_VOICE),
new CodecPool(this,5,"Opus Music", CodecType.OPUS_MUSIC)
new CodecPool(this,0,tr("Speex Narrowband"), CodecType.SPEEX_NARROWBAND),
new CodecPool(this,1,tr("Speex Wideband"), CodecType.SPEEX_WIDEBAND),
new CodecPool(this,2,tr("Speex Ultra Wideband"), CodecType.SPEEX_ULTRA_WIDEBAND),
new CodecPool(this,3,tr("CELT Mono"), CodecType.CELT_MONO),
new CodecPool(this,4,tr("Opus Voice"), CodecType.OPUS_VOICE),
new CodecPool(this,5,tr("Opus Music"), CodecType.OPUS_MUSIC)
];
private vpacketId: number = 0;
@ -150,7 +150,7 @@ class VoiceConnection {
this.voiceRecorder.reinitialiseVAD();
audio.player.on_ready(() => {
log.info(LogCategory.VOICE, "Initializing voice handler after AudioController has been initialized!");
log.info(LogCategory.VOICE, tr("Initializing voice handler after AudioController has been initialized!"));
if(native_client) {
this.codec_pool[0].initialize(2);
this.codec_pool[1].initialize(2);
@ -190,9 +190,9 @@ class VoiceConnection {
}
private setup_native() {
log.info(LogCategory.VOICE, "Setting up native voice stream!");
log.info(LogCategory.VOICE, tr("Setting up native voice stream!"));
if(!this.native_encoding_supported()) {
log.warn(LogCategory.VOICE, "Native codec isnt supported!");
log.warn(LogCategory.VOICE, tr("Native codec isnt supported!"));
return;
}
@ -267,7 +267,7 @@ class VoiceConnection {
//TODO may handle error?
}
} else {
console.warn("Could not transfer audio (not connected)");
console.warn(tr("Could not transfer audio (not connected)"));
}
}
@ -300,10 +300,10 @@ class VoiceConnection {
if(this.local_audio_stream) { //May a typecheck?
this.rtcPeerConnection.addStream(this.local_audio_stream.stream);
console.log("Adding stream (%o)!", this.local_audio_stream.stream);
console.log(tr("Adding stream (%o)!"), this.local_audio_stream.stream);
}
this.rtcPeerConnection.createOffer(this.onOfferCreated.bind(this), () => {
console.error("Could not create ice offer!");
console.error(tr("Could not create ice offer!"));
}, sdpConstraints);
}
@ -317,30 +317,30 @@ class VoiceConnection {
_ice_cache: any[] = [];
handleControlPacket(json) {
if(json["request"] === "answer") {
console.log("Set remote sdp! (%o)", json["msg"]);
console.log(tr("Set remote sdp! (%o)"), json["msg"]);
this.rtcPeerConnection.setRemoteDescription(new RTCSessionDescription(json["msg"])).catch(error => {
console.log("Failed to apply remote description: %o", error); //FIXME error handling!
console.log(tr("Failed to apply remote description: %o"), error); //FIXME error handling!
});
this._ice_use_cache = false;
for(let msg of this._ice_cache) {
this.rtcPeerConnection.addIceCandidate(new RTCIceCandidate(msg)).catch(error => {
console.log("Failed to add remote cached ice candidate %s: %o", msg, error);
console.log(tr("Failed to add remote cached ice candidate %s: %o"), msg, error);
});
}
} else if(json["request"] === "ice") {
if(!this._ice_use_cache) {
console.log("Add remote ice! (%s | %o)", json["msg"], json);
console.log(tr("Add remote ice! (%s | %o)"), json["msg"], json);
this.rtcPeerConnection.addIceCandidate(new RTCIceCandidate(json["msg"])).catch(error => {
console.log("Failed to add remote ice candidate %s: %o", json["msg"], error);
console.log(tr("Failed to add remote ice candidate %s: %o"), json["msg"], error);
});
} else {
console.log("Cache remote ice! (%s | %o)", json["msg"], json);
console.log(tr("Cache remote ice! (%s | %o)"), json["msg"], json);
this._ice_cache.push(json["msg"]);
}
} else if(json["request"] == "status") {
if(json["state"] == "failed") {
chat.serverChat().appendError("Failed to setup voice bridge ({}). Allow reconnect: {}", json["reason"], json["allow_reconnect"]);
log.error(LogCategory.NETWORKING, "Failed to setup voice bridge (%s). Allow reconnect: %s", json["reason"], json["allow_reconnect"]);
chat.serverChat().appendError(tr("Failed to setup voice bridge ({}). Allow reconnect: {}"), json["reason"], json["allow_reconnect"]);
log.error(LogCategory.NETWORKING, tr("Failed to setup voice bridge (%s). Allow reconnect: %s"), json["reason"], json["allow_reconnect"]);
if(json["allow_reconnect"] == true) {
this.createSession();
}
@ -351,7 +351,7 @@ class VoiceConnection {
//Listeners
onIceCandidate(event) {
console.log("Got ice candidate! Event:");
console.log(tr("Got ice candidate! Event:"));
console.log(event);
if (event) {
if(event.candidate)
@ -370,18 +370,18 @@ class VoiceConnection {
}
onOfferCreated(localSession) {
console.log("Offer created and accepted");
console.log(tr("Offer created and accepted"));
this.rtcPeerConnection.setLocalDescription(localSession).catch(error => {
console.log("Failed to apply local description: %o", error);
console.log(tr("Failed to apply local description: %o"), error);
//FIXME error handling
});
console.log("Send offer: %o", localSession);
console.log(tr("Send offer: %o"), localSession);
this.client.serverConnection.sendData(JSON.stringify({type: 'WebRTC', request: "create", msg: localSession}));
}
onDataChannelOpen(channel) {
console.log("Got new data channel! (%s)", this.dataChannel.readyState);
console.log(tr("Got new data channel! (%s)"), this.dataChannel.readyState);
this.client.controlBar.updateVoice();
}
@ -395,13 +395,13 @@ class VoiceConnection {
//console.log("Client id " + clientId + " PacketID " + packetId + " Codec: " + codec);
let client = this.client.channelTree.findClient(clientId);
if(!client) {
console.error("Having voice from unknown client? (ClientID: " + clientId + ")");
console.error(tr("Having voice from unknown client? (ClientID: %o)"), clientId);
return;
}
let codecPool = this.codec_pool[codec];
if(!codecPool) {
console.error("Could not playback codec " + codec);
console.error(tr("Could not playback codec %o"), codec);
return;
}
@ -417,7 +417,7 @@ class VoiceConnection {
codecPool.ownCodec(clientId)
.then(decoder => decoder.decodeSamples(client.getAudioController().codecCache(codec), encodedData))
.then(buffer => client.getAudioController().playBuffer(buffer)).catch(error => {
console.error("Could not playback client's (" + clientId + ") audio (" + error + ")");
console.error(tr("Could not playback client's (%o) audio (%o)"), clientId, error);
if(error instanceof Error)
console.error(error.stack);
});
@ -450,14 +450,14 @@ class VoiceConnection {
if(!this.voiceRecorder) return;
if(!this.client.connected) return;
console.log("Local voice ended");
console.log(tr("Local voice ended"));
if(this.dataChannel)
this.sendVoicePacket(new Uint8Array(0), this.current_channel_codec()); //TODO Use channel codec!
}
private handleVoiceStarted() {
console.log("Local voice started");
console.log(tr("Local voice started"));
if(this.client && this.client.getClient())
this.client.getClient().speaking = true;

View File

@ -122,7 +122,7 @@ class VoiceRecorder {
if(type == "ppt") {
if(settings.global('vad_ppt_key', undefined)) {
//TODO remove that because its legacy shit
createErrorModal("VAD changed!", "VAD key detection changed.<br>Please reset your PPT key!").open();
createErrorModal(tr("VAD changed!"), tr("VAD key detection changed.<br>Please reset your PPT key!")).open();
}
let ppt_settings: PPTKeySettings = settings.global('vad_ppt_settings', undefined);
ppt_settings = ppt_settings ? JSON.parse(ppt_settings as any as string) : {};
@ -156,7 +156,7 @@ class VoiceRecorder {
this.setVADHandler(new VoiceActivityDetectorVAD());
(this.getVADHandler() as VoiceActivityDetectorVAD).percentageThreshold = settings.global("vad_threshold", 50);
} else {
console.warn("Invalid VAD (Voice activation detector) handler! (" + type + ")");
console.warn(tr("Invalid VAD (Voice activation detector) handler! (%o)"), type);
}
}
@ -205,7 +205,7 @@ class VoiceRecorder {
this._deviceId = device;
this._deviceGroup = groupId;
console.log("[VoiceRecorder] Start recording! (Device: %o | Group: %o)", device, groupId);
console.log(tr("[VoiceRecorder] Start recording! (Device: %o | Group: %o)"), device, groupId);
this._recording = true;
//FIXME Implement that here for thew client as well
@ -217,14 +217,14 @@ class VoiceRecorder {
echoCancellationType: 'browser'
}
}, this.on_microphone.bind(this), error => {
createErrorModal("Could not resolve microphone!", "Could not resolve microphone!<br>Message: " + error).open();
console.error("Could not get microphone!");
createErrorModal(tr("Could not resolve microphone!"), tr("Could not resolve microphone!<br>Message: ") + error).open();
console.error(tr("Could not get microphone!"));
console.error(error);
});
}
stop(stop_media_stream: boolean = true){
console.log("Stop recording!");
console.log(tr("Stop recording!"));
this._recording = false;
if(this.microphoneStream) this.microphoneStream.disconnect();
@ -250,7 +250,7 @@ class VoiceRecorder {
if(!this.mediaStream) return;
if(!this.audioContext) {
console.log("[VoiceRecorder] Got microphone stream, but havn't a audio context. Waiting until its initialized");
console.log(tr("[VoiceRecorder] Got microphone stream, but havn't a audio context. Waiting until its initialized"));
return;
}