The resource manager constructor indicates the file from which resources are to be loaded.
Several alternatives
- Load from a loose .resources file
- Load from this assembly
- Load from another assembly
- Load from a custom resource format if you write your own resource manager (e.g. a database)
ResourceManager class
The ResourceManager class provides convenient access to culture-correct resources at run time. A ResourceManager manages multiple resources from a common source that has a particular root name.
Multiple class constructors provide support for different scenarios, including retrieving resources from assemblies and resources files. A separate, static method supports retrieving resources from stand-alone resource files, such as images. The default implementation loads all the resource names and then loads the values on demand, storing them for later use. This uses less memory than the ResourceSet class, assuming not all resources are loaded, but initially retrieving a specific resource might take longer. In addition, the default ResourceManager implementation supports object serialization. Finally, ResourceManager objects provide fallback resource lookup to region-independent and neutral cultures when specific localized resources are not provided.
CurrentUICulture
Resource manager can be used to load both strings and objects:
RM.GetString("string", new CultureInfo(en-NZ))
RM.GetString("string2")
RM.GetObject("Button1.Cursor")
Loads requested resources based on
Thread.CurrentThread.CurrentUICulture
Fallback hierarchy derived from RFC 1766
The default for CurrentUICulture is based on the user interface language of the operating system. If an application wants to enable users to switch between different languages of a multi-lingual applications it has to provide the user interface for the switching by itself (except for the Windows MUI versions in which the Regional Options settings already allow the user to select a user interface language).
CultureInfo Class
The CultureInfo Class is part of the System.Globalization namespace in Microsoft .NET Framework. It contains culture-specific information, such as the language, country/region, calendar, and cultural conventions associated with a specific culture. This class also provides the information required for performing culture-specific operations, such as casing, formatting dates and numbers, and comparing strings.
The culture names follow the RFC 1766 standard in the format "[-]", where is a lowercase two-letter code derived from ISO 639 and is an uppercase two-letter code derived from ISO 3166 alpha-2.
Netural Culture
- Based on language
- Resource only
- No formatting
- CurrentUICulture only
A neutral culture is specified by only the two-digit lowercase culture code. For example, "fr" specifies the neutral culture for French, and "de" specifies the neutral culture for German. As neutral cultures only specify a language, but not a locale they only can be used for tagging resources. For example a date format for the neutral culture "fr" could not be determined, because it would be unknown if the date format for France, Belgium, Luxembourg, Monaco, Canada or Switzerland is meant.
Specific Culture
- Based on language & region
- Resource & Formatting specifics
- CurrentCulture & CurrentUICulture
A specific culture is identified by the culture code followed by the two-digit uppercase subculture code. For example, "fr-FR" specifies French in France and "fr-CA" specifies French in Canada.