1. like auto write /lang de or en etc. for incoming players.
    maybe there is already such a plugin?
     
  2. 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 :)
     
  3. 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 them
     
    Last edited by a moderator: Dec 17, 2016
  4. Wulf

    Wulf Community Admin

    If you're asking how to write it (you posted under the plugin development section), you'd hook into something like OnPlayerConnected, grab their IP address, and send that to a website to check their country, then run the command or method to change their language.
     
  5. ye. maybe check client language setting, it's posible?
     
  6. Wulf

    Wulf Community Admin

    No, the client doesn't send that to the server. You'd need to check using a web request.
     
  7. 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}");
                }
            }
     
  8. Wulf

    Wulf Community Admin

    Oh nice, so it does send it now?
     
  9. I did experiment with it since someone asked last week or so about "streamer" detection.
    It returned atm the following (in my case):
    Code:
    global.god > False
    global.specnet > False
    global.streamermode > False
    global.language > en
     
  10. 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");
                }
            }
        }
    }
    What is my mistake?
    player.ConsoleMessage("chat.say /lang en"); - not working.
     
  11. Wulf

    Wulf Community Admin

    That isn't running a command, it's only putting a message in their console.
     
  12. Why not just call the method to set the language?
    Code:
    lang.SetLanguage(ply_lang, player.UserIDString);
     
  13. Mughisi, thank you, it works
     
  14. Code:
    if (ply_lang == "en")
                {
                    //do whatelse example
                    Puts($"Player {player.displayName} has the language {ply_lang}");
                    lang.SetLanguage(ply_lang, player.UserIDString);
                }
    another small question:
    why does not work the condition?
     
  15. Wulf

    Wulf Community Admin

    ply_lang is likely not just "en", perhaps "en-US" or "en-UK", etc.
     
  16. then i don't understend how it works, if string: Puts($"Player {player.displayName} has the language {ply_lang}");
    Write in console this:
    [​IMG]
    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
  17. Wulf

    Wulf Community Admin

    Try using Trim() to remove any possible spaces from it.
     
  18. 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?
     
  19. Wulf

    Wulf Community Admin

    Print it out and see I guess.
     
  20. 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);
                }
    In server console I see string "Player hulimontana has the language ru"
    But language don't switch for me.

    And ply_lang have short string like 'en' wrote about it Fujikura
    Where i can find information about: lang, player.ConsoleMessage and other oxide functions?
     
    Last edited by a moderator: Dec 28, 2016