Xliff.ImportFileIntoCollection - files not changed until save in Localizaiton Tables window

I am creating a C# script to automate synchronization of localizations between our Weblate git repository and our project repository.

After some git work, ti imports several files into several String Table Collections. After a sequence of Xliff.ImportFileIntoCollection calls finishes, I would like to call git add & git commit the changes to our project repository. But nothing gets commited and no changed files are present in the project directory.

I have to manually open the Localizaiton Tables window and press Ctrl + S for the changes to materialize. Is there a way how to flush them from code?

Update: I found and called SaveChangesToDisk but it is internal in my version (1.0.5).

        private void SaveLocalizations(StringTableCollection stringTableCollection) {
            stringTableCollection.GetType().GetMethod("SaveChangesToDisk", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(stringTableCollection, null);
        }

Is there a better way?

You can just call AssetDatabase.SaveAssets();, its the same thing.

Thanks!

1 Like