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); }
Languages are not updated when the plug-in is reload
Discussion in 'Rust Development' started by Sanlerus, Jun 15, 2017.
-
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.
-
-
Wulf Community Admin
-
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/rd7FyW6.png
http://i.imgur.com/jdA5n9M.pngLast edited by a moderator: Jun 15, 2017 -
Wulf Community Admin
-
-
Wulf Community Admin
Is this for an extension? Does the extension inherit CSPlugin?
-
-
Wulf Community Admin
-
[DOUBLEPOST=1497550939][/DOUBLEPOST] -
Wulf Community Admin
-
http://i.imgur.com/Cw6q4Xt.png -
Wulf Community Admin
-
Probably in .cs plug-ins, unload works somehow in a special way. -
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.
-
Wulf Community Admin
-
-
Wulf Community Admin
-
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.