Load CSV file and apply to translation

Is it possible to load and apply a CSV file (the one exported from Unity)?

Our usecase is to download the CSV from server and use it at the start of the application. I haven’t found any way to “dictate” which CSV the Localization should use.

Thanks in advance.

CSV is only supported in editor, we don’t support loading external files in the player.
There are a few different ways to update in the player.
The official way is to use address content updates. These can be provided by a server.
https://docs.unity3d.com/Packages/com.unity.addressables@1.20/manual/ContentUpdateWorkflow.html

You can also do something like this Creating StringTable at Runtime

In the next release we also have support for custom table providers and patchers which can be used to update the data at runtime.

Hey, thanks for the quick response. I’ll make sure to look at the resources you’ve kindly provided.

I’ve managed to come up with a solution, which loads it in Unity Editor and can be mounted to MonoBehaviour (but what I understand from your message, this will not work in an actual build).

I will post the code, though, it could be useful for somebody one day.

private void Start()
{
        // Import from CSV file
        var collection = LocalizationEditorSettings.GetStringTableCollection("UI Text");
        using (var stream = new StreamReader("path/to/CSV"))
        {
            Csv.ImportInto(stream, collection);
        }
}

Yes this wont work in player, its using Editor only API and will give you scripting errors when you try and build the player.
There’s some examples here on updating CSV through a script in the Editor Class Csv | Localization | 1.3.2

Alright, thanks a lot. Will try to find a way to load (and most importantly use) CSV files on the Player :slight_smile:

1 Like

We are just preparing 1.4, when this is released next month take a look at ITablePostprocessor. This will let you make changes to a table when its loaded but before its first used. Its designed for things such as loading in a csv file to patch the table.

1 Like