diff --git a/i18n/de.json b/i18n/de.json index 94867ad..d737eb6 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -10,6 +10,17 @@ "yes": "Ja", "no": "Nein", + "%errors": "", + "error_api_not_found": "Die Star Citizen Wiki API ist unter der angegebenen URL nicht erreichbar.", + "error_api_no_connection": "Die Star Citizen Wiki API ist derzeit nicht erreichbar", + "error_no_data": "Ich konnte keine Daten zu der Eingabe finden.", + "error_too_many_requests": "Zu viele Anfragen gesendet. Bitte warten.", + "error_command_failure": "Der Befehl konnte nicht ausgeführt werden.", + + "%comm-link": "", + "newest_comm_link": "Der neueste Comm-Link", + "newest_comm_links": "Die neuesten Comm-Links", + "%galactapedia": "", "related_articles": "Verwandte Artikel", diff --git a/i18n/en.json b/i18n/en.json index 71744c1..99ccb8b 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -10,6 +10,17 @@ "yes": "Yes", "no": "No", + "%errors": "", + "error_api_not_found": "The Star Citizen Wiki API is not reachable at the specified URL.", + "error_api_no_connection": "The Star Citizen Wiki API is currently unreachable", + "error_no_data": "I could not find any data related to the input.", + "error_too_many_requests": "Too many requests sent. Please wait.", + "error_command_failure": "The command could not be executed.", + + "%comm-link": "", + "newest_comm_link": "The current Comm-Link", + "newest_comm_links": "The current Comm-Links", + "%galactapedia": "", "related_articles": "Related articles", diff --git a/i18n/fr.json b/i18n/fr.json index cd2695b..5426981 100644 --- a/i18n/fr.json +++ b/i18n/fr.json @@ -10,6 +10,17 @@ "yes": "Oui", "no": "Non", + "%errors": "", + "error_api_not_found" : "L'API Star Citizen Wiki n'est pas accessible à l'URL indiquée", + "error_api_no_connection" : "L'API Star Citizen Wiki est actuellement inaccessible", + "error_no_data" : "Je n'ai trouvé aucune donnée concernant l'entrée", + "error_too_many_requests" : "Trop de demandes envoyées. Veuillez patienter", + "error_command_failure" : "La commande n'a pas pu être exécutée", + + "%comm-link": "", + "newest_comm_link": "Le Comm-Link actuel", + "newest_comm_links": "Les Comm-Links actuels", + "%galactapedia": "", "related_articles": "Articles connexes", diff --git a/src/events/interactionCreate.js b/src/events/interactionCreate.js index 0224b7f..217275c 100644 --- a/src/events/interactionCreate.js +++ b/src/events/interactionCreate.js @@ -1,5 +1,6 @@ const { Events } = require('discord.js'); const log = require('../lib/console-logger'); +const { translate } = require('../lib/translate'); module.exports = { name: Events.InteractionCreate, @@ -15,14 +16,14 @@ module.exports = { if (error.code === 'ENOTFOUND') { log('Could not connect to API', error.message, 'error'); - return interaction.editReply({ content: 'Die Star Citizen Wiki API ist unter der angegebenen URL nicht erreichbar.' }); + return interaction.editReply({ content: translate(interaction, 'error_api_not_found') }); } if (typeof error.response !== 'undefined' && typeof error.response.status !== 'undefined') { if (error.response.status === 504 || error.response.status === 500) { log('Could not connect to API', error, 'error'); - return interaction.editReply({ content: 'Die Star Citizen Wiki API ist derzeit nicht erreichbar' }); + return interaction.editReply({ content: translate(interaction, 'error_api_no_connection') }); } if (error.response.status === 404) { @@ -35,18 +36,18 @@ module.exports = { console.error(error); } - return interaction.editReply({ content: 'Ich konnte keine Daten zu der Eingabe finden.' }); + return interaction.editReply({ content: translate(interaction, 'error_no_data') }); } if (error.response.status === 429) { log('API calls are rate-limited', {}, 'warn'); - return interaction.editReply({ content: 'Zu viele Anfragen gesendet. Bitte warten.' }); + return interaction.editReply({ content: translate(interaction, 'error_too_many_requests') }); } } console.error(error); - interaction.reply({ content: 'Der Befehl konnte nicht ausgeführt werden.' }) + interaction.reply({ content: translate(interaction, 'error_command_failure') }) .catch(() => { log('Could not send message'); }); diff --git a/src/lib/embed/comm-links-embed.js b/src/lib/embed/comm-links-embed.js index 8ba2073..d54070b 100644 --- a/src/lib/embed/comm-links-embed.js +++ b/src/lib/embed/comm-links-embed.js @@ -1,6 +1,6 @@ const { EmbedBuilder } = require('discord.js'); const { footer, wiki_url } = require('../../../config.json'); -const { getLocale } = require('../translate'); +const { getLocale, translate } = require('../translate'); /** * @param {Object} data @@ -8,7 +8,9 @@ const { getLocale } = require('../translate'); * @return {EmbedBuilder} */ const createEmbed = (data, interaction) => { - const title = data.length === 1 ? 'Der neueste Comm-Link' : 'Die neuesten Comm-Links'; + const title = data.length === 1 + ? translate(interaction, 'newest_comm_link') + : translate(interaction, 'newest_comm_links'); const url = data.length === 1 ? `${wiki_url}/Comm-Link:${data[0].id}` : `${wiki_url}/Comm-Link:Übersicht`; const reply = new EmbedBuilder({