unorthodox
New Member
- Joined
- Aug 23, 2012
- Messages
- 32
- Reaction score
- 0
I parsed blizzard website and wrote patch to automatically translate legendary names. So if you have russian (or any other) client, you can still use english rules.
Interpreter.cs should be modified as follows:
1) Add translator methods.
Change locale variable to your locale. Variable localizationFile is the name of xml file with translation rules. This file should be placed at the same folder where you config.dis recides.
File is linked at the bottom of the post. There are 2 versions, RU only and all-in-one. Ofc smaller file loads faster.
2) Add using System.Xml; to import statements at the beginning of file.
3) In Interpreter constructor call readLocalization() before readConfiguration().
4) In fillDic method replace name parsing fragment to translate name. You should get smth like this:
I have tested this by setting low dps rules in hard.dis and forcing town runs. Seems to work with ItemRules from Trinity 1.7.1.16 distr (readonly string version = "2.0.4.5"; in Interpreter.cs) and russian client.
Ofc I haven't tested all the items and the languages.
Here are the links to translation xml files on dropbox:
Russian only
All languages in one file
And here is code:
Edited Interpreter.cs
Interpreter.cs should be modified as follows:
1) Add translator methods.
Change locale variable to your locale. Variable localizationFile is the name of xml file with translation rules. This file should be placed at the same folder where you config.dis recides.
File is linked at the bottom of the post. There are 2 versions, RU only and all-in-one. Ofc smaller file loads faster.
Code:
readonly string locale = "ru";
readonly string localizationFile = "legendaries.xml";
private Dictionary<string, string> legendariesTranslator;
public void readLocalization() {
if (locale == "en")
return;
legendariesTranslator = new Dictionary<string, string>();
XmlDocument xmlDoc= new XmlDocument(); //* create an xml document object.
xmlDoc.Load(Path.Combine(FileManager.ItemRulePath, localizationFile)); //* load the XML document from the specified file.
//* Get elements.
XmlNodeList legendaries = xmlDoc.GetElementsByTagName("item");
foreach(XmlNode legendary in legendaries) {
XmlAttributeCollection attrs = legendary.Attributes;
string eng = attrs["en"].Value;
string loc = attrs[locale].Value;
//DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "Translation rule '{0}' -> '{1}'", loc, eng);
legendariesTranslator[loc] = eng;
}
DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "Loaded translatins for {0} legendaries", legendariesTranslator.Count);
}
public string translate(string locName) {
if (locale == "en" || !legendariesTranslator.ContainsKey(locName))
return locName;
else
return legendariesTranslator[locName];
}
2) Add using System.Xml; to import statements at the beginning of file.
3) In Interpreter constructor call readLocalization() before readConfiguration().
4) In fillDic method replace name parsing fragment to translate name. You should get smth like this:
Code:
// - NAME -------------------------------------------------------------//
if ((item.ItemType == ItemType.Unknown && item.Name.Contains("Plan")) || item.ItemType == ItemType.CraftingPlan)
//{c:ffffff00}Plan: Exalted Fine Doomcaster{/c}
itemDic.Add("[NAME]", Regex.Replace(item.Name, @"{[/:a-zA-Z0-9 ]*}", string.Empty).Replace(" ", ""));
else {
itemDic.Add("[NAME]", translate(item.Name.ToString()).Replace(" ", ""));
}
I have tested this by setting low dps rules in hard.dis and forcing town runs. Seems to work with ItemRules from Trinity 1.7.1.16 distr (readonly string version = "2.0.4.5"; in Interpreter.cs) and russian client.
Ofc I haven't tested all the items and the languages.
Here are the links to translation xml files on dropbox:
Russian only
All languages in one file
And here is code:
Edited Interpreter.cs
Last edited: