Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Changes for v2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
amrshaheen61 committed Sep 21, 2023
1 parent ab03000 commit b33e2be
Show file tree
Hide file tree
Showing 35 changed files with 9,719 additions and 1,144 deletions.
37 changes: 27 additions & 10 deletions UE4localizationsTool/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using UE4localizationsTool.Core.locres;
using UE4localizationsTool.Helper;

namespace UE4localizationsTool
{
Expand All @@ -12,15 +14,16 @@ public enum Args
{
filter = 1 << 0,
noname = 1 << 1,
method2 = 1 << 2
method2 = 1 << 2,
CSV = 1 << 3,
}



public class Commands
{
private List<List<string>> Strings;

private string TextFileExtension = ".txt";
public Args Flags;

private bool UseMatching = false;
Expand All @@ -35,7 +38,10 @@ public Commands(string Options, string SourcePath, Args args)
GetFilterValues();
}

if (Flags.HasFlag(Args.CSV)){

TextFileExtension = ".csv";
}
string[] Paths;
string ConsoleText;
switch (Options.ToLower())
Expand All @@ -58,7 +64,7 @@ public Commands(string Options, string SourcePath, Args args)
Console.Write("Done\n");
Console.ForegroundColor = ConsoleColor.White;

SaveTextFile(SourcePath + ".txt");
SaveTextFile(SourcePath + TextFileExtension);


break;
Expand All @@ -76,7 +82,7 @@ public Commands(string Options, string SourcePath, Args args)
Console.Write(ConsoleText);
Console.ForegroundColor = ConsoleColor.White;

if (!SourcePath.EndsWith(".txt", StringComparison.OrdinalIgnoreCase))
if (!SourcePath.EndsWith(TextFileExtension, StringComparison.OrdinalIgnoreCase))
{
throw new Exception("Invalid text file type: " + Path.GetFileName(SourcePath));
}
Expand All @@ -93,7 +99,7 @@ public Commands(string Options, string SourcePath, Args args)
case "-importall"://Folders Without rename Files
Paths = SourcePath.Split(new char[] { '*' }, 2);

if (!Paths[1].EndsWith(".txt", StringComparison.OrdinalIgnoreCase))
if (!Paths[1].EndsWith(TextFileExtension, StringComparison.OrdinalIgnoreCase))
{
throw new Exception("Invalid text file type: " + Path.GetFileName(SourcePath));
}
Expand All @@ -114,6 +120,14 @@ private void SaveTextFile(string FilePath)
Console.Write(ConsoleText);
Console.ForegroundColor = ConsoleColor.White;


if (Flags.HasFlag(Args.CSV))
{
CSVFile.Instance.Save(Strings, FilePath);

goto End;
}

string[] stringsArray = new string[Strings.Count];
int i = 0;

Expand All @@ -137,7 +151,7 @@ private void SaveTextFile(string FilePath)
i++;
}
File.WriteAllLines(FilePath, stringsArray);

End:
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("Done\n");
Console.ForegroundColor = ConsoleColor.White;
Expand All @@ -154,8 +168,8 @@ private List<List<string>> Export(string FilePath)

if (FilePath.EndsWith(".locres", StringComparison.OrdinalIgnoreCase))
{
locres locres = new locres(FilePath);
return locres.Strings;
IAsset locres = new LocresFile(FilePath);
return locres.ExtractTexts();
// SizeOfRecord = locres.Strings.Count;
}
else if (FilePath.EndsWith(".uasset", StringComparison.OrdinalIgnoreCase) || FilePath.EndsWith(".umap", StringComparison.OrdinalIgnoreCase))
Expand Down Expand Up @@ -285,8 +299,11 @@ private void Import(string FilePath, string[] Values, string Option)

if (FilePath.EndsWith(".locres", StringComparison.OrdinalIgnoreCase))
{
locres locres = new locres(FilePath);
EditList(locres.Strings, Values);
var locres = new LocresFile(FilePath);
var strings = locres.ExtractTexts();
EditList(locres.ExtractTexts(), Values);
locres.ImportTexts(strings);

if (Option == "-import")
{
locres.SaveFile(FilePath);
Expand Down
Loading

0 comments on commit b33e2be

Please sign in to comment.