【本地化】修复代码本地化工具会重复导出包含转义字符的文本的问题

gaoxin 2020-11-12 10:47:25 +08:00
parent e0c8ecfba8
commit ea3be3e709
1 changed files with 7 additions and 20 deletions

View File

@ -153,7 +153,7 @@ namespace Assets.Scripts.Editor.LanguageTool
id = ++IDFlag;
L2ID.Add(L, id);
ID2L.Add(id, L);
Debug.LogWarning(id + "|" + L);
Debug.LogWarning("新增:" + id + "|" + L);
return id;
}
}
@ -440,8 +440,10 @@ namespace Assets.Scripts.Editor.LanguageTool
MatchCollection mc = reg.Matches(line);
for (int mi = 0; mi < mc.Count; mi++)
{
int id = AddLData(mc[mi].Value.Trim('"'));
Debug.Log(id+"|"+mc[mi].Value.Trim('"'));
string s = mc[mi].Value.Trim('"');
// 这里做个转换,否则可能导致包含转义字符的文字重复导出
s = s.Replace("\\n", "\n");
int id = AddLData(s);
lines[lIndex] = lines[lIndex].Replace(mc[mi].Value, "Language[" + id + "]");
}
}
@ -480,7 +482,6 @@ namespace Assets.Scripts.Editor.LanguageTool
{
string r = mc[mi].Value.Trim();
int id = Convert.ToInt32(r.Substring(9, 5));
Debug.Log(id);
string t = o[id];
lines[lIndex] = lines[lIndex].Replace(r, t);
}
@ -540,7 +541,7 @@ namespace Assets.Scripts.Editor.LanguageTool
}
// 遍历所有的可能包含中文文本的lua文件
[MenuItem("LanguageTool/lua/测试")]
//[MenuItem("LanguageTool/lua/测试")]
public static void CheckLanguage()
{
// 加载本地数据
@ -600,7 +601,7 @@ namespace Assets.Scripts.Editor.LanguageTool
}
// 从language.lua中读取数据
[MenuItem("LanguageTool/lua/读取language.lua")]
//[MenuItem("LanguageTool/lua/读取language.lua")]
private static Dictionary<int, string> ReadFromLanguage()
{
@ -629,20 +630,6 @@ namespace Assets.Scripts.Editor.LanguageTool
int num = Convert.ToInt32(str.Substring(1, 5));
string content = str.Substring(10, str.Length - 11);
o.Add(num, content);
string s = content.Trim('"');
//int id = AddLData(s);
//Debug.Log(id+"|"+ s);
//int id2= AddLData(s);
//Debug.Log(id2 + "|" + s);
string s2 = ID2L[12534];
s2 = s2.Replace("\n", "\\n");
Debug.Log(s + "|" + s2);
if (s == s2)
{
Debug.LogError("==");
}
}
}
// 清理本地数据