This demo shows one way to localize your user interface to multiple languages. The main focus points of this demo are:
-
Shows how to use
ResourceDictionarys to map from labels to the actual text to display in the various languages supported. -
Shows how to use the
LoadXamlfunction in aBlueprintto load the dictionaries.
-
LevelToColorConverter.h: Implements an
IValueConverterused to convert theSoundLevelandMusicLevelproperties exposed by the view model to colors. -
MainWindow.h: Implements a minimal code-behind for MainWindow.xaml.
-
LocalizationGame.cpp: Implements a minimal game module that registers the NoesisGUI native components.
NoesisBlueprint'/Game/MainWindowView.MainWindowView': It's aNoesisViewforNoesisXaml'/Game/MainWindow.MainWindow'(MainWindow.xaml).
Blueprint'/Game/Language.Language': ThisObjectderivedBlueprintrepresents a language for the UI. It exposes two properties, theNameof the language and theResources, which are loaded from aNoesisXamlusing theLoadXamlfunction from theNoesisFunctionLibrary.
Blueprint'/Game/ViewModel.ViewModel': AnObjectthat is used as theDataContextforNoesisBlueprint'/Game/MainWindowView.MainWindowView'. It exposes the list of supportedLanguagesand the currentlySelectedLanguage, as well as the previously mentionedSoundLevelandMusicLevel.
TestLevel - Level Blueprint: Creates aWidgetfromNoesisBlueprint'/Game/MainWindowView.MainWindowView', adds it to the viewport and captures mouse input. It also creates several instances ofBlueprint'/Game/Language.Language'and an instance ofBlueprint'/Game/ViewModel.ViewModel'that it sets as theDataContextof theWidget.
NoesisGUI Project Settings: Sets theNoesisXamlNoesisXaml'/Game/Resources.Resources'as the global applicationResourceDictionary.