Satellite Assemblies

                 Satellite assemblies are compiled library used to implement localization in .net application.Strings, images, icons, and audio we can add in the resource files. For each language there will be different resource file with suitable language code like for US English “.en-US” is postfix.


For more information about language codes refer this link

 Assembly will set the CurrentUICulture and CurrentCulture for current thread to language application specified;

 In one of the application I worked, we were implementing localization through satellite assemblies.
These are the steps followed.

  •       Create a class library with suitable name.
  • ·     private System.Resources.ResourceManager resourceMananger declared;
        

public ResourceManager()
        {
          
            resourceImage = new System.Resources.ResourceManager(ResourceFullName, Assembly.GetExecutingAssembly());
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(LangCode)
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(LangCode);
        }

 


public System.Drawing.Bitmap GetImage(string queryImage)
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(LangCode);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture
             (LangCode);
            return (System.Drawing.Bitmap)resourceImage.GetObject(queryImage);
        }

 


  •  LangCode is a property and its value is code for the language set.
  •  ResourceFullName contains resource file’s class name with namespaces (without                     language code postfix).
  •  Same applies for string, icons, and audio.
  • Call GetImage or GetString functions of assembly to get localized resources.

No comments:

Post a Comment

Pages