How to get the value of one or all LocalizedStrings in Editor?

The strings are there, I know it, I’ve written them and they work fine in the game as well as the build.
BUT I need some kind of validation, I know it’s on the roadmap … but there has to be some way to access the strings within the editor right now and maybe even compare them to the LocalizedString.TableEntryReference?

Haven’t found anything on the previos posts of the last 3 sites and nothing in the quick start guide / docs.
It’s possible to export CSV, so it has to be possible to get the strings somehow.

But how?

You want to get the data in editor? You can use LocalizationEditorSettings.

void DoValidate()
{
#if UNITY_EDITOR
    var collection = UnityEditor.Localization.
            LocalizationEditorSettings.GetStringTableCollection(text.TableReference);
    if (collection == null) return;
    var entry = collection.SharedData.GetEntryFromReference(text.TableEntryReference);
    if (entry == null) return;
    Debug.Log("Entry is: " + entry);
    // entry.value ???
#endif
}

I’ve come this far
(and ignore the #if UNITY_EDITOR line, it’s because I am using the Odin Asset to quickly make Buttons without creating a CustomInspector)

If you want a value for a particular locale:

vat st = collection.GetTable("en") as StringTable;
var entry = st.GetEntryFromReference(reference);
Debug.Log(entry.LocalizedValue)

Yes it worked :smile:
Awesome! Thanks a lot :smile:

1 Like