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

Commit

Permalink
add name table
Browse files Browse the repository at this point in the history
  • Loading branch information
amrshaheen61 committed May 28, 2022
1 parent 25956f4 commit 5bd96ff
Showing 1 changed file with 70 additions and 4 deletions.
74 changes: 70 additions & 4 deletions UE4localizationsTool/Core/locres.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,17 @@ private void ReadOrEdit(bool Modify = false)

if (Version >= LocresVersion.Compact)
{
// Console.WriteLine("Compact");
// Console.WriteLine("Compact");

int localizedStringOffset = (int)locresData.GetInt64Value();
int currentFileOffset = locresData.GetPosition();


if (localizedStringOffset == -1)
{
return;
}

locresData.Seek(localizedStringOffset);

int localizedStringCount = locresData.GetIntValue();
Expand Down Expand Up @@ -92,6 +101,7 @@ private void ReadOrEdit(bool Modify = false)
}
}
}
locresData.Seek(currentFileOffset);

}
else if (Version == LocresVersion.Legacy)
Expand All @@ -101,7 +111,7 @@ private void ReadOrEdit(bool Modify = false)

for (int i = 0; i < HashTablesCount; i++)
{
locresData.GetStringUE(); //hash namespace
locresData.GetStringUE(); //hash namespace

int localizedStringCount = locresData.GetIntValue();

Expand All @@ -110,9 +120,9 @@ private void ReadOrEdit(bool Modify = false)
{
if (!Modify)
{
locresData.GetStringUE(); //string hash
string KeyHash = locresData.GetStringUE(); //string hash
locresData.Skip(4); //Unkown
Strings.Add(new List<string>() { Strings.Count.ToString(), locresData.GetStringUE() });
Strings.Add(new List<string>() { KeyHash, locresData.GetStringUE() });

}
else
Expand All @@ -125,11 +135,67 @@ private void ReadOrEdit(bool Modify = false)
}

}
return;
}


if (Version >= LocresVersion.Optimized)
{
locresData.Skip(4); //FileHash
}


int namespaceCount = locresData.GetIntValue();

for(int n=0;n< namespaceCount; n++)
{
string nameSpaceStr;
uint StrHash;
ReadTextKey(locresData, Version,out StrHash,out nameSpaceStr); //no need right now
uint keyCount= locresData.GetUIntValue();
for (int k=0;k< keyCount;k++)
{
string KeyStr;
uint KeyStrHash;
ReadTextKey(locresData, Version, out KeyStrHash, out KeyStr);
locresData.Skip(4);//SourceStringHash

if (Version >= LocresVersion.Compact)
{
int localizedStringIndex= locresData.GetIntValue();
if(Strings.Count> localizedStringIndex)
{
Strings[localizedStringIndex][0] = KeyStr;
}

}

}

}










}

private void ReadTextKey(MemoryList memoryList, LocresVersion locresVersion, out uint StrHash, out string Str)
{
StrHash = 0;
Str = "";
if (locresVersion >= LocresVersion.Optimized)
{
StrHash = memoryList.GetUIntValue();
}

Str = memoryList.GetStringUE();
}


private void ModifyStrings()
Expand Down

0 comments on commit 5bd96ff

Please sign in to comment.