none
Splashscreen localization RRS feed

  • Question

  • Hello,

    Do somebody know if the image loaded by the splashscreen is localizable ?

    On the MSDN site (http://msdn.microsoft.com/en-us/library/system.windows.splashscreen.aspx), I can read :

    When your application is compiled, the image is embedded as a managed resource in the assembly. If the application is localized, the image is embedded in the localized satellite DLL.

    I tried to embed the image in the resource, but it doesn't work...

    Thank you :)

    Wednesday, August 31, 2011 7:50 AM

Answers

  • It seems that the splash screen does not support localization. The splash screen will be set and compile to the application, and then it will auto generate the *.g.cs, you can see the image file name and the splash screen is set in this file, it is a hard code thing.

    The way you can do is modify the *.g.cs source file, and use a if or switch statement to let program instant the different SplashScreen.

    Image can be embed into the localized satellite dll, but the splash screen has set, hard coded. 

    You can use something like this to set the SplashScreen:

     

        public static void Main() {
          string splashImage = "resources/default.jpg";
    
          //Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR"); //Impersonate the fr language environment
          if (Thread.CurrentThread.CurrentUICulture.Name == "fr-FR")
            splashImage = "resources/fr.jpg";
    
          SplashScreen splashScreen = new SplashScreen(splashImage);
          splashScreen.Show(true);
          WPFLocalizationTest.App app = new WPFLocalizationTest.App();
          app.InitializeComponent();
          app.Run();
        }
    
    Best wishes,

     


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by alaksjukilo Thursday, September 1, 2011 12:56 PM
    Thursday, September 1, 2011 10:24 AM
    Moderator
  • Thanks Dos Zhang!

     

    Here is what I have done :) :

     static ApplicationHelper()
        {
          Assembly assembly = Assembly.GetExecutingAssembly();
          AssemblyName assemblyName = new AssemblyName(assembly.FullName);
          ResourceManager resourceManager = new ResourceManager(string.Concat(assemblyName.Name, ".g"), assembly);
          ResourceSet set = resourceManager.GetResourceSet(CultureInfo.InvariantCulture, true, true);
          keys = new List<string>();
    
          if (set != null)
          {
            foreach (DictionaryEntry o in set)
            {
              keys.Add((string)o.Key);
            }
          }
        }
    
    
    
     public static void SetSplashScreen()
        {
          CultureInfo uiCulture = Thread.CurrentThread.CurrentUICulture;
    
          while (!string.IsNullOrEmpty(uiCulture.Name))
          {
            if (keys.Contains("images/splashscreen." + uiCulture.TwoLetterISOLanguageName.ToLowerInvariant() + ".png"))
            {
              break;
            }
            uiCulture = uiCulture.Parent;
          }
    
          if (!string.IsNullOrEmpty(uiCulture.Name))
          {
            App.SplashScreen = new SplashScreen("Images/splashscreen." + uiCulture.TwoLetterISOLanguageName + ".png");
          }
          else
          {
            App.SplashScreen = new SplashScreen("Images/splashscreen.png");
          }
        }
    

     

    • Marked as answer by alaksjukilo Thursday, September 1, 2011 12:56 PM
    Thursday, September 1, 2011 12:56 PM

All replies

  • It seems that the splash screen does not support localization. The splash screen will be set and compile to the application, and then it will auto generate the *.g.cs, you can see the image file name and the splash screen is set in this file, it is a hard code thing.

    The way you can do is modify the *.g.cs source file, and use a if or switch statement to let program instant the different SplashScreen.

    Image can be embed into the localized satellite dll, but the splash screen has set, hard coded. 

    You can use something like this to set the SplashScreen:

     

        public static void Main() {
          string splashImage = "resources/default.jpg";
    
          //Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR"); //Impersonate the fr language environment
          if (Thread.CurrentThread.CurrentUICulture.Name == "fr-FR")
            splashImage = "resources/fr.jpg";
    
          SplashScreen splashScreen = new SplashScreen(splashImage);
          splashScreen.Show(true);
          WPFLocalizationTest.App app = new WPFLocalizationTest.App();
          app.InitializeComponent();
          app.Run();
        }
    
    Best wishes,

     


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by alaksjukilo Thursday, September 1, 2011 12:56 PM
    Thursday, September 1, 2011 10:24 AM
    Moderator
  • Thanks Dos Zhang!

     

    Here is what I have done :) :

     static ApplicationHelper()
        {
          Assembly assembly = Assembly.GetExecutingAssembly();
          AssemblyName assemblyName = new AssemblyName(assembly.FullName);
          ResourceManager resourceManager = new ResourceManager(string.Concat(assemblyName.Name, ".g"), assembly);
          ResourceSet set = resourceManager.GetResourceSet(CultureInfo.InvariantCulture, true, true);
          keys = new List<string>();
    
          if (set != null)
          {
            foreach (DictionaryEntry o in set)
            {
              keys.Add((string)o.Key);
            }
          }
        }
    
    
    
     public static void SetSplashScreen()
        {
          CultureInfo uiCulture = Thread.CurrentThread.CurrentUICulture;
    
          while (!string.IsNullOrEmpty(uiCulture.Name))
          {
            if (keys.Contains("images/splashscreen." + uiCulture.TwoLetterISOLanguageName.ToLowerInvariant() + ".png"))
            {
              break;
            }
            uiCulture = uiCulture.Parent;
          }
    
          if (!string.IsNullOrEmpty(uiCulture.Name))
          {
            App.SplashScreen = new SplashScreen("Images/splashscreen." + uiCulture.TwoLetterISOLanguageName + ".png");
          }
          else
          {
            App.SplashScreen = new SplashScreen("Images/splashscreen.png");
          }
        }
    

     

    • Marked as answer by alaksjukilo Thursday, September 1, 2011 12:56 PM
    Thursday, September 1, 2011 12:56 PM
  • You're welcome!

    And thanks for sharing yours code here.

    Have a nice day!


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Friday, September 2, 2011 8:20 AM
    Moderator