Ejemplo n.º 1
0
        public static void Load()
        {
            // Get the language from the user settings
            string cultureCode = SettingsManager.Current.Localization_CultureCode;

            // If it's empty... detect the windows language
            if (string.IsNullOrEmpty(cultureCode))
            {
                cultureCode = CultureInfo.CurrentCulture.Name;
            }

            // Get the language from the list
            LocalizationInfo info = List.Where(x => x.Code == cultureCode).FirstOrDefault();

            // If it's not in the list, get the first one
            if (info == null)
            {
                info = List.First();
            }

            // Change the language if it's different than en-US
            if (info.Code != List.First().Code)
            {
                Change(info);
            }
            else
            {
                Current = info;
                Culture = new CultureInfo(info.Code);
            }
        }
Ejemplo n.º 2
0
        public static void Change(LocalizationInfo info)
        {
            // Set the current localization
            Current = info;

            // Set the culture code
            Culture = new CultureInfo(info.Code);
        }
Ejemplo n.º 3
0
        public static void Change(LocalizationInfo info)
        {
            // Set the current localization
            Current = info;

            // Remove dictionaries, which are no longer required
            if (_resourceDictionaryLocalization != null)
            {
                Application.Current.Resources.MergedDictionaries.Remove(_resourceDictionaryLocalization);
            }

            // Create/Initialize a new dictionary from the .xaml-file in the resource
            _resourceDictionaryLocalization = new ResourceDictionary {
                Source = new Uri(info.Path, UriKind.Relative)
            };

            // Add the new dictionary
            Application.Current.Resources.MergedDictionaries.Add(_resourceDictionaryLocalization);

            // Set the culture code
            Culture = new CultureInfo(info.Code);
        }