Open Gawdl3y opened 5 years ago
As promised, I'm working on that issue and have made some design decisions:
I use https://github.com/i18next as it already has a Loader/Loadable system and is feature rich, however it will be possible to integrate our own loader system later on. Bot owners may load and afterwards reload localization files even the ones which did not exist on initialization time.
I18next can be used for the whole bot, not only for commando. However, it will be possible to create a whole new instance, so there are no conflicts between commando translations and other ones.
Commando uses the language dev
for its builtin strings, so one can define own strings for en
, fallback language will be dev
.
Language can be set same as the prefix, means global and per guild which will override the global one for messages on that guild.
The bot can't use the guild.language
in DM mode so commando will try to translate into the language defined by user.locale
but that may be different than guild.language
. It's possible to configure fallback language for each user.locale
(see https://www.i18next.com/principles/fallback) so when user.locale
equals es
it's possible to fallback to fr
instead of using the builtin translation.
The property used for the global language is named defaultLanguage
and for guilds language
, e.g. client.defaultLanguage
and msg.guild.language
.
Commandos builtin strings are defined in a javascript object instead of a json file. so one does not need to setup a path with localization files.
No breaking changes - it will be possible to start commando without additional setup/configuration required, so there are no breaking changes.
Use without translation - one can choose to define strings as normal, or use translations. Both variants will work. Also it will be possible to translate only selected strings into another languages. For the others, the default strings will be used.
example: description: new CommandoTranslatable('command.help.description')
will work and translates the description description: 'my hard coded description'
will also work, of course without translation
Update: I'm almost done. I've implemented the feature on my private bot and everything seems to work. Only the translations for the type validations are missing.
Any news when this will be implemented officially? Thanks
@perzeuss : 10 months later, is it still "almost done" ? Something can be done to help you achieve this ? What is the roadmap to merge this into an official release (with documentation ^^) ?
thx :)
@Torbraw @Kaon68 Please look at the PR for this issue: https://github.com/discordjs/Commando/pull/324#issuecomment-780927084
@Gawdl3y did not like my solution and I started to rewrite it but I had not time yet to complete that rewrite, because I've other work to do with higher priority.
A system needs to be added to allow all built-in text to be translated to other languages or customised for any other reason. This system should also be usable by non-built-in components, allowing for easier translation of bots. The current locale should be a guild-specific setting, and locales should implement the Loader/Loadable functionality (depends on #196).