Posts Tagged ‘.NET’

Visual Studio 2010 and .NET Framework 4 Release Candidate Available

Wednesday, February 10th, 2010

Visual Studio 2010 and .NET Framework 4 RC (Release Candidate) were made available to all MSDN subscribers on February 8.

The rest of the world will have a chance do get it on Wednesday, February 10th. This version also includes a go-live license.

For more information on the RC, visit Jason Zander’s Weblog.

Happy coding!

Visual Studio 2010 and .NET Framework 4 Beta 1

Friday, May 22nd, 2009

Visual Studio 2010 Beta 1 is here!

Team Suite edition is available for download and can be obtained from Visual Studio 2010 Beta 1.

Also you can install new .NET Framework 4 Beta 1.

You can check out the new things this version has brought on Zander’s blog.

There are also walkthroughs available on MSDN so check them out too.

If you need a help installing VS2010 you can use this video guideline from Channel9.

Happy coding ;)

Localization and Globalization in C#: Globalization

Thursday, March 19th, 2009

Like localization, globalization in .NET is easy. If you want your application to be globalization-aware you need to display all the date, time, currency and other data in the proper display format. Fortunately, every .NET Convert method has a built in IFormatProvider parameter you can use to specify the culture you want your globalization-aware data to be displayed in. In order to force yourself to use the IFormatProvider, you can use CODE_ANALYSIS in Visual Studio, or external FxCop application which does the same thing. This application inspects your code and suggest to you how you can improve it.

DateTime.Now.ToString(CultureInfo.CurrentCulture);

If the data you are working with is not going to be displayed to the user, for example, you want to save information into a file so you can load it later, you should not use the CurrentCulture as an IFormatProvider. If you save your settings using the “de-AT” culture, and then you try to load them using “en-US” culture you might end-up with the invalid data. For this purposes, you should use CultureInfo.InvariantCulture, since it is invariant to both localization and globalization settings.

DateTime.Now.ToString(CultureInfo.InvariantCulture);

Localization and Globalization in C#: Localization

Wednesday, February 25th, 2009

.NET has an elegant way of localizing your applications. If you want to write your code well, you will store all the messages, titles, captions and other strings in the appropriate resource files (.resx) in your application. Your application has to have a main resource file (or files), for example MeritResources.resx. You can store all the default strings and other resources there. If you want to localize your application to, for example “fr-FR” culture, you can simply create another resource file and name it MeritResources.fr-FR.resx. It is simple as that.

To explain how your application is localized we need to explain how .NET framework decides where to extract the appropriate strings and other resources from. When selecting localization resource, .NET framework is using the CultureInfo.CurrentUICulture property. If your CurrentUICulture is “de-AT” .NET framework will first look for the MeritResources.de-AT.resx resource file. If this file is missing, it will look for the next best thing and it is the MeritResources.de.resx file. If this resource file is also missing, default resource file named MeritResources.resx will be used.

So, if you are using the most common version of Windows (Englis version), you are stuck with the “en-US” culture; hence, your application will always use your English resource. In order to mitigate this, you can perform a little trick at your application startup. You can mislead your application to look in your CurrentCulture property instead of CurrentUICulture property. At the application startup, you can write something like this:

Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

This way, your application will use your globalization setting instead of your default windows localization setting. Your application will be localized to your globalization language and culture. If you change the Regional Settings in your Control Panel, your application language and culture will change automatically.

Localization and Globalization in C#: Introduction

Wednesday, February 25th, 2009

.NET is equipped with powerful, yet simple, application localization and globalization mechanisms.

Localization is the process of translating resources to a specific culture. On the other hand, globalization is the process of designing applications that can adapt to different cultures. Basically, when you select the application language, you need to specify the culture the selected language is used in. For example, English language is used in United States, Canada and Great Britain, among other countries. Although, people in these countries are using the same language, their cultures are different (i.e.: date and time format differences, currency is different, etc.). There is a standard for designating the cultures. A list of currently available cultures can be found here.

In the heart of localization and globalization mechanism in the .NET framework is the System.Globalization namespace. In the heart of this namespace is the CultureInfo class with its static properties. Some of those properties are InvariantCulture, CurrentCulture, CurrentUICulture, etc.

CurrentCulture property has a lot to do with the Regional Settings in your Control Panel. Basically, Regional Settings in your Control Panel is the place where can you set how you want your date, time, currency and other stuff to appear in your Windows. CurentCulture static property reflects that setting.

On the other hand, CurrrentUICulture is in connection with the Windows itself. Most of us are using English version of Windows, to be more precise “en-US” version of Windows, but there are other Windows localizations available on the market. CurrentUICulture property reflects the Windows language.

In another words, if your Windows is in English (all messages, titles, captions, etc.), your CutureInfo.CurrentUICulture is “en-US”. This setting has nothing to do with the Regional Settings you have set in your Control Panel. Your CutlureInfo.CurrentCulture can be set to “fr-FR” on the “en-US” Windows. This setting will affect only date, time, currency and other display formats.