Class Language
Language helpers.
public static class Language
- Inheritance
-
Language
- Inherited Members
Methods
GetLanguageChoiceMenuItems(IActiveLanguage)
Gets a set of language choices that can be used to populate a menu with the list of language choices supported by Pinpoint.
public static IEnumerable<MenuItemViewModel> GetLanguageChoiceMenuItems(IActiveLanguage activeLanguageService)
Parameters
activeLanguageServiceIActiveLanguageA service provided by the client that tracks the active language.
Returns
- IEnumerable<MenuItemViewModel>
A collection of MenuItemViewModel objects.
Remarks
To use this, do the following:
Include Resources/Menu.xaml in the application's resource dictionaries. For example:
<Application.Resources>
<ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/Acuit.Pinpoint.Windows;component/Resources/Menu.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>
Implement IActiveLanguage and add a property to the main view model with the results of this call. For example:
class MainViewModel : NotificationObject, ILanguage
{ public MainViewModel() { LanguageChoices = Language.GetLanguageChoices(this); }
public IEnumerable<LanguageChoiceViewModel> LanguageChoices { get; private set; }
public string ActiveLanguage
{
get
{
// Implement this...
}
set
{
// Implement this...
// Be sure to call RaisePropertyChanged(nameof(ActiveLanguage)); when it changes
}
}</code></pre>
Add the languages menu to the main view XAML like this:
<MenuItem Header="_Language" ItemsSource="{Binding LanguageChoices}" ItemContainerStyle="{StaticResource MenuItemContainerStyle}" />
PromptForLanguageChangeRestart(string, IUserInterfaceService)
Shows a generic prompt like "The application must be restarted for this change to take effect. Do you want to restart now?" and gets a Yes/No response. If the user responds with Yes, returns true.
public static bool PromptForLanguageChangeRestart(string newCultureName, IUserInterfaceService userInterfaceService)
Parameters
newCultureNamestringThe culture representing the language to which we are changing.
userInterfaceServiceIUserInterfaceServiceThe user interface service.
Returns
- bool
True if the user indicated to restart now.
Remarks
The prompt is shown in both the current language as well as in the newly-specified language. This method assumes that the current thread's CurrentUICulture has NOT yet been set to the new language's culture.
Exceptions
- ArgumentNullException
userInterfaceServiceis null.