1. Hello. Wolf correct it already, finally, I'm tired of using this shit code.

    Code:
    private void UpdateMessages(string plugin, string lang)
    {
        var pathLang = Path.Combine(Interface.Oxide.LangDirectory, $"{lang}{Path.DirectorySeparatorChar}{plugin}.json");
        var messageFile = !File.Exists(pathLang) ? null : JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(pathLang));
        if (messageFile == null) return;
        var field = typeof(Oxide.Core.Libraries.Lang).GetField("langFiles", BindingFlags.NonPublic | BindingFlags.Instance);
        var langFiles = field?.GetValue(LibLang) as Dictionary<string, Dictionary<string, string>>;
        if (langFiles == null) return;
        langFiles[$"{lang}{Path.DirectorySeparatorChar}{plugin}.json"] = messageFile;
        field.SetValue(LibLang, langFiles);
    }
     
  2. Wulf

    Wulf Community Admin

    The Lang API doesn't to update existing messages with the same key as server owners may have customized those. You can easily change a message by adding a new key.
     
  3. I open the language file, change the values there, reload the plugin, the values on the server do not change. To see the new values, my have to reboot the server.
     
  4. Wulf

    Wulf Community Admin

    I can't reproduce that. Are you sure the keys match what your plugin is using?
     
  5. For example:
    I'm the server administrator, downloaded the plugin, installed. I check the plugin, I do not like the translation, I open the language file, I need to change how I need it, I save the file, I restart the plugin and nothing happens, I have to reboot the server to see my changes.
    [DOUBLEPOST=1497537761][/DOUBLEPOST]My register lang:
    Code:
    public static readonly Oxide.Core.Libraries.Lang LibLang = Interface.Oxide.GetLibrary<Oxide.Core.Libraries.Lang>();private void RegisterMessages()
    {
        LibLang.RegisterMessages(new Dictionary<string, string>
        {
            { "UiNotice:Title", "КРАФТ НЕВОЗМОЖЕН" },
            { "UiNotice:Text", "Для крафта {0} необходимо изучить чертёж." },
            { "UiStudied:Title", "ИЗУЧЕНИЕ НЕВОЗМОЖНО" },
            { "UiStudied:Text", "Вы уже изучили чертёж {0}." },
            { "UiReseachItems:Title", "ИЗУЧЕННЫЕ ПРЕДМЕТЫ" },
            { "ItemCategory:Weapon", "<color=#d6ccc3>ОРУЖИЕ</color>" },
            { "ItemCategory:Construction", "<color=#d6ccc3>СТРОИТЕЛЬСТВО</color>" },
            { "ItemCategory:Items", "<color=#d6ccc3>ПРЕДМЕТЫ</color>" },
            { "ItemCategory:Resources", "<color=#d6ccc3>РЕСУРСЫ</color>" },
            { "ItemCategory:Attire", "<color=#d6ccc3>ОДЕЖДА</color>" },
            { "ItemCategory:Tool", "<color=#d6ccc3>ИНСТРУМЕНТЫ</color>" },
            { "ItemCategory:Medical", "<color=#d6ccc3>МЕДИКАМЕНТЫ</color>" },
            { "ItemCategory:Ammunition", "<color=#d6ccc3>ПАТРОНЫ</color>" },
            { "ItemCategory:Traps", "<color=#d6ccc3>ЛОВУШКИ</color>" },
            { "ItemCategory:Other", "<color=#d6ccc3>ОСТАЛЬНОЕ</color>" },
            { "ItemCategory:Close", "<color=#d6ccc3>ЗАКРЫТЬ</color>" }
        }, ExtInstance);
        UpdateMessages(Name, LibLang.GetServerLanguage());
    }
    http://i.imgur.com/oeZEN0p.png
    http://i.imgur.com/rd7FyW6.png
    http://i.imgur.com/jdA5n9M.png
     
    Last edited by a moderator: Jun 15, 2017
  6. Wulf

    Wulf Community Admin

    Are you editing the actual language file or the plugin itself to change the messages?
     
  7. Language file.
     
  8. Wulf

    Wulf Community Admin

    Is this for an extension? Does the extension inherit CSPlugin?
     
  9. Yes, it inherits CSPlugin, but I think it's a problem with regular .cs plugins.
     
  10. Wulf

    Wulf Community Admin

    If it was a widespread issue (no other reports in the year+ it has been implemented), it would have been fixed already. I'll do some testing shortly though, but I've not noticed any issues with my daily use of it.
     
  11. Well, then I'll check on the usual .cs plugin.
    [DOUBLEPOST=1497550939][/DOUBLEPOST]
    Indeed, in normal .cs plugins everything is fine. The problem is CSPlugin plugins.
     
  12. Wulf

    Wulf Community Admin

    We use the Lang API in each game's core plugin and haven't noticed any issues. Ex. RustCore. Do you have the issue with it?
     
  13. I can not reload RustCore to check ...
    http://i.imgur.com/Cw6q4Xt.png
     
  14. Wulf

    Wulf Community Admin

    Extensions aren't really meant to be reloaded while the server is running, which is why we may have not encountered the issue with them before.
     
  15. Strangely this is all, .cs and CSPlugin use the same API for translation, where does this issue ...
    Probably in .cs plug-ins, unload works somehow in a special way.
     
  16. I have the same problem. When I add a new message to one of my plugins and upload it on the server, the lang file is updated but, when I use the command, it show the key and not the message.
     
  17. Wulf

    Wulf Community Admin

    Which language do you have set as your default?
     
  18. English
     
  19. Wulf

    Wulf Community Admin

    Extension plugin or plugin?
     
  20. Plugin. I have use command /lang en and after the plugin command, now it show the message. But when I add a new message to the plugin, again the same problem. It doesn't seem to reload the server's lang files.
    [DOUBLEPOST=1497977131][/DOUBLEPOST]Now it isn't doing it anymore. I'm not understanding anything xD
    This fact made me lose my head for an hour.