logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class PreviewLocalization

    Best-effort, edit-mode translation of localization keys for the View Preview, so the preview shows the same text the game would instead of raw keys (which are much longer and overflow the screen).

    Inheritance
    object
    PreviewLocalization
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Ui.Infrastructure.Editor.Preview
    Assembly: Serenity.UnityUi.Infrastructure.Editor.dll
    Syntax
    public static class PreviewLocalization
    Remarks

    The runtime localization service isn't available in edit mode, so this reads the project's StringTableCollections directly through the editor Localization API via reflection — that way this file compiles and runs even if the Localization package/API isn't present or changes; any failure reads as a miss, which renders the game's own missing-key text. Among the tables that have a value for a key, LocalePreviewMatcher picks the one matching LocalizationSettings.SelectedLocale (via Serenity.Global.Infrastructure.Editor.UnityLocalizationLocaleEditorUtils), falling back to English, then to any hit. Results are cached.

    Methods

    ClearCache()

    Drops cached lookups (e.g. when the user hits Refresh).

    Declaration
    public static void ClearCache()

    HasTranslation(string)

    Whether any of the project's string tables has a translation for key.

    Declaration
    public static bool HasTranslation(string key)
    Parameters
    Type Name Description
    string key
    Returns
    Type Description
    bool

    Translate(string)

    Translates key to the project's text. A key no string table has renders exactly as the running game renders it (For(string)) — a missing-key message under the project's Localization Settings — so the preview shows the defect instead of hiding it.

    Declaration
    public static string Translate(string key)
    Parameters
    Type Name Description
    string key
    Returns
    Type Description
    string

    TryTranslate(string, out string)

    Looks key up in the project's string tables.

    Declaration
    public static bool TryTranslate(string key, out string text)
    Parameters
    Type Name Description
    string key

    The localization key.

    string text

    The translation for the selected locale, or null on a miss.

    Returns
    Type Description
    bool

    True when a string table translates the key.

    In this article
    © 2026 Serenity. All Rights Reserved