Search Unity

Question Set a table entry as smart via script

Discussion in 'Localization Tools' started by JulianMC, May 5, 2021.

  1. JulianMC

    JulianMC

    Joined:
    Dec 30, 2019
    Posts:
    26
    Hi, I'm importing a CSV dynamically via script into the string table collection, but some of these entries need to be smart, is there a way to set them as Smart via script?
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Hi,

    Yes, you can get the entry and set its IsSmart flag. Like so:

    Code (csharp):
    1. var collection = LocalizationEditorSettings.GetStringTableCollection("My Strings");
    2. var table = collection.GetTable("en") as StringTable;
    3. table.GetEntry("My Entry").IsSmart = true;
    however, for your use case, I would suggest creating a custom column in the CSV that can be used to indicate if an entry is Smart. Take a look at the CSV samples included with the package. Samples can be found via the package manager window.
    You want CsvCustomColumnsExample
     
  3. JulianMC

    JulianMC

    Joined:
    Dec 30, 2019
    Posts:
    26
    Sorry, I don't understand how it works.....

    If I try to create a script with the code in the CsvCustomColumnsExample to see what it does, I get an error on using CsvHelper because it can't find it and I suppose the other error CsvReader is related


    upload_2021-5-5_11-51-26.png

    I'm really not that good at coding so I might not understand some of these things
     
    Last edited: May 5, 2021
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Csvhelper is included in a dll that needs to be added to the asmdef. Take a look at the one that comes with the sample. You will need your code to be in an asmdef file.