Is there a way to detect when a localized string's english value is modified?

When someone changes the english value of a string, we want to remove all of the existing translations for that string because they are no longer up to date.
Any ideas on how this can be implemented?

It depends how they make the change. If it's done through the table editor or the localized string property drawer then you should be able to use the TableEntryModified event.
https://docs.unity3d.com/Packages/com.unity.localization@1.4/api/UnityEditor.Localization.LocalizationEditorEvents.html

E.g LocalizationEditorSettings.EditorEvents.TableEntryModified += // event callback
This is an editor only feature. You could set up a script that uses InitializeOnLoad to add a subscriber to monitor. Then when a change occurs you can invalidate the table collection. Maybe add some metadata to the entry to say that it needs checking.

1 Like

Thank you for the timely and helpful response :)

1 Like

You can use Unity localization package + Crowdin to manage translation changes. It would be easy to see which source strings (english) changed and whether translations should be updated as well. Here's a bit more on how Unity localization would work if you use a localization tool.

@ -jones I have three follow-up questions:

  1. Is there a way to add metadata per table entry? As in metadata per locale for a string entry. I want to detect if the Spanish string for an entry was modified and only tag that one with metadata.
  2. If the answer to 1 is yes, then I think I would need an EditorEvent for TableEntryModified that gives a StringTableEntry as a parameter rather than a SharedTableEntry.
  3. In the callback for TableEntryModified I have a SharedTableEntry. Is there an efficient way to get the collection that the SharedTableEntry belongs too? Currently i have to iterate through all the collections in my project and check if it contains that key.
  1. Yes, we have metadata per entry.
  2. Unfortunately, we don't have an event that will tell you what locale was changed for the entry though. I'll add a task for us to add that.
  3. Ah looks like we need to improve that callback as well.

Thanks for the feedback, we will look at improving these callbacks.

For now, as a workaround one thing you can try is to use the Undo post process callback. You should be able to identify what table has changed and the entry using the asset and path info.
https://docs.unity3d.com/ScriptReference/Undo-postprocessModifications.html