Files
JJBB/Assets/Editor/Scripts/Multilingual/Multilingual.cs

757 lines
29 KiB
C#
Raw Permalink Normal View History

2024-08-23 15:49:34 +08:00
using UnityEngine;
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine.UI;
using System.Text.RegularExpressions;
using System.IO;
public class Multilingual : MonoBehaviour
{
public class GualInfo
{
public string ChineseText = "";
public string TranslateText = "-1";
public string ToLine()
{
return string.Format("{0}\t{1}", ChineseText, TranslateText);
}
}
private static string AllTEXTPATH = Application.dataPath.Replace("Assets", "Multilingual\\");
private static string PREFABPATH = Application.dataPath+ "\\Project3D\\BundleData\\UI\\Prefab";
private static string TABFILEPATH = Application.dataPath + "\\Project3D\\BundleData\\Tables3D";
[MenuItem("ProTool/Multilingual/ReturnAllUIText 还原到汉语")]
public static void ReturnAllUIText1()
{
SetAllUIText("韩语//", 0);
}
[MenuItem("ProTool/Multilingual/ReturnAllTabText 还原到汉语")]
public static void ReturnAllTabText1()
{
var utf8WithoutBom = new System.Text.UTF8Encoding(false);
string allTabtextPath = AllTEXTPATH + "//AllTabText.txt";
FileInfo fi = new FileInfo(allTabtextPath);
Dictionary<string, List<string>> fiLineDics = new Dictionary<string, List<string>>();
if (fi.Exists)
{
StreamReader sw1 = new StreamReader(allTabtextPath, System.Text.Encoding.Unicode);
string line = sw1.ReadLine();
while (line!=null)
{
line = sw1.ReadLine();
if (string.IsNullOrEmpty(line))
continue;
string[] lines = line.Split('\t');
if (lines.Length < 2)
continue;
fiLineDics[lines[0]] = new List<string>(lines);
}
sw1.Close();
}
else
{
EditorUtility.DisplayDialog("123", string.Format("找不到 {0} 文件", allTabtextPath), "123");
return;
}
DirectoryInfo directoryInfo = Directory.CreateDirectory(TABFILEPATH);
FileInfo[] fileInfos = directoryInfo.GetFiles("*.txt", SearchOption.AllDirectories);
for (int n = 0; n < fileInfos.Length; n++)
{
if (fileInfos[n].Name.Contains("StrDictionary"))
continue;
StreamReader sw1 = new StreamReader(fileInfos[n].FullName, utf8WithoutBom);
List<string> lines = new List<string>();
string line = sw1.ReadLine();
lines.Add(line);
while (line!=null)
{
line = sw1.ReadLine();
if (string.IsNullOrEmpty(line))
continue;
string[] strs = line.Split('\t');
if (strs.Length < 2)
continue;
lines.Add(line);
}
sw1.Close();
if (lines.Count <= 2)
continue;
string[] column = lines[0].Split('\t');
for (int i = 2; i < lines.Count; i++)
{
if (!string.IsNullOrEmpty(lines[i]) && !lines[i][0].Equals('#') && !lines[i][0].Equals('\t'))
{
string[] segments = lines[i].Split('\t');
if (segments.Length != column.Length)
{
Debug.Log("error : " + lines[i]);
return;
}
for (int index = 2; index < column.Length; index++)
{
string key = string.Format("{0}#{1}#{2}", fileInfos[n].Name, column[index], segments[0]);
if (fiLineDics.ContainsKey(key))
{
segments[index] = fiLineDics[key][1];
lines[i] = string.Join("\t", segments);
}
}
EditorUtility.DisplayProgressBar("Find All Text", string.Format("Files : {0}/{1} {2}", n, fileInfos.Length, fileInfos[n].FullName), n * 1.0f / fileInfos.Length);
}
}
StreamWriter sw = new StreamWriter(fileInfos[n].FullName, false, utf8WithoutBom);
for (int i = 0; i < lines.Count; i++)
{
sw.WriteLine(lines[i]);
}
sw.Close();
}
EditorUtility.ClearProgressBar();
AssetDatabase.SaveAssets();
}
#region //韩语
[MenuItem("ProTool/Multilingual/韩语/Set/SetAllUIText")]
public static void SetAllUIText1()
{
SetAllUIText("韩语//",1);
}
[MenuItem("ProTool/Multilingual/韩语/Set/SetAllTabText")]
public static void SetAllTabText1()
{
SetAllTabText("韩语", TABFILEPATH, "AllTabText.txt");
}
[MenuItem("ProTool/Multilingual/韩语/Set/SetStrDictionatyText")]
public static void SetStrTabText1()
{
SetStrTabText("韩语", TABFILEPATH);
}
[MenuItem("ProTool/Multilingual/韩语/Get/GetAllUIText")]
public static void AllUIText1()
{
GetAllUIText("韩语");
}
[MenuItem("ProTool/Multilingual/韩语/Get/GetAllTabText")]
public static void AllTabText1()
{
GetAllTabText("韩语", TABFILEPATH, "AllTabText.txt");
}
#endregion
public static string TrimAll(string ChinaText)
{
ChinaText = ChinaText.TrimEnd('"');
ChinaText = ChinaText.TrimStart('"');
return ChinaText;
}
/// <summary>
/// AllUIText 本地上次获取的所有UIPrefab上的文本信息 NewAllUIText 需要进行翻译的文本的信息
/// 该函数先对比 AllUIText NewAllUIText两个文件把NewAllUIText中有而AllUIText中没有或者NewAllUIText
/// 和AllUIText不一样的部分合并到AllUIText中并清空NewAllUIText文件。然后读取所有UIPrefab上的文本信息并和AllUIText中的信息对比
/// 把有变化的或者不存在的保存到NewAllUIText中完成后NewAllUIText中的文本就是最新需要翻译的文本
/// </summary>
/// <param name="country"></param>
public static void GetAllUIText(string country)
{
string allUItextPath = AllTEXTPATH + string.Format("//{0}//AllUIText.txt", country);
string newallUItextPath = AllTEXTPATH + string.Format("//{0}//TranslateAllUIText.txt", country);
//1对比两个文件
FileInfo fi = new FileInfo(allUItextPath);
FileInfo fiNew = new FileInfo(newallUItextPath);
if(fi.Exists != fiNew.Exists )
{
EditorUtility.DisplayDialog("123", "有问题 AllUIText TranslateAllUIText 要么都存在要么都不存在检查一下SVN的记录是不是本地的被删掉了", "123");
return;
}
Dictionary<string,GualInfo> fiLineDics = new Dictionary<string, GualInfo>();
if (fiNew.Exists)
{
StreamReader sw1 = new StreamReader(allUItextPath, System.Text.Encoding.Unicode);
StreamReader swnew1 = new StreamReader(newallUItextPath, System.Text.Encoding.Unicode);
int index = 0;
string line = sw1.ReadLine();
while(line!=null)
{
index++;
line = sw1.ReadLine();
if (string.IsNullOrEmpty(line))
{
Debug.Log(index+" null "+line);
continue;
}
string[] lines = line.Split('\t');
if (lines.Length < 2)
{
Debug.Log(index + " <2 " + line);
continue;
}
Debug.Log("sdafsafdsaf : "+line);
GualInfo gualInfo = new GualInfo();
gualInfo.ChineseText = TrimAll(lines[0]);
gualInfo.TranslateText = lines[1];
fiLineDics[gualInfo.ChineseText] = gualInfo;
}
line = swnew1.ReadLine();
while (line!=null)
{
line = swnew1.ReadLine();
if (string.IsNullOrEmpty(line))
continue;
string[] lines = line.Split('\t');
if (lines.Length < 2)
continue;
GualInfo gualInfo = new GualInfo();
gualInfo.ChineseText = TrimAll(lines[0]);
gualInfo.TranslateText = lines[1];
if (fiLineDics.ContainsKey(gualInfo.ChineseText) == false || gualInfo.TranslateText != "-1")
{
fiLineDics[gualInfo.ChineseText] = gualInfo;
}
}
sw1.Close();
swnew1.Close();
}
DirectoryInfo directoryInfo = Directory.CreateDirectory(PREFABPATH);
FileInfo[] fileInfos = directoryInfo.GetFiles("*.prefab", SearchOption.AllDirectories);
for (int i = 0; i < fileInfos.Length; i++)
{
string assetPath = fileInfos[i].FullName.Replace("\\", "/");
assetPath = assetPath.Replace(Application.dataPath, "Assets");
UnityEngine.Object[] objs = AssetDatabase.LoadAllAssetsAtPath(assetPath);
for (int j = 0; j < objs.Length; j++)
{
if (objs[j] == null)
continue;
if (objs[j].GetType() != typeof(Text))
continue;
Text text = objs[j] as Text;
if (text == null)
continue;
string txtStr = text.text;
if (Regex.IsMatch(txtStr, @"[\u4e00-\u9fa5]+") == false)
{
continue;
}
string LabelText = txtStr.Replace("\t", "#t").Replace("\r\n", "#r#n").Replace("\r", "#r").Replace("\n", "#n");
GualInfo gualInfo = new GualInfo();
LabelText = TrimAll(LabelText);
if (fiLineDics.ContainsKey(LabelText) == false)
{
gualInfo.ChineseText = LabelText;
fiLineDics[LabelText] = gualInfo;
}
EditorUtility.DisplayProgressBar("Find All Text", string.Format("Files : {0}/{1}", i, fileInfos.Length), i * 1.0f / fileInfos.Length);
}
}
if (!fi.Directory.Exists)
{
fi.Directory.Create();
}
StreamWriter sw = new StreamWriter(allUItextPath,false, System.Text.Encoding.Unicode);
StreamWriter swnew = new StreamWriter(newallUItextPath,false, System.Text.Encoding.Unicode);
StreamWriter swOriginal = new StreamWriter(AllTEXTPATH + "//AllUIText.txt", false, System.Text.Encoding.Unicode);
//写出列名称
string linew = "中文" + "\t" + country;
sw.WriteLine(linew);
swnew.WriteLine(linew);
swOriginal.WriteLine(linew);
foreach (var gual in fiLineDics)
{
linew = gual.Value.ToLine();
if (gual.Value.TranslateText == "-1")
swnew.WriteLine(linew);
sw.WriteLine(linew);
swOriginal.WriteLine(linew);
}
sw.Close();
swnew.Close();
swOriginal.Close();
EditorUtility.ClearProgressBar();
}
public static void GetAllTabText(string country,string tabsDictionary,string translatetabName)
{
var utf8WithoutBom = new System.Text.UTF8Encoding(false);
string allUItextPath = AllTEXTPATH + string.Format("//{0}//{1}", country, translatetabName);
string newallUItextPath = AllTEXTPATH + string.Format("//{0}//Translate{1}", country, translatetabName);
//1对比两个文件
FileInfo fi = new FileInfo(allUItextPath);
FileInfo fiNew = new FileInfo(newallUItextPath);
if (fi.Exists != fiNew.Exists)
{
EditorUtility.DisplayDialog("123", "有问题 AllUIText NewAllUIText 要么都存在要么都不存在检查一下SVN的记录是不是本地的被删掉了", "123");
return;
}
Dictionary<string, GualInfo> fiLineDics = new Dictionary<string, GualInfo>();
if (fiNew.Exists)
{
StreamReader sw1 = new StreamReader(allUItextPath, System.Text.Encoding.Unicode);
StreamReader swnew1 = new StreamReader(newallUItextPath, System.Text.Encoding.Unicode);
string line = sw1.ReadLine();
while (line!=null)
{
line = sw1.ReadLine();
if (string.IsNullOrEmpty(line))
continue;
string[] lines = line.Split('\t');
if (lines.Length < 2)
continue;
GualInfo gualInfo = new GualInfo();
gualInfo.ChineseText = TrimAll(lines[0]);
gualInfo.TranslateText = lines[1];
fiLineDics[gualInfo.ChineseText] = gualInfo;
}
line = swnew1.ReadLine();
while (line!=null)
{
line = swnew1.ReadLine();
if (string.IsNullOrEmpty(line))
continue;
string[] lines = line.Split('\t');
if (lines.Length < 2)
continue;
GualInfo gualInfo = new GualInfo();
gualInfo.ChineseText = TrimAll(lines[0]);
gualInfo.TranslateText = lines[1];
if (fiLineDics.ContainsKey(gualInfo.ChineseText) ==false || gualInfo.TranslateText != "-1")
{
fiLineDics[gualInfo.ChineseText] = gualInfo;
}
}
sw1.Close();
swnew1.Close();
}
DirectoryInfo directoryInfo = Directory.CreateDirectory(tabsDictionary);
FileInfo[] fileInfos = directoryInfo.GetFiles("*.txt", SearchOption.AllDirectories);
for (int n = 0; n < fileInfos.Length; n++)
{
if (fileInfos[n].Name.Contains("StrDictionary"))
continue;
if (fileInfos[n].Name.Contains("StrFilter"))
continue;
if (fileInfos[n].Name.Contains("RoleName"))
continue;
if (fileInfos[n].Name.Contains("QuestionBank"))
continue;
StreamReader sw1 = new StreamReader(fileInfos[n].FullName, utf8WithoutBom);
List<string> lines = new List<string>();
string line = sw1.ReadLine();
lines.Add(line);
while (line!=null)
{
line = sw1.ReadLine();
if (string.IsNullOrEmpty(line))
continue;
string[] strs = line.Split('\t');
if (strs.Length < 2)
continue;
lines.Add(line);
}
sw1.Close();
if (lines.Count < 2)
continue;
string[] column = lines[0].Split('\t');
for (int i = 2; i < lines.Count; i++)
{
if (!string.IsNullOrEmpty(lines[i]) && !lines[i][0].Equals('#') && !lines[i][0].Equals('\t'))
{
string[] segments = lines[i].Split('\t');
if (segments.Length != column.Length)
{
Debug.Log("error : " + lines[i]);
return;
}
for (int index = 2; index < column.Length; index++)
{
if (Regex.IsMatch(segments[index], @"[\u4e00-\u9fa5]+") == false)
{
continue;
}
string ChineText = segments[index];
ChineText = TrimAll(ChineText);
if (fileInfos[n].Name.Contains("StrFilter") || fileInfos[n].Name.Contains("RoleName"))
{
if(fiLineDics.ContainsKey(ChineText))
fiLineDics.Remove(ChineText);
}
else if (fiLineDics.ContainsKey(ChineText) == false)
{
GualInfo gualInfo = new GualInfo();
gualInfo.ChineseText = ChineText;
gualInfo.TranslateText = "-1";
fiLineDics[ChineText] = gualInfo;
}
}
EditorUtility.DisplayProgressBar("Find All Text", string.Format("Files : {0}/{1} {2}", n, fileInfos.Length, fileInfos[n].FullName), n * 1.0f / fileInfos.Length);
}
}
}
if (!fi.Directory.Exists)
{
fi.Directory.Create();
}
StreamWriter sw = new StreamWriter(allUItextPath,false, System.Text.Encoding.Unicode);
StreamWriter swnew = new StreamWriter(newallUItextPath,false, System.Text.Encoding.Unicode);
StreamWriter swOriginal = new StreamWriter(AllTEXTPATH + "//" + translatetabName, false, System.Text.Encoding.Unicode);
//写出列名称
string linew = "中文" + "\t" + country;
sw.WriteLine(linew);
swnew.WriteLine(linew);
swOriginal.WriteLine(linew);
foreach (var gual in fiLineDics)
{
linew = gual.Value.ToLine();
if (gual.Value.TranslateText == "-1")
swnew.WriteLine(linew);
sw.WriteLine(linew);
swOriginal.WriteLine(linew);
}
sw.Close();
swnew.Close();
swOriginal.Close();
EditorUtility.ClearProgressBar();
}
public static void SetAllUIText(string country,int Opera) //Opera 0还原 1翻译
{
string allUItextPath = AllTEXTPATH + string.Format("{0}AllUIText.txt", country);
FileInfo fi = new FileInfo(allUItextPath);
Dictionary<string, GualInfo> fiLineDics = new Dictionary<string, GualInfo>();
Dictionary<string, GualInfo> fiLineDicsTrasn = new Dictionary<string, GualInfo>();
if (fi.Exists)
{
StreamReader sw1 = new StreamReader(allUItextPath, System.Text.Encoding.Unicode);
string line = "5432";
while (line!=null)
{
line = sw1.ReadLine();
if (string.IsNullOrEmpty(line))
continue;
string[] lines = line.Split('\t');
if (lines.Length < 2 || string.IsNullOrEmpty(lines[1]) || lines[1] == "-1")
continue;
GualInfo gual = new GualInfo();
gual.ChineseText = TrimAll(lines[0]);
gual.TranslateText = TrimAll(lines[1]);
fiLineDics[gual.ChineseText] = gual;
fiLineDicsTrasn[gual.TranslateText] = gual;
}
sw1.Close();
}
else
{
EditorUtility.DisplayDialog("123", string.Format("找不到 {0} 文件", allUItextPath), "123");
return;
}
DirectoryInfo directoryInfo = Directory.CreateDirectory(PREFABPATH);
FileInfo[] fileInfos = directoryInfo.GetFiles("*.prefab", SearchOption.AllDirectories);
int fileCount = fileInfos.Length;
for (int i = 0; i < fileInfos.Length; i++)
{
string fullPath = fileInfos[i].FullName.Replace("\\", "/");
string asstePath = fullPath.Replace(Application.dataPath.Replace("\\","/"), "Assets");
GameObject _prefab = AssetDatabase.LoadAssetAtPath(asstePath, typeof(GameObject)) as GameObject;
if (_prefab == null)
{
Debug.Log(string.Format("找不到 {0} 文件", asstePath));
continue;
}
GameObject prefabGameobject = PrefabUtility.InstantiatePrefab(_prefab) as GameObject;
Text[] objs = prefabGameobject.GetComponentsInChildren<Text>(true);
for (int j = 0; j < objs.Length; j++)
{
if (objs[j] == null)
continue;
string txtStr = objs[j].text;
if (Opera == 1 && Regex.IsMatch(txtStr, @"[\u4e00-\u9fa5]+") == false)
{
continue;
}
string LabelText = txtStr.Replace("\t", "#t").Replace("\r\n", "#r#n").Replace("\r", "#r").Replace("\n", "#n");
GualInfo gualInfo = null;
LabelText = TrimAll(LabelText);
if (fiLineDics.ContainsKey(LabelText))
{
gualInfo = fiLineDics[LabelText];
}
else if(fiLineDicsTrasn.ContainsKey(LabelText))
{
gualInfo = fiLineDicsTrasn[LabelText];
}
else
continue;
if(Opera == 1)
{
objs[j].text = gualInfo.TranslateText.Replace("#t", "\t").Replace("#r#n", "\r\n").Replace("#n", "\n").Replace("#r", "\r");
}
else
{
objs[j].text = gualInfo.ChineseText.Replace("#t", "\t").Replace("#r#n", "\r\n").Replace("#n", "\n").Replace("#r", "\r");
}
}
EditorUtility.DisplayProgressBar("Set All Text", string.Format("prefabs : {0}/{1} {2}", i, fileCount, fileInfos[i].Name), i * 1.0f / fileCount);
//PrefabUtility.SaveAsPrefabAsset(prefabGameobject, asstePath);
PrefabUtility.ReplacePrefab(prefabGameobject, _prefab, ReplacePrefabOptions.Default);
MonoBehaviour.DestroyImmediate(prefabGameobject);
}
EditorUtility.ClearProgressBar();
AssetDatabase.SaveAssets();
}
public static void SetAllTabText(string country,string tabsDictionary,string translatetabName)
{
var utf8WithoutBom = new System.Text.UTF8Encoding(false);
string allTabtextPath = AllTEXTPATH + string.Format("//{0}//{1}",country, translatetabName);
FileInfo fi = new FileInfo(allTabtextPath);
Dictionary<string, string> fiLineDics = new Dictionary<string,string>();
if (fi.Exists)
{
StreamReader sw1 = new StreamReader(allTabtextPath, System.Text.Encoding.Unicode);
string line = "1213";
while (line!=null)
{
line = sw1.ReadLine();
if (string.IsNullOrEmpty(line))
continue;
string[] lines = line.Split('\t');
if (lines.Length < 2 || string.IsNullOrEmpty(lines[1]) || lines[1] == "-1")
continue;
string ChinaText = TrimAll(lines[0]);
fiLineDics[ChinaText] = TrimAll(lines[1]);
}
sw1.Close();
}
else
{
EditorUtility.DisplayDialog("123", string.Format("找不到 {0} 文件", allTabtextPath), "123");
return;
}
DirectoryInfo directoryInfo = Directory.CreateDirectory(tabsDictionary);
FileInfo[] fileInfos = directoryInfo.GetFiles("*.txt", SearchOption.AllDirectories);
for (int n = 0; n < fileInfos.Length; n++)
{
if (fileInfos[n].Name.Contains("StrDictionary"))
continue;
if (fileInfos[n].Name.Contains("StrFilter"))
continue;
if (fileInfos[n].Name.Contains("RoleName"))
continue;
if (fileInfos[n].Name.Contains("QuestionBank"))
continue;
StreamReader sw1 = new StreamReader(fileInfos[n].FullName, utf8WithoutBom);
List<string> lines = new List<string>();
string line = sw1.ReadLine();
lines.Add(line);
while (line!=null)
{
line = sw1.ReadLine();
if (string.IsNullOrEmpty(line))
continue;
string[] strs = line.Split('\t');
if (strs.Length < 2)
continue;
lines.Add(line);
}
sw1.Close();
if (lines.Count <= 2)
continue;
string[] column = lines[0].Split('\t');
for (int i = 2; i < lines.Count; i++)
{
if (!string.IsNullOrEmpty(lines[i]) && !lines[i][0].Equals('#') && !lines[i][0].Equals('\t'))
{
string[] segments = lines[i].Split('\t');
if (segments.Length != column.Length)
{
Debug.Log("error : "+ fileInfos[n].Name +" " +i+" "+ lines[i]);
return;
}
for (int index = 2; index < column.Length; index++)
{
if (Regex.IsMatch(segments[index], @"[\u4e00-\u9fa5]+") == false)
{
continue;
}
string ChineText = segments[index];
ChineText = TrimAll(ChineText);
if (fiLineDics.ContainsKey(ChineText) && fiLineDics[ChineText]!="-1")
{
segments[index] = fiLineDics[ChineText];
}
}
lines[i] = string.Join("\t", segments);
EditorUtility.DisplayProgressBar("Find All Text", string.Format("Files : {0}/{1} {2}", n, fileInfos.Length, fileInfos[n].FullName), n * 1.0f / fileInfos.Length);
}
}
StreamWriter sw = new StreamWriter(fileInfos[n].FullName,false, utf8WithoutBom);
for(int i=0;i<lines.Count;i++)
{
sw.WriteLine(lines[i]);
}
sw.Close();
}
EditorUtility.ClearProgressBar();
}
public static void SetStrTabText(string country, string tabsDictionary)
{
List<string> IgnorID = new List<string>() {"2626","2627","2628","5990","5991","5992","5993", "46267" };
var utf8WithoutBom = new System.Text.UTF8Encoding(false);
string allTabtextPath = AllTEXTPATH + string.Format("//{0}//{1}", country, "StrDictionatyID.txt");
FileInfo fi = new FileInfo(allTabtextPath);
Dictionary<string, List<string>> fiLineDics = new Dictionary<string, List<string>>();
if (fi.Exists)
{
StreamReader sw2 = new StreamReader(allTabtextPath, System.Text.Encoding.Unicode);
string line1 = sw2.ReadLine();
while (line1 != null)
{
line1 = sw2.ReadLine();
if (string.IsNullOrEmpty(line1))
continue;
string[] lines1 = line1.Split('\t');
if (lines1.Length < 2)
{
Debug.Log("0 line len less 2 : " + line1);
continue;
}
fiLineDics[lines1[0]] = new List<string>(lines1);
}
sw2.Close();
}
else
{
EditorUtility.DisplayDialog("123", string.Format("找不到 {0} 文件", allTabtextPath), "123");
return;
}
FileInfo fileInfo = new FileInfo(tabsDictionary + "/StrDictionary.txt");
StreamReader sw1 = new StreamReader(fileInfo.FullName, utf8WithoutBom);
List<string> lines = new List<string>();
string line = sw1.ReadLine();
lines.Add(line);
while (line != null)
{
line = sw1.ReadLine();
if (string.IsNullOrEmpty(line))
continue;
string[] strs = line.Split('\t');
if (strs.Length < 2)
{
Debug.Log("1 line len less 2 : " + line);
continue;
}
lines.Add(line);
}
sw1.Close();
if (lines.Count <= 2)
return;
string[] column = lines[0].Split('\t');
for (int i = 2; i < lines.Count; i++)
{
if (!string.IsNullOrEmpty(lines[i]) && !lines[i][0].Equals('#') && !lines[i][0].Equals('\t'))
{
string[] segments = lines[i].Split('\t');
if (segments.Length != column.Length || IgnorID.Contains(segments[0]))
{
Debug.Log("error : " + fileInfo.Name + " " + i + " " + lines[i]);
continue;
}
if (fiLineDics.ContainsKey(segments[0]))
{
if(segments.Length > 2 && fiLineDics[segments[0]].Count > 2)
{
segments[2] = fiLineDics[segments[0]][2];
segments[2] = TrimAll(segments[2]);
lines[i] = string.Join("\t", segments);
}
}
}
}
StreamWriter sw = new StreamWriter(fileInfo.FullName, false, utf8WithoutBom);
for (int i = 0; i < lines.Count; i++)
{
sw.WriteLine(lines[i]);
}
sw.Close();
EditorUtility.ClearProgressBar();
}
[MenuItem("ProTool/Multilingual/PrintPrafabAllText")]
public static void PrintPrafabAllText()
{
Text[] texts = Selection.activeGameObject.GetComponentsInChildren<Text>(true);
for(int i=0;i<texts.Length;i++)
{
string text = texts[i].text;
text = text.Replace('\\', '#');
Debug.Log(text);
}
}
}