Enzisoft

NZCore Localization

Freecom.enzisoft.localizationv1.0.2

com.enzisoft.localization

Lets ECS data reference Unity Localization strings.

LocalizedString is a managed class, so it can't live in components, blobs or Burst code. LocalizedStringRef stores the same reference as unmanaged data (table collection GUID + entry key ID) and turns back into a LocalizedString when you need the text.

Baking

Convert in a baker (NZCore.Localization.Authoring, editor only):

public LocalizedString Name;

// in Bake()
AddComponent(entity, new ItemName { Value = authoring.Name.ConvertWithError(authoring) });
  • ConvertWithError logs an error for a null or empty string and throws if the reference can't be resolved.
  • ConvertWithoutError returns default for null, empty or unresolvable strings. Use it for optional fields.

Entries referenced by key name are resolved to their key ID.

Runtime

if (itemName.Value.IsValid())
    label.text = itemName.Value.GetLocalizedString();

LocalizedString localized = itemName.Value; // implicit conversion, e.g. for LocalizeStringEvent

Lookups go through Unity Localization, so they're managed-only. LocalizedStringRef implements IEquatable, so it can be used as a hash map key.