Localizing the Application Code

Provide access to the manually added resources.

  1. In the Code Editor, import the System.Resources namespace at the beginning of the code module.
    using System.Resources;
  2. Add the following code at the beginning of the class. The ResourceManager constructor takes two arguments. The first is the root name of the resources — that is, the name of the resource file without the culture and .resx suffixes. The second argument is the main assembly.
    ResourceManager LocRM = new ResourceManager("SampleApp.SampleApp", typeof(Customer).Assembly);
  3. Modify the code to use the ResourceManager GetString() method to replace hard-coded strings. For example, modify:
    AddString("Database deleted");

    to:

    AddString(LocRM.GetString("strDatabaseDeleted"));
    Note: By default, the ResourceManager object is case-sensitive. If you want to perform case-insensitive lookups you can set the resource manager's IgnoreCase property to true. However, for performance reasons, specify the correct case for your resource names.
  4. Repeat the localization procedures for Customer Details.cs.