Continuing the discussion from GetLocalizedString in EditorWindow:
Hello, I’m using Unity 6000.0.43.f1 and using Localization version 1.5.4 but GetLocalizedString() still returned an empty string when in Editor mode.

I’m also confused on how to use LocalizationEditorSettings, here are my unfinished code.
var newText = "";
if (Application.isPlaying) {
newText = textLocalized.GetLocalizedString();
} else if (Application.isEditor) {
newText = LocalizationEditorSettings
.GetStringTableCollection(textLocalized.TableReference.TableCollectionNameGuid)
.GetTable(LocalizationSettings.ProjectLocale.Identifier.Code)
.SharedData.Entries.
}
Nvm, I didn’t google hard enough.
The answer is that I need to select active locale in the Localization Scene Control.
Just in case someone needs this in future.
Do not forget to set Active Locale in “LocalizationSceneControls” (Window → AssetManagement => LocalizationSceneControls).
#if UNITY_EDITOR
using UnityEditor.Localization;
private void OnValidate()
{
if (UnityEditor.EditorApplication.isPlaying || Application.isPlaying)
return;
if (localizedString == null || localizedString.IsEmpty)
return;
// Get the active locale in the Editor (not runtime)
var activeLocale = LocalizationEditorSettings.ActiveLocalizationSettings.GetSelectedLocale();
if (activeLocale == null)
return;
// Find the collection (by Guid from your LocalizedString.TableReference)
var collection = LocalizationEditorSettings.GetStringTableCollection(localizedString.TableReference.TableCollectionNameGuid);
if (collection == null)
return;
// Get the table for the current locale
var table = collection.GetTable(activeLocale.Identifier) as UnityEngine.Localization.Tables.StringTable;
if (table == null)
return;
// Try find the entry
var entry = table.GetEntry(localizedString.TableEntryReference);
if (entry == null)
return;
// Preview string applied in Edit mode
targetText.text = entry.LocalizedValue;
}
#endif