Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
In Visual Studio 2010 Essential Training, author Walt Ritscher demonstrates how to use Visual Studio 2010 Professional to develop full-featured applications targeting a variety of platforms. Starting with an overview of the integrated developer environment, the course covers working with code editors, navigating and formatting code, and deploying applications. Also included are tutorials on running performance and load tests, and debugging code. Exercise files accompany the course.
If you write an application for global consumption, you need to consider catering to the needs of multiple cultures. That is called localization in .NET terms. Let me show you how it works. I'm inside a solution called Localization, and I have a project called CultureResources open. I have one resource already set up inside this application. It's inside this Resources.resx file. I have this String resource, and the value of that is Hello welcome to .NET. Since I haven't localizes this application I'm using the default culture, which is US English.
.NET supports all the cultures supported in Windows operating systems. I want to create a second version of this localized string, so to do that I'm going to create a new resx file. Before I show you that though, let me show you what's inside my binary folder. I am going to click on Show All Files, and then I am going to open this bin folder, and then I am going to compile my application. Notice that there's just an exe and pdb file on here. Now what I am going to do is I am going to copy this Resource file and paste it back into the same folder--Ctrl+V to paste it back in--and then I'm going to add a suffix on the end of this that's culturally specific.
So I am going right here after the word "Resources," and I am going to type in period. Then I am typing es, for Spanish, and then a hyphen MX, for Mexico. So what this is saying is I want to create some resources for the Mexican culture. So what do I mean by cultural messages? We are not just talking about my translations--right now we are talking about translated strings--but it's also things like the calendar day names, the month names, which currency symbols to use when you're showing data as currency.
That's all cultural information as part of .NET. Right now, I've got two separate resx files. If I come into this resx file, I'm changing the string for the Mexican culture. Now let's show you the Resources.resx file that has the English string still in it. Now watch what happens when I compile my application. There is a few more folders created now inside my bin folder.
I now have this es.MX folder, and it contains this resource file. Every single resx file that I add for a different cultures is going to cause another folder should be generated in my Debug folder. What happens when your application runs is it talks to the operating system, sees what version of the operating system you're running, creates a thread and a brand-new culture info object, and attaches the culture info object for that culture to the thread. Let me show you how that's done. I'll switch over my code behind, and here's what I'm talking about.
This is the CultureInfo object. Right now, I'm creating a culture info object for US English culture. Then I am going to assign that culture to the current thread. Here you see it says current culture is used by formatting and affects things like dates, currency, and numbers. I am going to run the application. I first thing is to put a breakpoint in my code. I'll put one right here, F9, add a breakpoint in, and then I'll press F5 to run the application. I am going to run this one line of code, and then I am going to pause for second and show you what's inside this culture info.
I am going to take this auto window, and I am going to put out so you can see it and make it a little bit taller. And then we are going to pop this open and show you what's inside there. There is calendar information, there is numbering formatting information, and there are lots of details about this US English culture. I'm going to Ctrl+Click on this header to put back where it belongs. Now I come down here, and I attempt to parse the string, since I am on the US English culture, it shows up as a Date/ Time of 1-8-2009. And if I look at the Month value, you see that that's a month of 1.
Now on this line of code, we are using a slightly different alternative to getting the culture and parsing it. This is the German culture. If I look at the 'd' value now, you'll see that the month is 8 because their culture uses day first and then month and then year. Next, I'm going to go to the Resources section, that resx file, and I am going to tell Visual Studio that I'm using this culture. This would be the US English culture. And then when I go get the string that says Hello Welcome to .NET.
Now down here I am going to get the Mexican culture, and then I'm going to apply the Resources. And now when I go get that same welcome message, you'll see that I now has the localized version of that string. There are other localization tools available inside Visual Studio. You might want to check out the Windows Forms localization. Its very nice. You can design your UI using Windows forms, drag or drop your controls on the designer surface and say that this designer surfaces is for the English culture and this designer surface is for the Spanish culture, and it manages the changes between those.
Resources of all kinds are important for applications. As you can see, Visual Studio makes it simple to add both binary resources and culturally specific resources.
Find answers to the most frequently asked questions about Visual Studio 2010 Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.