Improve translation rule parsing

This commit is contained in:
ORelio 2013-07-27 12:25:14 +02:00
parent de50e07f54
commit 6347d832ce
2 changed files with 11 additions and 2 deletions

View file

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
namespace MinecraftClient namespace MinecraftClient
{ {
@ -139,7 +140,15 @@ namespace MinecraftClient
if (!init) { InitRules(); init = true; } if (!init) { InitRules(); init = true; }
if (TranslationRules.ContainsKey(rulename)) if (TranslationRules.ContainsKey(rulename))
{ {
string[] syntax = TranslationRules[rulename].Split(new string[2] { "%s", "%d" }, StringSplitOptions.None); if ((TranslationRules[rulename].IndexOf("%1$s") >= 0 && TranslationRules[rulename].IndexOf("%2$s") >= 0)
&& (TranslationRules[rulename].IndexOf("%1$s") > TranslationRules[rulename].IndexOf("%2$s")))
{
while (using_data.Count < 2) { using_data.Add(""); }
string tmp = using_data[0];
using_data[0] = using_data[1];
using_data[1] = tmp;
}
string[] syntax = TranslationRules[rulename].Split(new string[] { "%s", "%d", "%1$s", "%2$s" }, StringSplitOptions.None);
while (using_data.Count < syntax.Length - 1) { using_data.Add(""); } while (using_data.Count < syntax.Length - 1) { using_data.Add(""); }
string[] using_array = using_data.ToArray(); string[] using_array = using_data.ToArray();
string translated = ""; string translated = "";

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartArguments>TestBot - localhost bot:scripting:testscript.txt</StartArguments> <StartArguments>TestBot - localhost</StartArguments>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory> <PublishUrlHistory>publish\</PublishUrlHistory>