Search Unity

How to delete localization string tables (and others)

Discussion in 'Localization Tools' started by DallasP9124, Feb 4, 2022.

  1. DallasP9124

    DallasP9124

    Joined:
    Jul 15, 2020
    Posts:
    11
    I started using the localization package provided by unity and I already am having trouble managing string tables. I can't figure out how to delete a table through the UI. So I went to the assets created for the table and deleted them manually. Now I get a warning indicating that the table is obviously still being referenced by the chain of assets and dont really know what to do.

    The table's name was settings

    Collection settings is invalid and will be ignored because SharedTableData is null.
    UnityEditor.Localization.UI.LocalizationTablesWindow:OnEnable () (at Library/PackageCache/com.unity.localization@1.0.5/Editor/UI/Tables/LocalizationTablesWindow.cs:102)

    Looking in the documentation didn't tell me how to delete these assets.

    I looked in the Addressable Groups and did not see the old table in there.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Did you want to delete the whole collection or just a single language? There are at least 3 assets you need to delete if you want to delete the whole thing.
    Shared table data, collection asset and the table.
    Could you please file a bug report with the issues you are having so we can improve it?
    Table deletion is not an area we have a lot of support for.
     
  3. DallasP9124

    DallasP9124

    Joined:
    Jul 15, 2020
    Posts:
    11
    Hey Karl. I am talking about just the string table. So like I create a table, end up not wanting it anymore, then delete.

    Seems like bad design to not allow the deletion of a table as if Localization is an add only feature. I will file a bug to bring this to light.
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    A single table can be removed through the collection editor. Select the collection asset and the option is in the inspector. Once it's removed you can delete it.
     
  5. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    How do we delete a WHOLE locale in unity 2022.3.18f1?? because everyday i open up the project to keep working on it i have the surprise that the files regarding a certain language that we wont longer support appear again.
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Did you delete all the string/asset tables for that locale?
     
  7. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    You mean like one by one? shouldnt that be automatic? and if its not, is there any way to really wipe everything related to a certain language of the project, that wouldnt be as time consuming as going over houndreds of files? (we are making a narrative game, so its really heavy on text)
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Deleting a locale won't touch the string tables. We don't have support for deleting an entire language, it's not something people typically do. We do have plans for disabling languages in the future. For now you will need to delete the string tables for the language you are removing. You could write a script to iterate through the string tables collections and do it. LocalizationEditorSettongs.GetStringTableCollections().
     
  9. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    oof, sounds like a nightmare. can you help me with a more practical example? lets say how would it be a script to erase portuguese and italian?
     
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Something like this should do it

    Code (csharp):
    1. public static void RemoveLocale(LocaleIdentifier localeIdentifier)
    2. {
    3.     foreach (var collectionStrings in LocalizationEditorSettings.GetStringTableCollections())
    4.     {
    5.         var table = collectionStrings.GetTable(localeIdentifier);
    6.         if (table != null)
    7.         {
    8.             collectionStrings.RemoveTable(table);
    9.             AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(table));
    10.         }
    11.     }
    12.  
    13.     foreach (var collectionAssets in LocalizationEditorSettings.GetAssetTableCollections())
    14.     {
    15.         var table = collectionAssets.GetTable(localeIdentifier);
    16.         if (table != null)
    17.         {
    18.             collectionAssets.RemoveTable(table);
    19.             AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(table));
    20.         }
    21.     }
    22.  
    23.     var locale = LocalizationEditorSettings.GetLocale(localeIdentifier);
    24.     if (locale != null)
    25.     {
    26.         LocalizationEditorSettings.RemoveLocale(locale);
    27.         AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(locale));
    28.     }
    29. }
     
    alysonlupo likes this.