Localisation
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).
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
devfor its builtin strings, so one can define own strings foren, fallback language will bedev. -
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.languagein DM mode so commando will try to translate into the language defined byuser.localebut that may be different thanguild.language. It's possible to configure fallback language for eachuser.locale(see https://www.i18next.com/principles/fallback) so whenuser.localeequalsesit's possible to fallback tofrinstead of using the builtin translation. -
The property used for the global language is named
defaultLanguageand for guildslanguage, e.g.client.defaultLanguageandmsg.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 descriptiondescription: '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.