How to get the resolve a key without a target?
š Is there a way to access the locale strings using the i18next plugin passing the language instead of delegate it to the
fetchLanguage
?
I'd love to have the nameLocalizations
and descriptionLocalizations
on my slash commands coming from the i18n json files. That will make it easy to collaborative translation.
Something like:
Maybe something like resolKey('language', 'ping:success')
Solution:Jump to solution
Use applyLocalizedBuilder š
Exemple:
```ts
import { Subcommand } from '@kaname-png/plugin-subcommands-advanced';...
10 Replies
Solution
Use applyLocalizedBuilder š
Exemple:
WoW! I did not know that exists. Thanks!
In your case, this would look like this
Quick tip about it btw - mind the max lengths. With ArchId bots Kyra and I have noticed that sometimes they get exceeded by external translators (we use Crowdin). Crowdin however has the capability to let you set length limits for certain strings.
Quick question regards the
applyLocalizedBuilder
where the language coming from? Is this based on user language on guild, guild language? I realized that is not provided by the i18n fetchLanguage
, right?It goes through
fetchLanguage
if there is no value it searches if a language is configured on the server if none it returns the default value you have configured.@Swiizyy I don't see it relaying on the
fetchLanguage
it seems to get the language information from the user discord language preference. If the user change the discord language the slash command name/description set using applyLocalizedBuilder
will follow that choice not what I set in the fetchLanguage
your file system,
src/languages
by default. It iterates over all available languages.
see the guide for how to use the i18next plugin
should be in the getting started infoSorry maybe I was not clean in my question.
Let's say I'm configuring my slash command using the
applyLocalizedBuilder
:
Let's say I have provide 2 differente languages in the language
folder:
And in my fetchLanguage
I'm returning a fixed locale:
If the user set the language for pt-BR
in the Discord language setting, the Slash command name and description will be in pt-BR
instead of en-US
. That means the applyLocalizedBuilder
does not relay on the fetchLanguage
for set the name and description of the Slash Command, but all messages using resolveKey
for example resolveKey(interaction, 'commands/ping:reply')
will be in en-US
because that relays on the fetchLanguage
. Is that right?That means the applyLocalizedBuilder does not relay on the fetchLanguage for set the name and description of the Slash Commandno because
applyLocalizedBuilder
is on the builder. It adds to the data being sent to the Discord API when registering the command. The JSON object has name_localization
and description_localization
properties which are a key/value map of languages and their values.
but all messages using resolveKey for example resolveKey(interaction, 'commands/ping:reply') will be in en-US because that relays on the fetchLanguage. Is that rightThat's right, because that's a runtime check as opposed to a register-time check. Sidenote you mentioned
pt-BR
and en-US
here which are valid but be careful with the language codes. The full list of codes for Discord are in the Discord API docs I think but otherwise they are: