public virtual void Init()
        {
            GlobalizationManager = new GlobalizationManager(Resources.MergedDictionaries);
            StyleManager = new StyleManager(Resources.MergedDictionaries);

            // Load the default style
            CreateAvailableStyles();
            StyleManager.SwitchStyle(StyleManager.DefaultStyle);

            // Get current 5 character language and load the appropriate Globalization file
            CreateAvailableLanguages();
            try
            {
                GlobalizationManager.SwitchLanguage(Thread.CurrentThread.CurrentCulture.Name, true);
            }
            catch(CultureNotFoundException)
            {
                // Try the fallback
                GlobalizationManager.SwitchLanguage("en-US", true);
            }

            // Create the FallbackResourceDictionary
            FallbackResourceDictionary = new FallbackResourceDictionary() { Name = "Fallback" };
            Resources.MergedDictionaries.Add(FallbackResourceDictionary);
        }
예제 #2
0
        public virtual void Init()
        {
            GlobalizationManager = new GlobalizationManager(Resources.MergedDictionaries);
            StyleManager         = new StyleManager(Resources.MergedDictionaries);

            // Get current 5 character language and load the appropriate Globalization file
            CreateAvailableLanguages();
            try
            {
                GlobalizationManager.SwitchLanguage(Thread.CurrentThread.CurrentCulture.Name, true);
            }
            catch (Exception ex)
            {
                // Try the fallback
                GlobalizationManager.SwitchLanguage(GlobalizationManager.FallBackLanguage, true);
                Debug.WriteLine($"{nameof(GlobalizationManager.SwitchLanguage)} error.\r\n{ex.Message}");
            }

            // Load the default style
            CreateAvailableStyles();
            try
            {
                StyleManager.SwitchStyle(StyleManager.FallBackStyle, true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"{nameof(StyleManager.SwitchStyle)} error.\r\n{ex.Message}");
            }

            // Create the FallbackResourceDictionary
            FallbackResourceDictionary = new FallbackResourceDictionary()
            {
                Name = "Fallback"
            };
            Resources.MergedDictionaries.Add(FallbackResourceDictionary);
        }