Skip to content

Commit

Permalink
add translations
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsounet committed May 3, 2024
1 parent 0c56c7e commit 83d667b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
21 changes: 19 additions & 2 deletions EXT-VLCServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ Module.register("EXT-VLCServer", {
return dom;
},

getTranslations () {
return {
en: "translations/en.json",
fr: "translations/fr.json"
};
},

notificationReceived (noti, payload, sender) {
switch (noti) {
case "GA_READY":
Expand All @@ -31,10 +38,20 @@ Module.register("EXT-VLCServer", {
socketNotificationReceived (noti, payload) {
switch (noti) {
case "ERROR":
console.log(`[VLC] [ERROR] ${payload}`);
console.error(`[VLC] [ERROR] ${this.translate(payload.message)}`);
this.sendNotification("EXT_ALERT", {
type: "error",
message: this.translate(payload.message),
timer: 10000
});
break;
case "WARNING":
console.log(`[VLC] [WARNING] ${payload}`);
console.warn(`[VLC] [WARNING] this.translate(payload.message, { VALUES: payload.values })`);
this.sendNotification("EXT_ALERT", {
type: "warning",
message: this.translate(payload.message, { VALUES: payload.values }),
timer: 10000
});
break;
case "STARTED":
this.sendNotification("EXT_VLCSERVER-START");
Expand Down
10 changes: 5 additions & 5 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports = NodeHelper.create({
this.ServerStarted = true;
} else {
if (this.ServerStarted) {
console.error(`[VLC] VLC Http Server Close! (id:${packet.process.pm_id})`);
console.error(`[VLC] VLC Http Server Closed! (id:${packet.process.pm_id})`);
this.sendSocketNotification("ERROR" , { message: "VLC_Close" });
this.sendSocketNotification("CLOSED");
}
Expand All @@ -83,9 +83,9 @@ module.exports = NodeHelper.create({
if (packet.process.name === "VLCServer") {
if (packet.data.includes("main interface error:")) {
console.error("[VLC]", packet.data);
this.sendSocketNotification("ERROR" , { message: "VLC_Error" });
this.sendSocketNotification("ERROR" , { message: "VLC_ErrorPacket" });
} else {
log("[VLC]", packet.data);
log("[PACKET DATA]", packet.data);
}
}
});
Expand All @@ -102,14 +102,14 @@ module.exports = NodeHelper.create({
args: [
"-I http",
"--extraintf", "http",
"--http-port", 8082,
"--http-port", 8081,
"--http-host", "127.0.0.1",
"--http-password", "EXT-VLCServer"
]
/* eslint-enable @stylistic/array-element-newline */
}, (err, proc) => {
if (err) {
this.sendSocketNotification("WARNING" , { message: "VLCError", values: err.toString() });
this.sendSocketNotification("WARNING" , { message: "VLCError", values: err.message });
console.error(`[VLC] ${err}`);
}
});
Expand Down
6 changes: 6 additions & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"VLC_NotInstalled": "VLC is not installed or not found!",
"VLC_Close": "VLC HTTP Server Closed!",
"VLCError": "VLC Return an error: {VALUES}",
"VLC_ErrorPacket": "VLC Return an error"
}
7 changes: 7 additions & 0 deletions translations/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"VLC_NotInstalled": "VLC n'est pas installé ou n'a pas été trouvé!",
"VLC_Close": "Le Serveur HTTP de VLC est Fermé!",
"VLCError": "VLC Retourne une erreur: {VALUES}",
"VLC_ErrorPacket": "VLC a retourné une error!"
}

0 comments on commit 83d667b

Please sign in to comment.