feat: add an about command #2

Merged
naomi merged 4 commits from feat/about into main 2025-02-10 15:43:06 -08:00
10 changed files with 662 additions and 190 deletions

View File

@ -23,7 +23,7 @@
"vitest": "3.0.5"
},
"dependencies": {
"discord.js": "14.17.3",
"discord.js": "14.18.0",
"fastify": "5.2.1",
"winston": "3.17.0"
}

46
pnpm-lock.yaml generated
View File

@ -9,8 +9,8 @@ importers:
.:
dependencies:
discord.js:
specifier: 14.17.3
version: 14.17.3
specifier: 14.18.0
version: 14.18.0
fastify:
specifier: 5.2.1
version: 5.2.1
@ -116,8 +116,8 @@ packages:
'@dabh/diagnostics@2.0.3':
resolution: {integrity: sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==}
'@discordjs/builders@1.10.0':
resolution: {integrity: sha512-ikVZsZP+3shmVJ5S1oM+7SveUCK3L9fTyfA8aJ7uD9cNQlTqF+3Irbk2Y22KXTb3C3RNUahRkSInClJMkHrINg==}
'@discordjs/builders@1.10.1':
resolution: {integrity: sha512-OWo1fY4ztL1/M/DUyRPShB4d/EzVfuUvPTRRHRIt/YxBrUYSz0a+JicD5F5zHFoNs2oTuWavxCOVFV1UljHTng==}
engines: {node: '>=16.11.0'}
'@discordjs/collection@1.5.3':
@ -132,16 +132,16 @@ packages:
resolution: {integrity: sha512-YIruKw4UILt/ivO4uISmrGq2GdMY6EkoTtD0oS0GvkJFRZbTSdPhzYiUILbJ/QslsvC9H9nTgGgnarnIl4jMfw==}
engines: {node: '>=16.11.0'}
'@discordjs/rest@2.4.2':
resolution: {integrity: sha512-9bOvXYLQd5IBg/kKGuEFq3cstVxAMJ6wMxO2U3wjrgO+lHv8oNCT+BBRpuzVQh7BoXKvk/gpajceGvQUiRoJ8g==}
'@discordjs/rest@2.4.3':
resolution: {integrity: sha512-+SO4RKvWsM+y8uFHgYQrcTl/3+cY02uQOH7/7bKbVZsTfrfpoE62o5p+mmV+s7FVhTX82/kQUGGbu4YlV60RtA==}
engines: {node: '>=18'}
'@discordjs/util@1.1.1':
resolution: {integrity: sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g==}
engines: {node: '>=18'}
'@discordjs/ws@1.2.0':
resolution: {integrity: sha512-QH5CAFe3wHDiedbO+EI3OOiyipwWd+Q6BdoFZUw/Wf2fw5Cv2fgU/9UEtJRmJa9RecI+TAhdGPadMaEIur5yJg==}
'@discordjs/ws@1.2.1':
resolution: {integrity: sha512-PBvenhZG56a6tMWF/f4P6f4GxZKJTBG95n7aiGSPTnodmz4N5g60t79rSIAq7ywMbv8A4jFtexMruH+oe51aQQ==}
engines: {node: '>=16.11.0'}
'@es-joy/jsdoccomment@0.49.0':
@ -1021,8 +1021,8 @@ packages:
discord-api-types@0.37.119:
resolution: {integrity: sha512-WasbGFXEB+VQWXlo6IpW3oUv73Yuau1Ig4AZF/m13tXcTKnMpc/mHjpztIlz4+BM9FG9BHQkEXiPto3bKduQUg==}
discord.js@14.17.3:
resolution: {integrity: sha512-8/j8udc3CU7dz3Eqch64UaSHoJtUT6IXK4da5ixjbav4NAXJicloWswD/iwn1ImZEMoAV3LscsdO0zhBh6H+0Q==}
discord.js@14.18.0:
resolution: {integrity: sha512-SvU5kVUvwunQhN2/+0t55QW/1EHfB1lp0TtLZUSXVHDmyHTrdOj5LRKdR0zLcybaA15F+NtdWuWmGOX9lE+CAw==}
engines: {node: '>=18'}
doctrine@2.1.0:
@ -2296,8 +2296,8 @@ packages:
undici-types@6.20.0:
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
undici@6.19.8:
resolution: {integrity: sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g==}
undici@6.21.1:
resolution: {integrity: sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==}
engines: {node: '>=18.17'}
update-browserslist-db@1.1.2:
@ -2567,7 +2567,7 @@ snapshots:
enabled: 2.0.0
kuler: 2.0.0
'@discordjs/builders@1.10.0':
'@discordjs/builders@1.10.1':
dependencies:
'@discordjs/formatters': 0.6.0
'@discordjs/util': 1.1.1
@ -2585,7 +2585,7 @@ snapshots:
dependencies:
discord-api-types: 0.37.119
'@discordjs/rest@2.4.2':
'@discordjs/rest@2.4.3':
dependencies:
'@discordjs/collection': 2.1.1
'@discordjs/util': 1.1.1
@ -2595,14 +2595,14 @@ snapshots:
discord-api-types: 0.37.119
magic-bytes.js: 1.10.0
tslib: 2.8.1
undici: 6.19.8
undici: 6.21.1
'@discordjs/util@1.1.1': {}
'@discordjs/ws@1.2.0':
'@discordjs/ws@1.2.1':
dependencies:
'@discordjs/collection': 2.1.1
'@discordjs/rest': 2.4.2
'@discordjs/rest': 2.4.3
'@discordjs/util': 1.1.1
'@sapphire/async-queue': 1.5.5
'@types/ws': 8.5.14
@ -3477,20 +3477,20 @@ snapshots:
discord-api-types@0.37.119: {}
discord.js@14.17.3:
discord.js@14.18.0:
dependencies:
'@discordjs/builders': 1.10.0
'@discordjs/builders': 1.10.1
'@discordjs/collection': 1.5.3
'@discordjs/formatters': 0.6.0
'@discordjs/rest': 2.4.2
'@discordjs/rest': 2.4.3
'@discordjs/util': 1.1.1
'@discordjs/ws': 1.2.0
'@discordjs/ws': 1.2.1
'@sapphire/snowflake': 3.5.3
discord-api-types: 0.37.119
fast-deep-equal: 3.1.3
lodash.snakecase: 4.1.1
tslib: 2.8.1
undici: 6.19.8
undici: 6.21.1
transitivePeerDependencies:
- bufferutil
- utf-8-validate
@ -5018,7 +5018,7 @@ snapshots:
undici-types@6.20.0: {}
undici@6.19.8: {}
undici@6.21.1: {}
update-browserslist-db@1.1.2(browserslist@4.24.4):
dependencies:

87
src/commands/about.ts Normal file
View File

@ -0,0 +1,87 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import {
ApplicationIntegrationType,
SlashCommandBuilder,
InteractionContextType,
Locale,
} from "discord.js";
const command = new SlashCommandBuilder().
setContexts(
InteractionContextType.BotDM,
InteractionContextType.Guild,
InteractionContextType.PrivateChannel,
).
setIntegrationTypes(ApplicationIntegrationType.UserInstall).
setName("about").
setNameLocalizations({
[Locale.Indonesian]: "tentang",
[Locale.EnglishGB]: "about",
[Locale.EnglishUS]: "about",
[Locale.Bulgarian]: "за",
[Locale.ChineseCN]: "关于",
[Locale.ChineseTW]: "關於",
[Locale.Czech]: "o-aplikaci",
[Locale.Danish]: "om",
[Locale.Dutch]: "over",
[Locale.Finnish]: "tietoja",
[Locale.French]: "à-propos",
[Locale.German]: "über",
[Locale.Greek]: "σχετικά-με",
[Locale.Hindi]: "के-बारे-में",
[Locale.Hungarian]: "rólunk",
[Locale.Italian]: "informazioni",
[Locale.Japanese]: "約",
[Locale.Korean]: "약",
[Locale.Lithuanian]: "apie",
[Locale.Polish]: "o-nas",
[Locale.PortugueseBR]: "sobre",
[Locale.Romanian]: "despre",
[Locale.Russian]: "о",
[Locale.SpanishES]: "acerca-de",
[Locale.SpanishLATAM]: "acerca-de",
[Locale.Swedish]: "om",
[Locale.Thai]: "เกี่ยวกับ",
[Locale.Turkish]: "hakkında",
[Locale.Ukrainian]: "про",
}).
setDescription("Learn more about this bot!").
setDescriptionLocalizations({
[Locale.Indonesian]: "Pelajari lebih lanjut tentang bot ini!",
[Locale.EnglishGB]: "Learn more about this bot!",
[Locale.EnglishUS]: "Learn more about this bot!",
[Locale.Bulgarian]: "Научете повече за този бот!",
[Locale.ChineseCN]: "了解有关此机器人的更多信息!",
[Locale.ChineseTW]: "了解有關此機器人的更多信息!",
[Locale.Czech]: "Dozvědět se více o tomto botovi!",
[Locale.Danish]: "Lær mere om denne bot!",
[Locale.Dutch]: "Leer meer over deze bot!",
[Locale.Finnish]: "Lisätietoja tästä botista!",
[Locale.French]: "En savoir plus sur ce bot!",
[Locale.German]: "Erfahren Sie mehr über diesen Bot!",
[Locale.Greek]: "Μάθετε περισσότερα για αυτό το bot!",
[Locale.Hindi]: "इस बॉट के बारे में और अधिक जानें!",
[Locale.Hungarian]: "Tudj meg többet erről a botról!",
[Locale.Italian]: "Scopri di più su questo bot!",
[Locale.Japanese]: "このボットについてもっと詳しく知る!",
[Locale.Korean]: "이 봇에 대해 더 알아보기!",
[Locale.Lithuanian]: "Sužinokite daugiau apie šį botą!",
[Locale.Polish]: "Dowiedz się więcej o tym bocie!",
[Locale.PortugueseBR]: "Saiba mais sobre este bot!",
[Locale.Romanian]: "Aflați mai multe despre acest bot!",
[Locale.Russian]: "Узнайте больше об этом боте!",
[Locale.SpanishES]: "¡Obtén más información sobre este bot!",
[Locale.SpanishLATAM]: "¡Obtén más información sobre este bot!",
[Locale.Swedish]: "Lär dig mer om denna bot!",
[Locale.Thai]: "เรียนรู้เพิ่มเติมเกี่ยวกับบอตนี้!",
[Locale.Turkish]: "Bu bot hakkında daha fazla bilgi edinin!",
[Locale.Ukrainian]: "Дізнайтеся більше про цього бота!",
});
// eslint-disable-next-line no-console -- We don't need our logger here as this never runs in production.
console.log(JSON.stringify(command.toJSON()));

View File

@ -6,10 +6,21 @@
/* eslint-disable @typescript-eslint/naming-convention -- This is the convention for these keys. */
/* eslint-disable stylistic/max-len -- These are going to be long strings and that's okay. */
/* eslint-disable max-lines -- massive chonky boi*/
import { Locale } from "discord.js";
export const responses: Record<string, { "no-message-content": string; "subscription-required": string; "translation": string; "unsupported-locale": string }> = {
export const responses: Record<string, { "no-message-content": string; "subscription-required": string; "translation": string; "unsupported-locale": string; "embed": { title: string; description: string; commit: string; version: string }; "button": { support: string; code: string } }> = {
en: {
"button": {
code: "Source code",
support: "Need help?",
},
"embed": {
commit: "Current Commit",
description: "Aria Iuvo is a Discord bot that uses LibreTranslate to provide translations for messages. She is developed by NHCarrigan. To use the bot, right click on a message, select `Apps`, then select `Translate message`!",
title: "About Aria Iuvo",
version: "Running Version",
},
"no-message-content": "No message content found.",
"subscription-required":
"You must be subscribed to translate messages.",
@ -18,201 +29,403 @@ export const responses: Record<string, { "no-message-content": string; "subscrip
"unsupported-locale": "Language {{target}} is not supported by our translation software.",
},
[Locale.Indonesian]: {
"no-message-content": "Tidak ada konten pesan ditemukan.",
"subscription-required":
"Anda harus berlangganan untuk menerjemahkan pesan.",
"translation":
"{{translation}}\n-# Mendeteksi {{language}} dengan kepercayaan {{confidence}}%.",
"unsupported-locale": "Bahasa {{target}} tidak didukung oleh perangkat lunak terjemahan kami.",
"button": {
code: "Kode sumber",
support: "Butuh bantuan?",
},
"embed": {
commit: "Commit Saat Ini",
description: "Aria Iuvo adalah bot Discord yang menggunakan LibreTranslate untuk menyediakan terjemahan pesan. Dia dikembangkan oleh NHCarrigan. Untuk menggunakan bot, klik kanan pada pesan, pilih `Apps`, lalu pilih `Translate message`!",
title: "Tentang Aria Iuvo",
version: "Versi Berjalan",
},
"no-message-content": "Tidak ditemukan konten pesan.",
"subscription-required": "Anda harus berlangganan untuk menerjemahkan pesan.",
"translation": "{{translation}}\n-# Terdeteksi {{language}} dengan tingkat kepercayaan {{confidence}}%.",
"unsupported-locale": "Bahasa {{target}} tidak didukung oleh perangkat lunak terjemahan kami.",
},
es: {
"no-message-content": "No se encontró contenido del mensaje.",
"subscription-required":
"Debes estar suscrito para traducir mensajes.",
"translation":
"{{translation}}\n-# Detectado {{language}} con {{confidence}}% de confianza.",
"unsupported-locale": "El idioma {{target}} no es compatible con nuestro software de traducción.",
"button": {
code: "Código fuente",
support: "¿Necesitas ayuda?",
},
"embed": {
commit: "Commit Actual",
description: "Aria Iuvo es un bot de Discord que usa LibreTranslate para proporcionar traducciones de mensajes. Está desarrollada por NHCarrigan. Para usar el bot, haz clic derecho en un mensaje, selecciona `Apps`, ¡luego selecciona `Translate message`!",
title: "Sobre Aria Iuvo",
version: "Versión en Ejecución",
},
"no-message-content": "No se encontró contenido del mensaje.",
"subscription-required": "Debes estar suscrito para traducir mensajes.",
"translation": "{{translation}}\n-# Detectado {{language}} con {{confidence}}% de confianza.",
"unsupported-locale": "El idioma {{target}} no es compatible con nuestro software de traducción.",
},
pt: {
"no-message-content": "Nenhum conteúdo de mensagem encontrado.",
"subscription-required":
"Você deve estar inscrito para traduzir mensagens.",
"translation":
"{{translation}}\n-# Detectado {{language}} com {{confidence}}% de confiança.",
"unsupported-locale": "O idioma {{target}} não é suportado pelo nosso software de tradução.",
"button": {
code: "Código fonte",
support: "Precisa de ajuda?",
},
"embed": {
commit: "Commit Atual",
description: "Aria Iuvo é um bot do Discord que usa LibreTranslate para fornecer traduções de mensagens. Ela é desenvolvida por NHCarrigan. Para usar o bot, clique com o botão direito em uma mensagem, selecione `Apps`, depois selecione `Translate message`!",
title: "Sobre Aria Iuvo",
version: "Versão em Execução",
},
"no-message-content": "Nenhum conteúdo de mensagem encontrado.",
"subscription-required": "Você precisa ser assinante para traduzir mensagens.",
"translation": "{{translation}}\n-# Detectado {{language}} com {{confidence}}% de confiança.",
"unsupported-locale": "O idioma {{target}} não é suportado pelo nosso software de tradução.",
},
[Locale.Czech]: {
"no-message-content": "Nebyl nalezen žádný obsah zprávy.",
"subscription-required":
"Musíte být přihlášeni k překladu zpráv.",
"translation":
"{{translation}}\n-# Detekováno {{language}} s důvěrou {{confidence}}%.",
"unsupported-locale": "Jazyk {{target}} není podporován naším překladovým softwarem.",
"button": {
code: "Zdrojový kód",
support: "Potřebujete pomoc?",
},
"embed": {
commit: "Aktuální Commit",
description: "Aria Iuvo je Discord bot, který používá LibreTranslate k poskytování překladů zpráv. Je vyvíjena NHCarriganem. Pro použití bota klikněte pravým tlačítkem na zprávu, vyberte `Apps`, pak vyberte `Translate message`!",
title: "O Aria Iuvo",
version: "Aktuální Verze",
},
"no-message-content": "Nebyl nalezen žádný obsah zprávy.",
"subscription-required": "Pro překládání zpráv musíte mít předplatné.",
"translation": "{{translation}}\n-# Detekován jazyk {{language}} s {{confidence}}% jistotou.",
"unsupported-locale": "Jazyk {{target}} není podporován naším překladovým softwarem.",
},
[Locale.Danish]: {
"no-message-content": "Ingen beskedindhold fundet.",
"subscription-required":
"Du skal være tilmeldt for at oversætte beskeder.",
"translation":
"{{translation}}\n-# Detekteret {{language}} med {{confidence}}% tillid.",
"unsupported-locale": "Sproget {{target}} understøttes ikke af vores oversættelsessoftware.",
"button": {
code: "Kildekode",
support: "Brug for hjælp?",
},
"embed": {
commit: "Nuværende Commit",
description: "Aria Iuvo er en Discord bot, der bruger LibreTranslate til at levere oversættelser af beskeder. Hun er udviklet af NHCarrigan. For at bruge botten, højreklik på en besked, vælg `Apps`, vælg derefter `Translate message`!",
title: "Om Aria Iuvo",
version: "Kørende Version",
},
"no-message-content": "Intet beskedindhold fundet.",
"subscription-required": "Du skal være abonnent for at oversætte beskeder.",
"translation": "{{translation}}\n-# Detekteret {{language}} med {{confidence}}% sikkerhed.",
"unsupported-locale": "Sproget {{target}} understøttes ikke af vores oversættelsessoftware.",
},
[Locale.Dutch]: {
"no-message-content": "Geen berichtinhoud gevonden.",
"subscription-required":
"U moet zijn geabonneerd om berichten te vertalen.",
"translation":
"{{translation}}\n-# Gedetecteerd {{language}} met {{confidence}}% vertrouwen.",
"unsupported-locale": "Taal {{target}} wordt niet ondersteund door onze vertaalsoftware.",
"button": {
code: "Broncode",
support: "Hulp nodig?",
},
"embed": {
commit: "Huidige Commit",
description: "Aria Iuvo is een Discord bot die LibreTranslate gebruikt om vertalingen voor berichten te verzorgen. Ze is ontwikkeld door NHCarrigan. Om de bot te gebruiken, klik met de rechtermuisknop op een bericht, selecteer `Apps`, selecteer vervolgens `Translate message`!",
title: "Over Aria Iuvo",
version: "Huidige Versie",
},
"no-message-content": "Geen berichtinhoud gevonden.",
"subscription-required": "Je moet geabonneerd zijn om berichten te vertalen.",
"translation": "{{translation}}\n-# Gedetecteerd {{language}} met {{confidence}}% zekerheid.",
"unsupported-locale": "Taal {{target}} wordt niet ondersteund door onze vertaalsoftware.",
},
[Locale.Finnish]: {
"no-message-content": "Ei viestisisältöä löytynyt.",
"subscription-required":
"Sinun on tilattava viestien kääntämiseksi.",
"translation":
"{{translation}}\n-# Havaittu {{language}} {{confidence}}% luottamuksella.",
"unsupported-locale": "Kieltä {{target}} ei tueta käännössovelluksellamme.",
"button": {
code: "Lähdekoodi",
support: "Tarvitsetko apua?",
},
"embed": {
commit: "Nykyinen Commit",
description: "Aria Iuvo on Discord-botti, joka käyttää LibreTranslatea viestien kääntämiseen. Sen on kehittänyt NHCarrigan. Käyttääksesi bottia, napsauta hiiren oikealla painikkeella viestiä, valitse `Apps`, sitten valitse `Translate message`!",
title: "Tietoja Aria Iuvosta",
version: "Käynnissä Oleva Versio",
},
"no-message-content": "Viestin sisältöä ei löytynyt.",
"subscription-required": "Sinun täytyy olla tilaaja kääntääksesi viestejä.",
"translation": "{{translation}}\n-# Tunnistettu {{language}} {{confidence}}% varmuudella.",
"unsupported-locale": "Kieli {{target}} ei ole käännösohjelmistomme tukema.",
},
[Locale.French]: {
"no-message-content": "Aucun contenu de message trouvé.",
"subscription-required":
"Vous devez être abonné pour traduire les messages.",
"translation":
"{{translation}}\n-# Détecté {{language}} avec {{confidence}}% de confiance.",
"unsupported-locale": "La langue {{target}} n'est pas prise en charge par notre logiciel de traduction.",
"button": {
code: "Code source",
support: "Besoin d'aide ?",
},
"embed": {
commit: "Commit Actuel",
description: "Aria Iuvo est un bot Discord qui utilise LibreTranslate pour fournir des traductions de messages. Elle est développée par NHCarrigan. Pour utiliser le bot, faites un clic droit sur un message, sélectionnez `Apps`, puis sélectionnez `Translate message` !",
title: "À propos d'Aria Iuvo",
version: "Version en Cours",
},
"no-message-content": "Aucun contenu de message trouvé.",
"subscription-required": "Vous devez être abonné pour traduire les messages.",
"translation": "{{translation}}\n-# Détecté {{language}} avec {{confidence}}% de confiance.",
"unsupported-locale": "La langue {{target}} n'est pas prise en charge par notre logiciel de traduction.",
},
[Locale.German]: {
"no-message-content": "Kein Nachrichteninhalt gefunden.",
"subscription-required":
"Sie müssen abonniert sein, um Nachrichten zu übersetzen.",
"translation":
"{{translation}}\n-# Erkannt {{language}} mit {{confidence}}% Vertrauen.",
"unsupported-locale": "Die Sprache {{target}} wird von unserer Übersetzungssoftware nicht unterstützt.",
"button": {
code: "Quellcode",
support: "Hilfe benötigt?",
},
"embed": {
commit: "Aktueller Commit",
description: "Aria Iuvo ist ein Discord-Bot, der LibreTranslate verwendet, um Übersetzungen für Nachrichten bereitzustellen. Sie wurde von NHCarrigan entwickelt. Um den Bot zu verwenden, klicken Sie mit der rechten Maustaste auf eine Nachricht, wählen Sie `Apps` und dann `Translate message`!",
title: "Über Aria Iuvo",
version: "Laufende Version",
},
"no-message-content": "Kein Nachrichteninhalt gefunden.",
"subscription-required": "Sie müssen abonniert sein, um Nachrichten zu übersetzen.",
"translation": "{{translation}}\n-# Erkannt {{language}} mit {{confidence}}% Sicherheit.",
"unsupported-locale": "Die Sprache {{target}} wird von unserer Übersetzungssoftware nicht unterstützt.",
},
[Locale.Greek]: {
"no-message-content": "Δεν βρέθηκε περιεχόμενο μηνύματος.",
"subscription-required":
"Πρέπει να είστε συνδρομητής για να μεταφράσετε μηνύματα.",
"translation":
"{{translation}}\n-# Ανιχνεύθηκε {{language}} με {{confidence}}% εμπιστοσύνη.",
"unsupported-locale": "Η γλώσσα {{target}} δεν υποστηρίζεται από το λογισμικό μετάφρασής μας.",
"button": {
code: "Πηγαίος κώδικας",
support: "Χρειάζεστε βοήθεια;",
},
"embed": {
commit: "Τρέχον Commit",
description: "Η Aria Iuvo είναι ένα bot Discord που χρησιμοποιεί το LibreTranslate για να παρέχει μεταφράσεις μηνυμάτων. Αναπτύχθηκε από τον NHCarrigan. Για να χρησιμοποιήσετε το bot, κάντε δεξί κλικ σε ένα μήνυμα, επιλέξτε `Apps`, στη συνέχεια επιλέξτε `Translate message`!",
title: "Σχετικά με την Aria Iuvo",
version: "Τρέχουσα Έκδοση",
},
"no-message-content": "Δεν βρέθηκε περιεχόμενο μηνύματος.",
"subscription-required": "Πρέπει να είστε συνδρομητής για να μεταφράσετε μηνύματα.",
"translation": "{{translation}}\n-# Εντοπίστηκε {{language}} με {{confidence}}% βεβαιότητα.",
"unsupported-locale": "Η γλώσσα {{target}} δεν υποστηρίζεται από το λογισμικό μετάφρασής μας.",
},
[Locale.Hindi]: {
"no-message-content": "कोई संदेश सामग्री नहीं मिली।",
"subscription-required":
"आपको संदेश अनुवाद करने के लिए सब्सक्राइब करना होगा।",
"translation":
"{{translation}}\n-# {{confidence}}% विश्वास के साथ {{language}} का पता लगाया गया।",
"unsupported-locale": "हमारे अनुवाद सॉफ़्टवेयर द्वारा {{target}} भाषा का समर्थन नहीं किया जाता है।",
"button": {
code: "सोर्स कोड",
support: "मदद चाहिए?",
},
"embed": {
commit: "वर्तमान कमिट",
description: "Aria Iuvo एक Discord बॉट है जो संदेशों के अनुवाद के लिए LibreTranslate का उपयोग करती है। इसे NHCarrigan द्वारा विकसित किया गया है। बॉट का उपयोग करने के लिए, किसी संदेश पर राइट क्लिक करें, `Apps` चुनें, फिर `Translate message` चुनें!",
title: "Aria Iuvo के बारे में",
version: "चल रहा संस्करण",
},
"no-message-content": "कोई संदेश सामग्री नहीं मिली।",
"subscription-required": "संदेशों का अनुवाद करने के लिए आपको सदस्यता लेनी होगी।",
"translation": "{{translation}}\n-# {{confidence}}% विश्वास के साथ {{language}} का पता चला।",
"unsupported-locale": "भाषा {{target}} हमारे अनुवाद सॉफ्टवेयर द्वारा समर्थित नहीं है।",
},
[Locale.Hungarian]: {
"no-message-content": "Nem található üzenettartalom.",
"subscription-required":
"Fel kell iratkoznia az üzenetek fordításához.",
"translation":
"{{translation}}\n-# {{language}} érzékelve {{confidence}}% bizalommal.",
"unsupported-locale": "A {{target}} nyelvet nem támogatja fordító szoftverünk.",
"button": {
code: "Forráskód",
support: "Segítségre van szüksége?",
},
"embed": {
commit: "Jelenlegi Commit",
description: "Az Aria Iuvo egy Discord bot, amely a LibreTranslate-et használja üzenetek fordításához. NHCarrigan fejlesztette. A bot használatához kattintson jobb gombbal egy üzenetre, válassza az `Apps` lehetőséget, majd válassza a `Translate message` opciót!",
title: "Az Aria Iuvoról",
version: "Futó Verzió",
},
"no-message-content": "Nem található üzenet tartalom.",
"subscription-required": "Feliratkozás szükséges az üzenetek fordításához.",
"translation": "{{translation}}\n-# {{language}} nyelv észlelve {{confidence}}% biztonsággal.",
"unsupported-locale": "A(z) {{target}} nyelvet nem támogatja a fordító szoftverünk.",
},
[Locale.Italian]: {
"no-message-content": "Nessun contenuto del messaggio trovato.",
"subscription-required":
"Devi essere abbonato per tradurre i messaggi.",
"translation":
"{{translation}}\n-# Rilevato {{language}} con {{confidence}}% di fiducia.",
"unsupported-locale": "La lingua {{target}} non è supportata dal nostro software di traduzione.",
"button": {
code: "Codice sorgente",
support: "Hai bisogno di aiuto?",
},
"embed": {
commit: "Commit Attuale",
description: "Aria Iuvo è un bot Discord che utilizza LibreTranslate per fornire traduzioni dei messaggi. È sviluppata da NHCarrigan. Per utilizzare il bot, fai clic destro su un messaggio, seleziona `Apps`, quindi seleziona `Translate message`!",
title: "Informazioni su Aria Iuvo",
version: "Versione in Esecuzione",
},
"no-message-content": "Nessun contenuto del messaggio trovato.",
"subscription-required": "Devi essere abbonato per tradurre i messaggi.",
"translation": "{{translation}}\n-# Rilevato {{language}} con {{confidence}}% di affidabilità.",
"unsupported-locale": "La lingua {{target}} non è supportata dal nostro software di traduzione.",
},
[Locale.Japanese]: {
"no-message-content": "メッセージコンテンツが見つかりません。",
"subscription-required":
"メッセージを翻訳するには購読する必要があります。",
"translation":
"{{translation}}\n-# {{confidence}}% の信頼度で {{language}} を検出しました。",
"unsupported-locale": "{{target}} 言語は、翻訳ソフトウェアでサポートされていません。",
"button": {
code: "ソースコード",
support: "サポートが必要ですか?",
},
"embed": {
commit: "現在のコミット",
description: "Aria Iuvoは、LibreTranslateを使用してメッセージの翻訳を提供するDiscordボットです。NHCarriganによって開発されました。ボットを使用するには、メッセージを右クリックし、`Apps`を選択し、`Translate message`を選択してください!",
title: "Aria Iuvoについて",
version: "実行中のバージョン",
},
"no-message-content": "メッセージの内容が見つかりません。",
"subscription-required": "メッセージを翻訳するには購読が必要です。",
"translation": "{{translation}}\n-# {{confidence}}%の確率で{{language}}を検出しました。",
"unsupported-locale": "言語{{target}}は翻訳ソフトウェアでサポートされていません。",
},
[Locale.Korean]: {
"no-message-content": "메시지 내용을 찾을 수 없습니다.",
"subscription-required":
"메시지를 번역하려면 구독해야 합니다.",
"translation":
"{{translation}}\n-# {{confidence}}% 신뢰도로 {{language}} 감지.",
"unsupported-locale": "{{target}} 언어는 번역 소프트웨어에서 지원되지 않습니다.",
"button": {
code: "소스 코드",
support: "도움이 필요하신가요?",
},
"embed": {
commit: "현재 커밋",
description: "Aria Iuvo는 LibreTranslate를 사용하여 메시지 번역을 제공하는 Discord 봇입니다. NHCarrigan이 개발했습니다. 봇을 사용하려면 메시지를 마우스 오른쪽 버튼으로 클릭하고 `Apps`를 선택한 다음 `Translate message`를 선택하세요!",
title: "Aria Iuvo 소개",
version: "실행 중인 버전",
},
"no-message-content": "메시지 내용을 찾을 수 없습니다.",
"subscription-required": "메시지를 번역하려면 구독이 필요합니다.",
"translation": "{{translation}}\n-# {{confidence}}% 신뢰도로 {{language}} 감지됨.",
"unsupported-locale": "언어 {{target}}는 번역 소프트웨어에서 지원되지 않습니다.",
},
[Locale.Lithuanian]: {
"no-message-content": "Nerasta jokio pranešimo turinio.",
"subscription-required":
"Norint išversti žinutes, turite būti prenumeratorius.",
"translation":
"{{translation}}\n-# Aptikta {{language}} su {{confidence}}% pasitikėjimu.",
"unsupported-locale": "{{target}} kalba nepalaikoma mūsų vertimo programine įranga.",
"button": {
code: "Išeities kodas",
support: "Reikia pagalbos?",
},
"embed": {
commit: "Dabartinis Commit",
description: "Aria Iuvo yra Discord botas, naudojantis LibreTranslate žinučių vertimams. Ją sukūrė NHCarrigan. Norėdami naudoti botą, dešiniuoju pelės klavišu spustelėkite žinutę, pasirinkite `Apps`, tada pasirinkite `Translate message`!",
title: "Apie Aria Iuvo",
version: "Veikianti Versija",
},
"no-message-content": "Žinutės turinio nerasta.",
"subscription-required": "Turite būti prenumeratorius, kad galėtumėte versti žinutes.",
"translation": "{{translation}}\n-# Aptikta {{language}} su {{confidence}}% tikimybe.",
"unsupported-locale": "Kalba {{target}} nėra palaikoma mūsų vertimo programinės įrangos.",
},
[Locale.Polish]: {
"no-message-content": "Nie znaleziono treści wiadomości.",
"subscription-required":
"Aby tłumaczyć wiadomości, musisz być subskrybentem.",
"translation":
"{{translation}}\n-# Wykryto {{language}} z {{confidence}}% pewnością.",
"unsupported-locale": "Język {{target}} nie jest obsługiwany przez nasze oprogramowanie do tłumaczenia.",
"button": {
code: "Kod źródłowy",
support: "Potrzebujesz pomocy?",
},
"embed": {
commit: "Aktualny Commit",
description: "Aria Iuvo to bot Discord, który używa LibreTranslate do tłumaczenia wiadomości. Została stworzona przez NHCarrigan. Aby użyć bota, kliknij prawym przyciskiem myszy na wiadomość, wybierz `Apps`, następnie wybierz `Translate message`!",
title: "O Aria Iuvo",
version: "Aktualna Wersja",
},
"no-message-content": "Nie znaleziono treści wiadomości.",
"subscription-required": "Musisz być subskrybentem, aby tłumaczyć wiadomości.",
"translation": "{{translation}}\n-# Wykryto {{language}} z {{confidence}}% pewnością.",
"unsupported-locale": "Język {{target}} nie jest obsługiwany przez nasze oprogramowanie do tłumaczeń.",
},
sv: {
"no-message-content": "Inget meddelandeinnehåll hittades.",
"subscription-required":
"Du måste prenumerera för att översätta meddelanden.",
"translation":
"{{translation}}\n-# Upptäckt {{language}} med {{confidence}}% förtroende.",
"unsupported-locale": "Språket {{target}} stöds inte av vår översättningsprogramvara.",
"button": {
code: "Källkod",
support: "Behöver du hjälp?",
},
"embed": {
commit: "Nuvarande Commit",
description: "Aria Iuvo är en Discord-bot som använder LibreTranslate för att tillhandahålla översättningar av meddelanden. Hon är utvecklad av NHCarrigan. För att använda boten, högerklicka på ett meddelande, välj `Apps`, välj sedan `Translate message`!",
title: "Om Aria Iuvo",
version: "Körande Version",
},
"no-message-content": "Inget meddelandeinnehåll hittades.",
"subscription-required": "Du måste prenumerera för att översätta meddelanden.",
"translation": "{{translation}}\n-# Upptäckte {{language}} med {{confidence}}% säkerhet.",
"unsupported-locale": "Språket {{target}} stöds inte av vår översättningsprogramvara.",
},
[Locale.Romanian]: {
"no-message-content": "Nu s-a găsit niciun conținut de mesaj.",
"subscription-required":
"Trebuie să fiți abonat pentru a traduce mesajele.",
"translation":
"{{translation}}\n-# Detectat {{language}} cu {{confidence}}% încredere.",
"unsupported-locale": "Limba {{target}} nu este acceptată de software-ul nostru de traducere.",
"button": {
code: "Cod sursă",
support: "Aveți nevoie de ajutor?",
},
"embed": {
commit: "Commit Curent",
description: "Aria Iuvo este un bot Discord care folosește LibreTranslate pentru a furniza traduceri pentru mesaje. Este dezvoltat de NHCarrigan. Pentru a folosi botul, faceți clic dreapta pe un mesaj, selectați `Apps`, apoi selectați `Translate message`!",
title: "Despre Aria Iuvo",
version: "Versiunea Curentă",
},
"no-message-content": "Nu s-a găsit conținutul mesajului.",
"subscription-required": "Trebuie să fiți abonat pentru a traduce mesaje.",
"translation": "{{translation}}\n-# Detectat {{language}} cu {{confidence}}% încredere.",
"unsupported-locale": "Limba {{target}} nu este suportată de software-ul nostru de traducere.",
},
[Locale.Russian]: {
"no-message-content": "Содержимое сообщения не найдено.",
"subscription-required":
"Вы должны быть подписаны на перевод сообщений.",
"translation":
"{{translation}}\n-# Обнаружен {{language}} с {{confidence}}% уверенностью.",
"unsupported-locale": "Язык {{target}} не поддерживается нашим программным обеспечением для перевода.",
"button": {
code: "Исходный код",
support: "Нужна помощь?",
},
"embed": {
commit: "Текущий Коммит",
description: "Aria Iuvo - это Discord бот, использующий LibreTranslate для перевода сообщений. Разработан NHCarrigan. Чтобы использовать бота, щелкните правой кнопкой мыши по сообщению, выберите `Apps`, затем выберите `Translate message`!",
title: "О Aria Iuvo",
version: "Текущая Версия",
},
"no-message-content": "Содержимое сообщения не найдено.",
"subscription-required": "Для перевода сообщений необходима подписка.",
"translation": "{{translation}}\n-# Обнаружен {{language}} с уверенностью {{confidence}}%.",
"unsupported-locale": "Язык {{target}} не поддерживается нашим программным обеспечением для перевода.",
},
zh: {
"button": {
code: "源代码",
support: "需要帮助?",
},
"embed": {
commit: "当前提交",
description: "Aria Iuvo是一个使用LibreTranslate提供消息翻译的Discord机器人。由NHCarrigan开发。要使用机器人右键点击消息选择`Apps`,然后选择`Translate message`",
title: "关于Aria Iuvo",
version: "运行版本",
},
"no-message-content": "未找到消息内容。",
"subscription-required": "您必须订阅以翻译消息。",
"translation":
"{{translation}}\n-# 检测到 {{language}}{{confidence}}% 的信心。",
"unsupported-locale": "我们的翻译软件不支持 {{target}} 语言。",
"subscription-required": "您必须订阅才能翻译消息。",
"translation": "{{translation}}\n-# 检测到{{language}},置信度为{{confidence}}%。",
"unsupported-locale": "我们的翻译软件不支持{{target}}语言。",
},
zt: {
"no-message-content": "未找到消息内容。",
"subscription-required": "您必须订阅以翻译消息。",
"translation":
"{{translation}}\n-# 检测到 {{language}}{{confidence}}% 的信心。",
"unsupported-locale": "我们的翻译软件不支持 {{target}} 语言。",
"button": {
code: "原始碼",
support: "需要幫助?",
},
"embed": {
commit: "當前提交",
description: "Aria Iuvo是一個使用LibreTranslate提供訊息翻譯的Discord機器人。由NHCarrigan開發。要使用機器人右鍵點擊訊息選擇`Apps`,然後選擇`Translate message`",
title: "關於Aria Iuvo",
version: "運行版本",
},
"no-message-content": "未找到訊息內容。",
"subscription-required": "您必須訂閱才能翻譯訊息。",
"translation": "{{translation}}\n-# 檢測到{{language}},置信度為{{confidence}}%。",
"unsupported-locale": "我們的翻譯軟件不支持{{target}}語言。",
},
[Locale.Thai]: {
"no-message-content": "ไม่พบเนื้อหาข้อความ",
"subscription-required":
"คุณต้องสมัครสมาชิกเพื่อแปลข้อความ",
"translation":
"{{translation}}\n-# ตรวจพบ {{language}} ด้วยความมั่นใจ {{confidence}}%",
"unsupported-locale": "ภาษา {{target}} ไม่ได้รับการสนับสนุนโดยซอฟต์แวร์แปลของเรา",
"button": {
code: "ซอร์สโค้ด",
support: "ต้องการความช่วยเหลือ?",
},
"embed": {
commit: "คอมมิตปัจจุบัน",
description: "Aria Iuvo เป็นบอท Discord ที่ใช้ LibreTranslate เพื่อแปลข้อความ พัฒนาโดย NHCarrigan ในการใช้บอท ให้คลิกขวาที่ข้อความ เลือก `Apps` จากนั้นเลือก `Translate message`!",
title: "เกี่ยวกับ Aria Iuvo",
version: "เวอร์ชันที่ใช้งาน",
},
"no-message-content": "ไม่พบเนื้อหาข้อความ",
"subscription-required": "คุณต้องเป็นสมาชิกเพื่อแปลข้อความ",
"translation": "{{translation}}\n-# ตรวจพบ {{language}} ด้วยความเชื่อมั่น {{confidence}}%",
"unsupported-locale": "ภาษา {{target}} ไม่รองรับโดยซอฟต์แวร์แปลภาษาของเรา",
},
[Locale.Turkish]: {
"no-message-content": "Hiçbir mesaj içeriği bulunamadı.",
"subscription-required":
"Mesajları çevirmek için abone olmalısınız.",
"translation":
"{{translation}}\n-# {{confidence}}% güvenle {{language}} tespit edildi.",
"unsupported-locale": "{{target}} dilimiz tarafından desteklenmiyor.",
"button": {
code: "Kaynak kodu",
support: "Yardıma mı ihtiyacınız var?",
},
"embed": {
commit: "Mevcut Commit",
description: "Aria Iuvo, mesajlar için çeviri sağlamak üzere LibreTranslate kullanan bir Discord botudur. NHCarrigan tarafından geliştirilmiştir. Botu kullanmak için, bir mesaja sağ tıklayın, `Apps`'i seçin, ardından `Translate message`'ı seçin!",
title: "Aria Iuvo Hakkında",
version: "Çalışan Sürüm",
},
"no-message-content": "Mesaj içeriği bulunamadı.",
"subscription-required": "Mesajları çevirmek için abone olmanız gerekiyor.",
"translation": "{{translation}}\n-# {{confidence}}% güvenle {{language}} tespit edildi.",
"unsupported-locale": "{{target}} dili çeviri yazılımımız tarafından desteklenmiyor.",
},
[Locale.Ukrainian]: {
"no-message-content": "Не знайдено вмісту повідомлення.",
"subscription-required":
"Ви повинні підписатися на переклад повідомлень.",
"translation":
"{{translation}}\n-# Виявлено {{language}} з {{confidence}}% впевненістю.",
"unsupported-locale": "Мова {{target}} не підтримується нашим програмним забезпеченням для перекладу.",
"button": {
code: "Вихідний код",
support: "Потрібна допомога?",
},
"embed": {
commit: "Поточний Коміт",
description: "Aria Iuvo - це Discord бот, який використовує LibreTranslate для перекладу повідомлень. Розроблений NHCarrigan. Щоб використовувати бота, клацніть правою кнопкою миші на повідомленні, виберіть `Apps`, потім виберіть `Translate message`!",
title: "Про Aria Iuvo",
version: "Поточна Версія",
},
"no-message-content": "Вміст повідомлення не знайдено.",
"subscription-required": "Для перекладу повідомлень потрібна підписка.",
"translation": "{{translation}}\n-# Виявлено {{language}} з впевненістю {{confidence}}%.",
"unsupported-locale": "Мова {{target}} не підтримується нашим програмним забезпеченням для перекладу.",
},
};

View File

@ -4,6 +4,7 @@
* @author Naomi Carrigan
*/
import { Client, Events } from "discord.js";
import { about } from "./modules/about.js";
import { translate } from "./modules/translate.js";
import { instantiateServer } from "./server/serve.js";
import { logHandler } from "./utils/logHandler.js";
@ -16,6 +17,9 @@ client.on(Events.InteractionCreate, (interaction) => {
if (interaction.isMessageContextMenuCommand()) {
void translate(interaction);
}
if (interaction.isChatInputCommand()) {
void about(interaction);
}
});
client.on(Events.ClientReady, () => {

67
src/modules/about.ts Normal file
View File

@ -0,0 +1,67 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { execSync } from "node:child_process";
import {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
EmbedBuilder,
MessageFlags,
type ChatInputCommandInteraction,
} from "discord.js";
import { i18n } from "../utils/i18n.js";
import { getLocale } from "./getLocale.js";
/**
* Responds with information about the bot.
* @param interaction -- The interaction payload from Discord.
*/
export const about
= async(interaction: ChatInputCommandInteraction): Promise<void> => {
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
const targetLocale = getLocale(interaction);
const version = process.env.npm_package_version ?? "Unknown";
const commit = execSync("git rev-parse --short HEAD").toString().
trim();
const embed = new EmbedBuilder();
embed.setTitle(i18n("embed.title", targetLocale));
embed.setDescription(i18n("embed.description", targetLocale));
embed.addFields(
{
name: i18n("embed.version", targetLocale),
value: version,
},
{
name: i18n("embed.commit", targetLocale),
value: commit,
},
);
const supportButton = new ButtonBuilder().
setLabel(i18n("button.support", targetLocale)).
setStyle(ButtonStyle.Link).
setURL("https://chat.nhcarrigan.com");
const sourceButton = new ButtonBuilder().
setLabel(i18n("button.code", targetLocale)).
setStyle(ButtonStyle.Link).
setURL("https://git.nhcarrigan.com/nhcarrigan/aria-iuvo");
const subscribeButton = new ButtonBuilder().
setStyle(ButtonStyle.Premium).
setSKUId("1338596712121499669");
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
supportButton,
sourceButton,
subscribeButton,
);
await interaction.editReply({
components: [ row ],
embeds: [ embed ],
});
};

View File

@ -5,7 +5,7 @@
*/
import { mappedLocales } from "../config/locales.js";
import type { MessageContextMenuCommandInteraction } from "discord.js";
import type { CommandInteraction } from "discord.js";
/**
* Parses the locale from the interaction, using our mapped
@ -14,7 +14,7 @@ import type { MessageContextMenuCommandInteraction } from "discord.js";
* @returns The locale string.
*/
export const getLocale = (
interaction: MessageContextMenuCommandInteraction,
interaction: CommandInteraction,
): string => {
if (mappedLocales[interaction.locale] !== undefined) {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- It's not undefined.

View File

@ -5,6 +5,9 @@
*/
import {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
MessageFlags,
type MessageContextMenuCommandInteraction,
} from "discord.js";
@ -28,8 +31,15 @@ export const translate = async(
});
if (!isEntitled && interaction.user.id !== "465650873650118659") {
const subscribeButton = new ButtonBuilder().
setStyle(ButtonStyle.Premium).
setSKUId("1338596712121499669");
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
subscribeButton,
);
await interaction.editReply({
content: i18n("subscription-required", targetLocale),
components: [ row ],
content: i18n("subscription-required", targetLocale),
});
return;
}

View File

@ -3,25 +3,58 @@
* @license Naomi's Public License
* @author Naomi Carrigan
*/
/* eslint-disable @typescript-eslint/no-non-null-assertion -- We've already asserted the language exists through our typeguard.*/
/* eslint-disable unicorn/no-array-reduce -- It's a clean approach here and makes sense. */
/* eslint-disable @typescript-eslint/consistent-type-assertions -- We have likely over-engineered the hell out of this...*/
import { responses } from "../i18n/responses.js";
const isTranslatedLocale = (
locale: string,
): locale is keyof typeof responses => {
return locale in responses;
};
/**
* Translates a key to the specified locale, performing
* interpolation on the string.
* @param key -- The key to translate.
* @param locale -- The user's locale.
* @param rawLocale -- The user's locale.
* @param interpolation -- An object of keys to replace with values.
* @returns The translated string.
*/
export const i18n = (
key: keyof (typeof responses)["en"],
locale: string,
key:
| keyof (typeof responses)["en"]
| `embed.${keyof (typeof responses)["en"]["embed"]}`
| `button.${keyof (typeof responses)["en"]["button"]}`,
rawLocale: string,
interpolation: Record<string, unknown> = {},
): string => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- We know the en key exists, but having the loose type helps.
const string = responses[locale]?.[key] ?? responses.en![key];
// eslint-disable-next-line unicorn/no-array-reduce -- This is the cleanest way to do it, really.
const locale: keyof typeof responses = isTranslatedLocale(rawLocale)
? rawLocale
: "en";
const isNestedProperty = key.startsWith("embed.")
|| key.startsWith("button.");
if (isNestedProperty) {
const [ category, property ] = key.split(".") as
| ["embed", keyof (typeof responses)["en"]["embed"]]
| ["button", keyof (typeof responses)["en"]["button"]];
if (category === "embed") {
const string = responses[locale]![category][property];
return Object.entries(interpolation).reduce((accumulator, [ k, v ]) => {
return accumulator.replace(`{{${k}}}`, String(v));
}, string);
}
const string = responses[locale]![category][property];
return Object.entries(interpolation).reduce((accumulator, [ k, v ]) => {
return accumulator.replace(`{{${k}}}`, String(v));
}, string);
}
const string
= responses[locale]![
key as Exclude<keyof (typeof responses)["en"], "embed" | "button">
];
return Object.entries(interpolation).reduce((accumulator, [ k, v ]) => {
return accumulator.replace(`{{${k}}}`, String(v));
}, string);

View File

@ -7,16 +7,74 @@
import { describe, it, expect } from "vitest";
import { supportedLocales, mappedLocales } from "../src/config/locales.js";
const localesSupportedByLibretranslate = [ "ar", "az", "bg", "bn", "ca", "cs", "da", "de", "el", "en", "eo", "es", "et", "eu", "fa", "fi", "fr", "ga", "gl", "he", "hi", "hu", "id", "it", "ja", "ko", "lt", "lv", "ms", "nb", "nl", "pl", "pt", "ro", "ru", "sk", "sl", "sq", "sv", "th", "tl", "tr", "uk", "ur", "zh", "zt" ];
const localesSupportedByLibretranslate = [
"ar",
"az",
"bg",
"bn",
"ca",
"cs",
"da",
"de",
"el",
"en",
"eo",
"es",
"et",
"eu",
"fa",
"fi",
"fr",
"ga",
"gl",
"he",
"hi",
"hu",
"id",
"it",
"ja",
"ko",
"lt",
"lv",
"ms",
"nb",
"nl",
"pl",
"pt",
"ro",
"ru",
"sk",
"sl",
"sq",
"sv",
"th",
"tl",
"tr",
"uk",
"ur",
"zh",
"zt",
];
describe("i18n locales", () => {
it.each(supportedLocales)("%s should be supported by libretranslate", (lang) => {
expect.assertions(1);
expect(localesSupportedByLibretranslate, `${lang} is not supported by libretranslate`).toContain(lang);
});
it.each(supportedLocales)(
"%s should be supported by libretranslate",
(lang) => {
expect.assertions(1);
expect(
localesSupportedByLibretranslate,
`${lang} is not supported by libretranslate`,
).toContain(lang);
},
);
it.each(Object.values(mappedLocales))("%s should be mapped to a supported locale", (lang) => {
expect.assertions(1);
expect(supportedLocales, `${lang} is not supported by our app`).toContain(lang);
});
it.each(Object.values(mappedLocales))(
"%s should be mapped to a supported locale",
(lang) => {
expect.assertions(1);
expect(supportedLocales, `${lang} is not supported by our app`).toContain(
lang,
);
},
);
});