like auto write /lang de or en etc. for incoming players.
maybe there is already such a plugin?
Solved Automatic language switching for incoming players?
Discussion in 'Rust Development' started by hulimontana, Dec 16, 2016.
-
Most plugins have already inbuilt language support, and a such they do create a default english language file in oxide's "lang/en" folder. You need only to copy those files into the specific coded subfolders (like es, fr, gr, ...) and do rewrite the included language parts into the preferred language.
Done -
I know.
But i mean another.
I need automatically switching language individual for each player, for en player set en lang., for rus player set rus lang.
I translated into 2 languages all plugins on my server, is en, ru, de folder in oxide/lang.
Now people can switch language with /lang command.
But it would be great if the language was set automatically for each incoming player.
Need identify the country of incoming players and to set the language for themLast edited by a moderator: Dec 17, 2016 -
Wulf Community Admin
-
ye. maybe check client language setting, it's posible?
-
Wulf Community Admin
-
Code:
void OnPlayerInit(BasePlayer player) { if (player == null || player.net == null || player.net.connection == null) return; string ply_lang = player.net.connection.info.GetString("global.language", null); // returns a shortcode like 'en' if (ply_lang != null) { //do whatelse example Puts($"Player {player.displayName} has the language {ply_lang}"); } }
-
Wulf Community Admin
-
It returned atm the following (in my case):
Code:global.god > False global.specnet > False global.streamermode > False global.language > en
-
Code:
namespace Oxide.Plugins { [Info("Lang", "hulimontana", 0.1)] [Description("Auto change language")] class Lang : RustPlugin { void OnPlayerInit(BasePlayer player) { if (player == null || player.net == null || player.net.connection == null) return; string ply_lang = player.net.connection.info.GetString("global.language", null); // returns a shortcode like 'en' if (ply_lang != null) { //do whatelse example Puts($"Player {player.displayName} has the language {ply_lang}"); player.ConsoleMessage("chat.say /lang en"); } } } }
player.ConsoleMessage("chat.say /lang en"); - not working. -
Wulf Community Admin
-
Code:lang.SetLanguage(ply_lang, player.UserIDString);
-
Mughisi, thank you, it works
-
Code:
if (ply_lang == "en") { //do whatelse example Puts($"Player {player.displayName} has the language {ply_lang}"); lang.SetLanguage(ply_lang, player.UserIDString); }
why does not work the condition? -
Wulf Community Admin
-
then i don't understend how it works, if string: Puts($"Player {player.displayName} has the language {ply_lang}");
Write in console this:
like just "ru"
but if (ply_lang == "ru") don't work.
ok, anyway, how do I compare ply_lang?Last edited by a moderator: Dec 28, 2016 -
Wulf Community Admin
-
maybe don't need change this "if"?
if (ply_lang != null)
what happens if the server don't have the user language? set default lang? -
Wulf Community Admin
-
Sorry, but it's don't work too:
Code:if (ply_lang != null) { string lng = ply_lang.Substring(0, 1); Puts($"Player {player.displayName} has the language {lng}"); lang.SetLanguage(lng, player.UserIDString); }
But language don't switch for me.
And ply_lang have short string like 'en' wrote about it Fujikura
Last edited by a moderator: Dec 28, 2016