-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathTxtGeneralLocalizer.cs
34 lines (30 loc) · 1.17 KB
/
TxtGeneralLocalizer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Localizer.Localizers
{
public static class TxtGeneralLocalizer
{
public static string LocalizationAnchorLine = "\r\n[###StarSectorLocalization###]\r\n";
public static bool Localize(string targetTxtPath, string localizationTxtPath)
{
string originalContent = File.ReadAllText(targetTxtPath);
string localizationContent = File.ReadAllText(localizationTxtPath);
int pos = localizationContent.IndexOf(LocalizationAnchorLine);
if(pos == -1)
{
Console.WriteLine($"Corrupted txt translation: {localizationTxtPath}");
return false;
}
if (originalContent.Length != pos || originalContent != localizationContent[0..pos])
{
Console.WriteLine($"[TXT UNM][{originalContent.Length}][{pos}] {targetTxtPath}");
return false;
}
File.WriteAllText(targetTxtPath, localizationContent[(pos + LocalizationAnchorLine.Length)..]);
return true;
}
}
}