1
votes

I'm trying to implement localization to my C# .NET 3.5 project (a game mod). I have it working with a single resx file per language, but as the number of strings is long I would like to split them into multiple files for each language.

Right now, I have A.resx, with A.fr.resx and A.de.resx. With using Project.Localization, I can call A.MyString and it translates correctly in-game.

However I have added B.resx with B.fr.resx and B.de.resx and while I can call B.MyOtherString in my code, when I build and run the project only the strings in A show up translated - the B strings use the default English regardless of the game's language.

A quick look at the generated fr/Project.resources.dll show that both the translated strings for A and B are in the file. I don't know what I'm looking at, but the strings are there.

I tried adding different namespace properties to the A files and the B files, but this only seems to affect the code - as in, I had to alter the calls to be NamespaceA.A.MyString and NamespaceB.B.MyOtherString but the same translation fails happened in-game.

1

1 Answers

0
votes

You can make a custom .resx generator by System.Windows.Forms.ResXResourceWriter.

static void WriteResX(Dictionary<string, object> dictionary, string resxPath)
{
    using ResXResourceWriter writer = new ResXResourceWriter(resxPath);
    foreach (var item in dictionary)
    {
        writer.AddResource(item.Key, item.Value);
    }
}

Now you can manage the texts by .txt, .csv, .xml, .json whatever. Even multiple files.