In the player, you would not want to do it for every language but just for the language that is currently in use, we don’t load the other languages (unless they are fallback - see preload behavior)
The changes you make in the player are not saved, they are only for that run so you need to do this every time the player starts, so it’s not ideal to update every language since you will usually only need 1.
You could filter the csv when you load it to extract what you need or have a csv per language and just load the one you need.
There is any way to import csv or json to the tables at runtime? i can do it in editor but not in runtime. I don’t see a way to do it with the link you provided previously as i just get one of the languages so i can’t save for all languages. If i filter what i need from the csv wouldn’t change anything cause i just can save changes for one language.
I have the csv in StreamingAssets so that the person who is going to run the build can change the csv or json and i need to load the tables from the csv or json
No, we don’t provide any runtime parsers but it’s quite simple to do, especially with json.
Example pseudo-code
[Serializable]
public class CustomTablePatcher : ITablePostprocessor
{
public void PostprocessTable(LocalizationTable table)
{
if (table is StringTable stringTable)
{
var file = Path.Combine(path, $"{stringTable.TableCollectionName}_{table.LocaleIdentifier.Code}.json");
// TODO: Parse the CSV/Json file and extract the column for table "table.LocaleIdentifier.Code"
foreach (var row in csvFile)
{
// Update an old value
var entry = stringTable.GetEntry(row.Id);
if (entry != null)
{
entry.Value = row.Value;
}
else
{
// Add a new value
stringTable.AddEntry(row.Id, row.Value);
}
}
}
}
}
Create a file format to store the data and parse using JsonUtility.
Something simple would be:
[Serializable]
class LocalizationEntry
{
public string key;
public string value;
}
[Serializable]
class LocalizationData
{
public List<LocalizationEntry> entries;
}
You could create some editor scripts to generate the json files in the Editor, like you do above, get the collections but convert them into the json and save them as .json files in StreamingAssets.
Ill create a task for us to put together a package sample to show how to do all of this in the future.
How do you know its not working, how are you checking the value?
Does a new value get applied in PostprocessTable?
These changes wont be saved to the table in Editor, it will be a play mode only feature.
I know cause the UI text is not updated. But i am doing something wrong cause it just updates in one language but not in the other. I use LocalizationSettings.StringDatabase.GetAllTables twice, one for each language. Then i get the right entry value from the json but when i assign this value to entry.Value just update in one of the languages. I tried to change locale with LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[localeId]; before getalltables but doesn’t work
You are calling getalltables and then updating the values? That wont work, the values will be updated after the table has loaded but before you have applied the changes, you need to use a ITablePostprocessor to make the changes before the table is used.
I got to solve the issue, i was trying to load both languages one after the other, but i have to choose one language and make the changes just for that one