public void Initialize()
        {
            originalLanguage = InputLanguageManager.Current.CurrentInputLanguage;
            logger.Info($"Saved current keyboard layout {ToString(originalLanguage)}.");

            foreach (CultureInfo info in InputLanguageManager.Current.AvailableInputLanguages)
            {
                var layout = new KeyboardLayoutDefinition
                {
                    CultureCode = info.ThreeLetterISOLanguageName.ToUpper(),
                    CultureInfo = info,
                    Name        = info.NativeName
                };

                if (originalLanguage.Equals(info))
                {
                    currentLayout = layout;
                }

                layouts.Add(layout);
                logger.Info($"Detected keyboard layout {ToString(info)}.");
            }

            InputLanguageManager.Current.InputLanguageChanged += Current_InputLanguageChanged;
        }
        private void Current_InputLanguageChanged(object sender, InputLanguageEventArgs e)
        {
            var newLayout = layouts.First(l => l.CultureInfo.Equals(e.NewLanguage));

            logger.Info($"Detected keyboard layout change from {ToString(e.PreviousLanguage)} to {ToString(e.NewLanguage)}.");
            currentLayout = newLayout;

            foreach (var control in controls)
            {
                control.SetCurrent(newLayout);
                control.SetInformation(GetInfoTextFor(newLayout));
            }
        }
 private string GetInfoTextFor(KeyboardLayoutDefinition layout)
 {
     return(text.Get(TextKey.SystemControl_KeyboardLayoutTooltip).Replace("%%LAYOUT%%", layout.CultureInfo.NativeName));
 }