
Load game's language earlier for translation
Tenebrosful opened this issue ยท 1 comments
Describe the bug
It looks like that Helper.Translation.LocaleEnum
is equal to en
until a long time, making for exemple not possible to use localization for SMAPI commands description for exemple or other direct use of localized strings in Entry
. I don't know if it's possible but it could be nice that game language is load before Entry
To Reproduce
Exact steps which reproduce the bug, if possible. For example:
- Use any direct use localized String in
Entry
Exemple:
Helper.ConsoleCommands.Add("DiscordReload",
Helper.Translation.Get("command.discordreload.desc"), //<-- LocaleEnum = en (beside having game in french)
(string command, string[] args) => {
LoadConfig();
}
);
Log file
https://smapi.io/log/bdc70289233748a0b7468445d04e3159?Mods=SMAPI~RichPresence
Hi! SMAPI sets the translation locale as soon as the game sets its language. The game itself is still defaulted to English before that point, so it's not possible for SMAPI to set it earlier.
Console commands weren't designed to be translatable. That's something that may be improved in future SMAPI versions, but it'll require API changes (e.g. by using a Func<string>
to get the text only when it's being displayed).
In cases where you cache text yourself, you should use the LocaleChanged
event to update the cache. That will solve both the issue of text not reflecting the initial language, and also text not updating when the player changes the language.
I'll close this in the meantime though, since SMAPI just matches the base game here.