diff --git a/assets/localisations/parameters/en-US.json b/assets/localisations/parameters/en-US.json index 9a78529a4..ec0734477 100644 --- a/assets/localisations/parameters/en-US.json +++ b/assets/localisations/parameters/en-US.json @@ -1,22 +1,22 @@ { - "user.name": "user", - "user.description": "The user's username, tag, ID or mention.", - "show.name": "show", - "show.description": "If set to true, the result will be shown to others.", + "parameters.user.name": "user", + "parameters.user.description": "The user's username, tag, ID or mention.", + "parameters.show.name": "show", + "parameters.show.description": "If set to true, the result will be shown to others.", - "duration.name": "duration", - "duration.description": "The duration of the sanction.", - "reason.name": "reason", - "reason.description": "The reason for the sanction or its repeal. It should be descriptive.", + "parameters.duration.name": "duration", + "parameters.duration.description": "The duration of the sanction.", + "parameters.reason.name": "reason", + "parameters.reason.description": "The reason for the sanction or its repeal. It should be descriptive.", - "query.name": "query", - "query.description": "The title or a link to the song or song collection.", - "timestamp.name": "timestamp", - "timestamp.description": "The timestamp to seek.", - "collection.name": "collection", - "collection.description": "If set to true, the action will be taken on the song collection instead.", - "by.name": "by", - "by.description": "The number of songs or song listings to skip by.", - "to.name": "to", - "to.description": "The index of the track to skip to." + "parameters.query.name": "query", + "parameters.query.description": "The title or a link to the song or song collection.", + "parameters.timestamp.name": "timestamp", + "parameters.timestamp.description": "The timestamp to seek.", + "parameters.collection.name": "collection", + "parameters.collection.description": "If set to true, the action will be taken on the song collection instead.", + "parameters.by.name": "by", + "parameters.by.description": "The number of songs or song listings to skip by.", + "parameters.to.name": "to", + "parameters.to.description": "The index of the track to skip to." } diff --git a/assets/localisations/parameters/hu.json b/assets/localisations/parameters/hu.json index d8413bf22..a161781be 100644 --- a/assets/localisations/parameters/hu.json +++ b/assets/localisations/parameters/hu.json @@ -1,22 +1,22 @@ { - "user.name": "felhasználó", - "user.description": "A felhasználó neve, tagje, ID-je vagy megemlítése.", - "show.name": "megjelenítés", - "show.description": "Ha igaz, a találatok másoknak is láthatóvá válnak.", + "parameters.user.name": "felhasználó", + "parameters.user.description": "A felhasználó neve, tagje, ID-je vagy megemlítése.", + "parameters.show.name": "megjelenítés", + "parameters.show.description": "Ha igaz, a találatok másoknak is láthatóvá válnak.", - "duration.name": "időtartam", - "duration.description": "A szankció időtartama.", - "reason.name": "ok", - "reason.description": "A szankciónak vagy visszavonásának oka. Legyen kifejező.", + "parameters.duration.name": "időtartam", + "parameters.duration.description": "A szankció időtartama.", + "parameters.reason.name": "ok", + "parameters.reason.description": "A szankciónak vagy visszavonásának oka. Legyen kifejező.", - "query.name": "lekérés", - "query.description": "", - "timestamp.name": "különbség", - "timestamp.description": "", - "collection.name": "gyűjtemény", - "collection.description": "Ha igaz, akkor a művelet a zenegyűjteményen lesz végrehajtva.", - "by.name": "lépték", - "by.description": "Az átugrandó elemek száma.", - "to.name": "cél", - "to.description": "Az ugrás végcéljának indexe." + "parameters.query.name": "lekérés", + "parameters.query.description": "", + "parameters.timestamp.name": "különbség", + "parameters.timestamp.description": "", + "parameters.collection.name": "gyűjtemény", + "parameters.collection.description": "Ha igaz, akkor a művelet a zenegyűjteményen lesz végrehajtva.", + "parameters.by.name": "lépték", + "parameters.by.description": "Az átugrandó elemek száma.", + "parameters.to.name": "cél", + "parameters.to.description": "Az ugrás végcéljának indexe." } diff --git a/assets/localisations/parameters/pl.json b/assets/localisations/parameters/pl.json index 0eec3694a..8761c3f60 100644 --- a/assets/localisations/parameters/pl.json +++ b/assets/localisations/parameters/pl.json @@ -1,22 +1,22 @@ { - "user.name": "użytkownik", - "user.description": "Nazwa użytkownika, jego tag, ID lub wzmianka.", - "show.name": "wyświetl", - "show.description": "Jeśli tak, rezultat będzie wyświetlony innym użytkownikom.", + "parameters.user.name": "użytkownik", + "parameters.user.description": "Nazwa użytkownika, jego tag, ID lub wzmianka.", + "parameters.show.name": "wyświetl", + "parameters.show.description": "Jeśli tak, rezultat będzie wyświetlony innym użytkownikom.", - "duration.name": "okres", - "duration.description": "Jak długo sankcja ma trwać.", - "reason.name": "powód", - "reason.description": "Powód dla sankcji lub dla jej uchylenia. Powinien być szczegółowy.", + "parameters.duration.name": "okres", + "parameters.duration.description": "Jak długo sankcja ma trwać.", + "parameters.reason.name": "powód", + "parameters.reason.description": "Powód dla sankcji lub dla jej uchylenia. Powinien być szczegółowy.", - "query.name": "zapytanie", - "query.description": "Tytuł lub link do utworu lub zbioru utworów.", - "timestamp.name": "znacznik-czasu", - "timestamp.description": "Znacznik czasu w piosence, określający dokąd przewinąć.", - "collection.name": "zbiór", - "collection.description": "Jeśli tak, działanie zostanie wykonane na zbiorze utworów.", - "by.name": "o", - "by.description": "Liczba utworów lub wpisów, które mają być przewinięte.", - "to.name": "do", - "to.description": "Indeks utworu lub wpisu do którego przewinąć." + "parameters.query.name": "zapytanie", + "parameters.query.description": "Tytuł lub link do utworu lub zbioru utworów.", + "parameters.timestamp.name": "znacznik-czasu", + "parameters.timestamp.description": "Znacznik czasu w piosence, określający dokąd przewinąć.", + "parameters.collection.name": "zbiór", + "parameters.collection.description": "Jeśli tak, działanie zostanie wykonane na zbiorze utworów.", + "parameters.by.name": "o", + "parameters.by.description": "Liczba utworów lub wpisów, które mają być przewinięte.", + "parameters.to.name": "do", + "parameters.to.description": "Indeks utworu lub wpisu do którego przewinąć." } diff --git a/assets/localisations/parameters/ro.json b/assets/localisations/parameters/ro.json index 084f6e6a6..8c5fe6605 100644 --- a/assets/localisations/parameters/ro.json +++ b/assets/localisations/parameters/ro.json @@ -1,22 +1,22 @@ { - "user.name": "utilizator", - "user.description": "Numele de utilizator, tag-ul, ID-ul sau mențiunea utilizatorului.", - "show.name": "afișare", - "show.description": "Dacă da, rezultatul va fi afișat altor utilizatori.", + "parameters.user.name": "utilizator", + "parameters.user.description": "Numele de utilizator, tag-ul, ID-ul sau mențiunea utilizatorului.", + "parameters.show.name": "afișare", + "parameters.show.description": "Dacă da, rezultatul va fi afișat altor utilizatori.", - "duration.name": "durată", - "duration.description": "Durata sancțiunii.", - "reason.name": "motiv", - "reason.description": "Motivul pentru sancțiune sau anularea acesteia. Ar trebui să fie detaliat.", + "parameters.duration.name": "durată", + "parameters.duration.description": "Durata sancțiunii.", + "parameters.reason.name": "motiv", + "parameters.reason.description": "Motivul pentru sancțiune sau anularea acesteia. Ar trebui să fie detaliat.", - "query.name": "interogare", - "query.description": "Titlul melodiei, link-ul către aceasta sau către unui set de melodii.", - "timestamp.name": "marcaj-de-timp", - "timestamp.description": "Marcajul de timp din cântec la care să se treacă.", - "collection.name": "set", - "collection.description": "Dacă da, acțiunea va fi efectuată pe set de melodii.", - "by.name": "cu", - "by.description": "Numărul de melodii sau de înregistrări care să fie sărite peste.", - "to.name": "până-la", - "to.description": "Indexul melodiei sau al înregistrării până la care să fie sărit peste." + "parameters.query.name": "interogare", + "parameters.query.description": "Titlul melodiei, link-ul către aceasta sau către unui set de melodii.", + "parameters.timestamp.name": "marcaj-de-timp", + "parameters.timestamp.description": "Marcajul de timp din cântec la care să se treacă.", + "parameters.collection.name": "set", + "parameters.collection.description": "Dacă da, acțiunea va fi efectuată pe set de melodii.", + "parameters.by.name": "cu", + "parameters.by.description": "Numărul de melodii sau de înregistrări care să fie sărite peste.", + "parameters.to.name": "până-la", + "parameters.to.description": "Indexul melodiei sau al înregistrării până la care să fie sărit peste." } diff --git a/src/client.ts b/src/client.ts index 6964afbc9..a5f7b2a3d 100644 --- a/src/client.ts +++ b/src/client.ts @@ -470,12 +470,15 @@ function withRateLimiting(handle: InteractionHandler): InteractionHandler { function localiseCommands(localisations: Client['localisations'], commandTemplates: CommandTemplate[]): Command[] { function localiseCommandOrOption(key: string): Pick | undefined { - const nameLocalisationsAll = localisations.get(`${key}.name`); + const optionName = key.split('.')!.at(-1)!; + + const nameLocalisationsAll = localisations.get(`${key}.name`) ?? localisations.get(`parameters.${optionName}.name`); const nameLocalisations = nameLocalisationsAll !== undefined ? toDiscordLocalisations(nameLocalisationsAll) : undefined; - const descriptionLocalisationsAll = localisations.get(`${key}.description`); + const descriptionLocalisationsAll = localisations.get(`${key}.description`) ?? + localisations.get(`parameters.${optionName}.description`); const description = descriptionLocalisationsAll?.get(defaultLanguage)?.({}); const descriptionLocalisations = descriptionLocalisationsAll !== undefined ? toDiscordLocalisations(descriptionLocalisationsAll) @@ -510,6 +513,16 @@ function localiseCommands(localisations: Client['localisations'], commandTemplat const subOption: Option = { ...localisations, ...subOptionTemplate, options: [] }; + for (let subSubOptionTemplate of subOptionTemplate.options ?? []) { + const subSubOptionKey = [subOptionKey, 'options', subSubOptionTemplate.name].join('.'); + const localisations = localiseCommandOrOption(subSubOptionKey); + if (localisations === undefined) continue; + + const subSubOption: Option = { ...localisations, ...subSubOptionTemplate, options: [] }; + + subOption.options?.push(subSubOption); + } + option.options?.push(subOption); }