I l @ ve RuBoard |
The .NET framework provides a family of classes that are designed to make resource management consistent and easy. These classes are as follows :
Your application must use a ResourceManager to load the resource assemblies and make them available to the rest of the program. The ResourceManager will return a ResourceSet for a given culture. Got Culture?Different cultures and languages are identified through the CultureInfo class. This class is a simple information store that contains data about the culture selected by the user when he or she installed the operating system. It contains information about the language, calendar, currency, and other preferences that the user might have chosen . Your software will have access to this information so that it can determine whether it has the ability to offer culture-specific resources or must choose the neutral default value. Being culture specific might be very important in the message you are trying to deliver. There is an anecdote that illustrates why.
Culture information about languages is provided by a two-letter code and an optional region identifier that accompanies the two letter code. For example, the neutral English language is represented by the two letter code en , but the different flavors of English ”English from England, Canada, the United States and other places ”is identified by the sub-codes GB , CA , US , and so on. Listing 3.4.1 shows a program that will get the CultureInfo for your computer and display the language and region that applies to your computer. It also shows the full name of the culture and which calendar your current culture is using. Listing 3.4.1 culture.cs: Displaying the Current Culture Information1: namespace Sams 2: { 3: using System; 4: using System.Drawing; 5: using System.Collections; 6: using System.ComponentModel; 7: using System.Globalization; 8: using System.Windows.Forms; 9: using System.Data; 10: 11: class CultureInfoTest : Form 12: { 13: 14: public CultureInfoTest() 15: { 16: this.Size = new Size(300,200); 17: 18: Label l = new Label(); 19: l.Location = new Point(3,5); 20: l.Size = new Size(294,190); 21: 22: InputLanguage inL = InputLanguage.CurrentInputLanguage; 23: 24: CultureInfo info = inL.Culture; 25: 26: l.Text = String.Format("Culture identifier = { 0} \ n"+ 27: "Display name = { 1} \ n"+ 28: "Calender = { 2} \ n", 29: info.ToString(), 30: info.DisplayName, 31: info.Calendar.ToString()); 32: this.Controls.Add(l); 33: 34: } 35: static void Main() 36: { 37: Application.Run(new CultureInfoTest()); 38: } 39: } 40: 41: } |
I l @ ve RuBoard |