[BUG] Localizer prints strings in default language
Hey, couple days ago I noticed that plugins with Localization (lang) don't return strings in language that's set using !lang command (or from custom plugin that sets the language automatically).
For example, I have targetPlayer.PrintToChat(Localizer["test.loc"]);. I've set-up Polish language with !lang pl and just for verification also send !lang command to see if it really is set. Do something to trigger PrintToChat and get the string in chat for default language.
I've tried everything, results don't change. I've debugged players CultureInfo where it also returns pl, I can only assume that something broke and doesn't work anymore.
Together with this issue, I've written a small plugin that would set players localization automatically with PlayerLanguageManager.SetLanguage and that also doesn't work. But I did find a temporary solution for it if anyone needs it which would be to use PlayerLanguageManager.Instance.SetLanguage without defining the PlayerLanguageManager itself.
Yeah, I’ve noticed the same issue—lang is set, but Localizer still returns default strings. Hopefully this gets fixed soon.
Hello,
In a plugin, if you want to output a text in the server language (as set in CoreConfig), use:
Localizer["test.message"]
However, if you wish to send something in the player’s set language, use:
Localizer.ForPlayer(controller, "test.message")
This function can be found in the CounterStrikeSharp.API.Core.Translations namespace. If ForPlayer is given a null player, there’s no translation for the player’s language, or no language is configured, it will fall back to the CoreConfig language.