What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

ItemRules 2 rule translator

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.
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:
it's not work for me..
can you upload your "Interpreter.cs"? thanks!
 
Last edited:
Yeah, there was a bug. It seems that i fixed it now.
I edited code in my post and attached link to edited Interpreter.cs.
 
... its nice to see some one working on rules ^^ thx

an other appraoch with less coding need would have been to just make the legendary not use names ^^

Code:
// - The Butcher's Sickle -----------------------------------------------------+
// "Legendary" Axe
// 349.7?1044.4 Damage Per Second
// (204-536)?(334-1071) Damage
// 1.30 Attacks per Second
// +66-316 Minimum Damage
// +88-411 Maximum Damage
// +26-30% Damage
// Critical Hit Damage Increased by 51-55%
// 2.50-2.70% of Damage Dealt Is Converted to Life
// 20-25% chance to drag enemies to you when attacking.
// +2 Random Magic Properties
// Item Level: 60
[QUALITY] == "Legendary" && [LEVEL] == 60 && [TYPE] = "Axe" && [ONEHAND] # [DPS] > 800 && [SOCKETS] > 0 && ([LOH] > 0 || [MAXSTATVIT] > 100 || [WEAPAS] > 1.35)
[QUALITY] == "Legendary" && [LEVEL] == 60 && [TYPE] = "Axe" && [ONEHAND] # [DPS] > 900 && [SOCKETS] > 0
[QUALITY] == "Legendary" && [LEVEL] == 60 && [TYPE] = "Axe" && [ONEHAND] # [DPS] > 1000

// - The Burning Axe of Sankis ------------------------------------------------+
// "Legendary" Axe
// 566.9?972.9 Damage Per Second
// (287-477)?(585-1020) Damage
// 1.30 Attacks per Second
// +(112-296)?(261-687) Fire Damage
// Adds 5-6% to Fire Damage
// Fire skills deal 15-25% more damage.
// +36-40% Damage
// +46-50 Fire Resistance
// Each Hit Adds +449-657 Life
// Chance to fight through the pain when enemies hit you.
// +1 Random Magic Properties
// Item Level: 62
[QUALITY] == "Legendary" && [LEVEL] == 62 && [TYPE] = "Axe" && [ONEHAND] # [DPS] > 900 && ([SOCKETS] > 0 || [CRITDMG%] > 75)

// - Sky Splitter -------------------------------------------------------------+
// "Legendary" Axe
// 768.5?1146.5 Damage Per Second
// (353-510)?(722-1080) Damage
// 1.43-1.44 Attacks per Second
// +(143-286)?(334-667) Holy Damage
// +41-50% Damage
// Increases Attack Speed by 10-11%
// Regenerates 411-599 Life per Second
// 10-20% chance to Smite enemies when you hit them.
// One of 3 Magic Properties (varies)
// +170-200 Intelligence
// +170-200 Dexterity
// +170-200 Strength
// +1 Random Magic Properties
// Item Level: 63
[QUALITY] == "Legendary" && [LEVEL] == 63 && [TYPE] = "Axe" && [ONEHAND] # [DPS] > 1000 && [SOCKETS] > 0

this way no one has to worry about any language ... sad that no one has started that ^^ ... (some might be duplicate but it can be specified)
 
Less coding but more lines to change.
I thought about writing little app to translate rule files itself, but then If you want to switch to different rules provided by someone else you have to launch it every time.
 
Hi, unorthodox
If My locale is ZH so where I need chagne like you?
I have try a lot but it's still not work
Thx!
 
Try changing this:
Code:
readonly string locale = "ru";
to this:
Code:
readonly string locale = "zh";
Use second, bigger xml that contains zh locale. Firefox displays ZH characters correctly in this xml so I think I parsed it right. Maybe there is some problem with dictionary keys in ZH, but I can't test this.
 
Less coding but more lines to change.
I thought about writing little app to translate rule files itself, but then If you want to switch to different rules provided by someone else you have to launch it every time.
Please write application for translating files.
 
Back
Top