Custom Localization System

So I was following Game Dev Guide’s Localization System tutorial stuff. For the most part, everything works just fine but as one of the commenters on the first of the two tutorial videos mentioned, having all of the translated text from every language implemented is an amount of memory unnecessarily loaded. In the interest of changing that, I had begun making some modifications to the system used but I have come across a rather large issue;

File.AppendAllText and File.WriteAllText failed to write anything.

I have debug statements showing that the values and arguments passed do in fact include the data I wished to add, and yet no changes were made to the file. No errors in my log either mentioning anything about “failure to access file” or the like. The code runs, and the final debug statement that would show the final change shows an empty string, and the changes are never made. I’m rather puzzled as my understanding and google-fu presents itself like I’m using the statements correctly.
I have no idea whats going wrong. For clarity; the intended use is to have the LocalizedString draw an extra couple buttons, one of which allows you to “add” a value to the given key. Press the “Add” button on the prompt it shows and presto, we should have a new key-value pair in the language file, and the code reloads the assets to reflect it.

Any clues?

8871201–1211238–CSVLoader.cs (3.15 KB)
8871201–1211241–LocalizationSystem.cs (2.4 KB)
8871201–1211244–LocalizedString.cs (431 Bytes)
8871201–1211250–LocalizedStringDrawer.cs (2.3 KB)
8871201–1211253–TextLocalizerEditor.cs (3.65 KB)

Are you telling AssetDatabase to refresh?

Yes. The debug lines I’ve made shows that it doesn’t make it that far though; the file itself doesn’t seem to be modified at any point, despite the function calls to do so.

Fixed my issue; I missed typing a backslash in the path for the .csv files, so it saved the file somewhere else that it didn’t load the files. Oopsies.

1 Like

Also worth noting Unity has their own localisation package. It utilises addressables to handle remote content and memory management.

Worth looking at if you don’t want to handle it all yourself.

1 Like