Search Results for

    Show / Hide Table of Contents

    Localization

    If you want to create an application that supports different target languages, you may find useful localization mechanism provided by XRV. It scans your assemblies looking for embedded resource files (.resx), and provides a set of Evergine components that let you choose a dictionary name-entry pair for a 3D texts or buttons. Lookup assemblies must be decorated with EvergineAssembly attribute with UserProject or Extension as value.

    Note

    In current state, we only support English (fallback) and Spanish as available languages for applications. We plan to add extension points in the future to allow developers adding new languages.

    You can easily change current UI culture

    var localization = this.xrvService.Localization;
    localization.CurrentCulture = CultureInfo.GetCultureInfo("es");
    

    When culture changes, a CurrentCultureChangeMessage message is published in PubSub, indicating the value of the new UI culture. It also changes current thread CurrentUICulture and CurrentCulture values.

    Built-in components for localization

    We provide a set of components to control localization for button texts and 3D texts:

    • Text3dLocalization: to have localized text for Text3DMesh components.
    • ButtonLocalization: you can localize buttons text for entities with StandardButtonConfigurator component.
    • ToggleButtonLocalization: you can localize toggle buttons text for entities with ToggleStateManager component. You should have one component instance for each one of toggle states.

    localization 3D text sample


    For a toggle button, as we said, you must add one component for each one of toggle states.

    localization toggle button sample

    Get localized string from code

    To retrieve a localized string, just use of localization service.

    var localization = this.xrvService.Localization;
    var localizedString = this.localization.GetString(() => Resources.Strings.MyString);
    

    Hand menu buttons

    MenuButtonDescription has a way to set localized text for hand menu buttons. If your button is a toggle button, you can also indicate different strings for each one of the toggle states.

    var localization = this.xrvService.Localization;
    var description = new MenuButtonDescription()
    {
        TextOn = () => localization.GetString(() => Resources.Strings.MyString),
        TextOff = () => localization.GetString(() => Resources.Strings.MyString),
    };
    

    Tab items

    TabItem lets you to set a Func that will be invoked on first run or when current culture changes.

    var localization = this.xrvService.Localization;
    var item = new TabItem()
    {
        Name = () => localization.GetString(() => Resources.Strings.MyString),
        Contents = this.HelpContent,
    };
    

    Window title

    WindowConfigurator also uses an specific Func property to have localized text for window title.

    var windowsSystem = this.xrvService.WindowsSystem;
    var localization = this.xrvService.Localization;
    var window = windowsSystem.CreateWindow(config => 
    {
        config.LocalizedTitle = () => localization.GetString(() => Resources.Strings.MyString),
    });
    

    Alert dialogs

    WindowsSystem API has overload methods for both ShowAlertDialog and ShowConfirmationDialog, where you can assign Func callbacks to have localized dialogs.

    var windowsSystem = this.xrvService.WindowsSystem;
    var dialog = windowsSystem.ShowAlertDialog(
        () => localization.GetString(() => Resources.Strings.MyAlertTitle),
        () => localization.GetString(() => Resources.Strings.MyAlertMessage),
        () => localization.GetString(() => Resources.Strings.MyAlertOk));
    
    In This Article
    Back to top
    Generated by DocFX