i18n options are not considered

Hi, While I try to refactor my code I want to implement the i18n plugin the way it is intended. When I call the resolveKey() method i18n wont consider my passed options. Example
await resolveKey(interaction, "help:about_description", {
website: await resolveKey(interaction, "repeating:homepage")
}
await resolveKey(interaction, "help:about_description", {
website: await resolveKey(interaction, "repeating:homepage")
}
The respective content from the json file
"about_description": "[About/Website]({{website}}"
"about_description": "[About/Website]({{website}}"
Every resolveKey() without options works perfectly fine but not with options. Any ideas?
22 Replies
Favna
Favna14mo ago
Guess I'll have to setup the plugin in my test bot after all to properly test this...
ShowCast
ShowCast14mo ago
I'm looking forward to it <:Peepo_Happy:832181382595870730>
Swiizyy
Swiizyy14mo ago
It seems to return an error if the default value is not added.
Favna
Favna14mo ago
uh that's weird I thought I checked for that
Swiizyy
Swiizyy14mo ago
@Favna Before/after default value complete
No description
No description
Swiizyy
Swiizyy14mo ago
it's this undefined that's causing the problem, it should be deleted
No description
Swiizyy
Swiizyy14mo ago
@Favna look at the value next to undefined this is not what should be used 😅 switching from defaultValueOrOptions to optionsOrUndefined should solve all problems
Favna
Favna14mo ago
I think you mean the other way around right? Can you make a PR? and deleting that undefined causes type issues pretty sure Either way if you can make a PR, much appreciated.
Swiizyy
Swiizyy14mo ago
If I make a PR for this I can solve a problem on the subcommands in passing?
Favna
Favna14mo ago
Not sure what you mean but make it a separate PR for changelog scoping please
Swiizyy
Swiizyy14mo ago
Ok no problem 👌
ShowCast
ShowCast14mo ago
So the third parameter is for the defaultKey and the options I want to pass is the fourth paramter did I get this right?
Swiizyy
Swiizyy14mo ago
GitHub
fix(plugin-i18next): :bug: fix options passed if not have default v...
The value passed to theresolveKey function was incorrect, resulting in errors every time it was called. This PR corrects this problem.
ShowCast
ShowCast14mo ago
Another strange behaviour:
chatInputApplicationCommandMention('help', clientContainer.env.string('HELP_COMMAND_ID'))
chatInputApplicationCommandMention('help', clientContainer.env.string('HELP_COMMAND_ID'))
returns the correct string </help:946826618553401416> If I call this within resolveKey
await resolveKey(interaction, Language.buildCommandTranslationKey(CommandType.help, 'help_command'), '', {
command: chatInputApplicationCommandMention('help', clientContainer.env.string('HELP_COMMAND_ID'))
})
await resolveKey(interaction, Language.buildCommandTranslationKey(CommandType.help, 'help_command'), '', {
command: chatInputApplicationCommandMention('help', clientContainer.env.string('HELP_COMMAND_ID'))
})
The return value is &lt;&#x2F;help:946826618553401416&gt;. Am I doing something wrong?
Swiizyy
Swiizyy14mo ago
I don't have this problem on my side...
ShowCast
ShowCast14mo ago
I tested around.
await resolveKey(interaction, Language.buildCommandTranslationKey(CommandType.help, 'help_command'), '', {
command: '</help:946826618553401416>'
})
await resolveKey(interaction, Language.buildCommandTranslationKey(CommandType.help, 'help_command'), '', {
command: '</help:946826618553401416>'
})
Outputs the correct string. The string from resolveKey with the chatInputApplicationCommandMention seems to html escape the string. Any ideas why this occurs?
Swiizyy
Swiizyy14mo ago
I also use this function but I have no display problem.... 🧐
ShowCast
ShowCast14mo ago
Got the issue! Got some custom config options for i18next I tried while figuring the issue with the options out
i18next: {
returnObjects: true,
interpolation: {
skipOnVariables: false
}
}
i18next: {
returnObjects: true,
interpolation: {
skipOnVariables: false
}
}
These messed it up. Removed it and it is working rn
Swiizyy
Swiizyy14mo ago
Hey, when would you update the version? 🧐
Favna
Favna14mo ago
ill do it now there ya go @swiizyy @showcast
Swiizyy
Swiizyy14mo ago
Thank you very much
ShowCast
ShowCast14mo ago
Perfect, will checkout rn
Want results from more Discord servers?
Add your server