From 1b419ca39ec0945899ae660d5402361e20590a0f Mon Sep 17 00:00:00 2001 From: LemonNeko Date: Mon, 1 Apr 2024 08:57:59 +0800 Subject: [PATCH] [i18n] provide localizations for discord command description (#198) --- internal/bots/discord/listeners/listeners.go | 2 +- locales/en.yaml | 24 ++++++++++---------- pkg/bots/discordbot/commanddef.go | 21 ++++++++++++++--- pkg/linkprev/linkprev_test.go | 4 ++-- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/internal/bots/discord/listeners/listeners.go b/internal/bots/discord/listeners/listeners.go index 6e079c3..fb59a8b 100644 --- a/internal/bots/discord/listeners/listeners.go +++ b/internal/bots/discord/listeners/listeners.go @@ -56,7 +56,7 @@ func (b *Listeners) smrCmd(event *events.ApplicationCommandInteractionCreate, da b.logger.Info(fmt.Sprintf("discord: command received: /smr %s", urlString)) - lang := event.Locale().String() + lang := event.Locale().Code() // url check err, originErr := smr.CheckUrl(urlString) diff --git a/locales/en.yaml b/locales/en.yaml index d973e70..1f71388 100644 --- a/locales/en.yaml +++ b/locales/en.yaml @@ -20,7 +20,7 @@ system: modules: telegram: - chatMigration: + chatMigration: '' notification: | {{.Name}} @{{.Username}} has observed your group's upgrading to a supergroup, where the group ID will change. Rest assured, we've smoothly transitioned all historical data to the new group ID, while maintaining all your settings unaltered. However, due to Telegram's limitations, message IDs from before the upgrade won't match those sent after and will thus be excluded from future summaries. We regret any inconvenience caused by such migrations. @@ -69,17 +69,17 @@ commands: commands: smr: help: Enhance your article reading with Quantum Speed-Reading. This feature enables rapid understanding of web content and is compatible across messaging platforms. Initiate with :/smr <link>. - noLinksFound: - telegram: No link detected. Please provide a valid URL to proceed. Example usage:/smr <link>. - slackOrDiscord: No link detected. Please provide a valid URL to proceed. Example usage:`/smr `. - invalidLink: - telegram: The link provided could not be processed. Please ensure the URL is correct and try again. Usage:/smr <link>. - slackOrDiscord: The link provided could not be processed. Please ensure the URL is correct and try again. Usage:`/smr `. - reading: Quantum Speed-Reading is currently processing your request, please wait... - rateLimitExceeded: Apologies, but you've reached the rate limit to maintain service stability. This command is accessible once every {{ .Seconds }} seconds. Kindly wait {{ .SecondsToBeWaited }} seconds before attempting again. We appreciate your patience and comprehension. - failedToRead: Quantum Speed-Reading was unsuccessful. Would you like to retry? - failedToReadDueToFailedToFetch: Encountered an issue retrieving the content for Quantum Speed-Reading. Perhaps another attempt might succeed? - contentNotSupported: This content is not supported by Quantum Speed-Reading. Considering another link might be beneficial. + noLinksFound: + telegram: No link detected. Please provide a valid URL to proceed. Example usage:/smr <link>. + slackOrDiscord: No link detected. Please provide a valid URL to proceed. Example usage:`/smr `. + invalidLink: + telegram: The link provided could not be processed. Please ensure the URL is correct and try again. Usage:/smr <link>. + slackOrDiscord: The link provided could not be processed. Please ensure the URL is correct and try again. Usage:`/smr `. + reading: Quantum Speed-Reading is currently processing your request, please wait... + rateLimitExceeded: Apologies, but you've reached the rate limit to maintain service stability. This command is accessible once every {{ .Seconds }} seconds. Kindly wait {{ .SecondsToBeWaited }} seconds before attempting again. We appreciate your patience and comprehension. + failedToRead: Quantum Speed-Reading was unsuccessful. Would you like to retry? + failedToReadDueToFailedToFetch: Encountered an issue retrieving the content for Quantum Speed-Reading. Perhaps another attempt might succeed? + contentNotSupported: This content is not supported by Quantum Speed-Reading. Considering another link might be beneficial. prompts: smr: diff --git a/pkg/bots/discordbot/commanddef.go b/pkg/bots/discordbot/commanddef.go index 9c34dc2..22724f4 100644 --- a/pkg/bots/discordbot/commanddef.go +++ b/pkg/bots/discordbot/commanddef.go @@ -6,11 +6,26 @@ var commands = []discord.ApplicationCommandCreate{ discord.SlashCommandCreate{ Name: "smr", Description: "对网页进行总结", + DescriptionLocalizations: map[discord.Locale]string{ + discord.LocaleChineseCN: "对网页进行总结", + discord.LocaleEnglishUS: "Summarize a web article", + discord.LocaleEnglishGB: "Summarize a web article", + }, Options: []discord.ApplicationCommandOption{ discord.ApplicationCommandOptionString{ - Required: true, - Name: "link", - Description: "网页链接", + Required: true, + Name: "link", + NameLocalizations: map[discord.Locale]string{ + discord.LocaleChineseCN: "文章链接", + discord.LocaleEnglishUS: "link", + discord.LocaleEnglishGB: "link", + }, + Description: "The link of web article", + DescriptionLocalizations: map[discord.Locale]string{ + discord.LocaleChineseCN: "需要被总结的文章的链接", + discord.LocaleEnglishUS: "The link of web article", + discord.LocaleEnglishGB: "The link of web article", + }, }, }, }, diff --git a/pkg/linkprev/linkprev_test.go b/pkg/linkprev/linkprev_test.go index 487d772..b7da074 100644 --- a/pkg/linkprev/linkprev_test.go +++ b/pkg/linkprev/linkprev_test.go @@ -19,9 +19,9 @@ func TestPreview(t *testing.T) { Title: "Nólëbase | 记录回忆,知识和畅想的地方", Description: "记录回忆,知识和畅想的地方", Favicon: "/logo.svg", - Author: "Ayaka Neko, Ayaka Rizumu", + Author: "絢香猫, 絢香音", Keywords: []string{ - "markdown, knowledgebase, 知识库, vitepress, obsidian, notebook, notes, nekomeowww, littlesound", + "markdown, knowledge-base, 知识库, vitepress, obsidian, notebook, notes, nekomeowww, LittleSound", }, OpenGraph: opengraph.OpenGraph{ Title: "Nólëbase",