browse by category or date

I have previously made a small pet project done in Ext.NET MVC that requires multi-language UI. So today I’ll share with you what i’ve done, hopefully it can be useful to those who need it. If you have a better idea, kindly let me know. So that I learn something too 😉

Taken from Cuckoo’s call

All Strings in Resource Files

In order to translation, you must have a number of resource files. Each for the language that you plan to support. After you added the resource files, you should have something similar to this:

Make sure that each resource file has the same number of records and records Name.

Using the resource file in the UI

Below is example of the usage of the resource file on the front-end


Selecting the Correct Language

Now that we have all the resource files that is needed, we need to tell ASP.NET rendering engine to pick-up the correct resource file. To do that, we need to switch the Culture before the Controllers is doing their job. For my case, I override Application_AuthenticateRequest method in Global.asax.cs to execute the following code:

HttpRequest Req = HttpContext.Current.Request;
if (Req.UserLanguages != null && Req.UserLanguages.Length>0)
	var Lang = Request.UserLanguages[0]; //Browser Locale Setting

	//My UI allows its users to change the language preference
	//and stored the selection in a Cookie
	if (Req.Cookies["cultureCode"] != null
		&& !String.IsNullOrEmpty(Req.Cookies["cultureCode"].Value))
		Lang = Req.Cookies["cultureCode"].Value;

	if (!String.IsNullOrEmpty(Lang))
		System.Globalization.CultureInfo Culture = null;
			Culture = new System.Globalization.CultureInfo(Lang);
			//Lang is not a valid culture code (e.g. en-US, fr-CA)
			//Do something or Ignore
		if (Culture != null) {
			System.Threading.Thread.CurrentThread.CurrentCulture = Culture;
			System.Threading.Thread.CurrentThread.CurrentUICulture = Culture;
GD Star Rating
How To Enable Multi Language Translations in Ext.NET MVC, 4.0 out of 5 based on 1 rating

Possibly relevant:

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

1 Trackback


No Comment

Add Your Comment