background preloader

Localization

Facebook Twitter

Nadeem Afana's blog · ASP.NET MVC 3 Internationalization - Part 2 (NerdDinner) In my previous blog post, ASP.NET MVC 3 Internationalization, I talked in detail about creating a multilingual ASP.NET MVC 3 website and showed the different techniques that can be used to globalize an MVC 3 website. Perhaps the best way to learn about internationalization is by applying it to a real-world application.

In this post, I am going to show you how to globalize the popular web application, NerdDinner. We’ll tackle the obstacles one by one and from server-side to client-side. We will add the Spanish language to the website, so we can have Spanish nerds joining us. If a website targets users from different parts of the world, these users might like to see the website content in their own language. We will revamp the NerdDinner web application, so that: It can display contents in different languages.It autodetects the language from the user's browser.It allows the user to override the language of their browser.

Internationalization, Globalization and Localization. Firefox Views. Nadeem Afana's blog · ASP.NET MVC 3 Internationalization. Public static class CultureHelper private static readonly List<string> _cultures = new List<string> { "en-US", "es", "ar" /// <summary> /// Returns true if the language is a right-to-left language. Otherwise, false. /// </summary> public static bool IsRighToLeft() return System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft; /// Returns a valid culture name based on "name" parameter. /// <param name="name" />Culture's name (e.g. en-US)</param> public static string GetImplementedCulture(string name) if (string.IsNullOrEmpty(name)) return GetDefaultCulture(); if (_validCultures.Where(c => c.Equals(name, StringComparison.InvariantCultureIgnoreCase)).Count() == 0) if (_cultures.Where(c => c.Equals(name, StringComparison.InvariantCultureIgnoreCase)).Count() > 0) return name; var n = GetNeutralCulture(name); foreach (var c in _cultures) if (c.StartsWith(n)) return c; /// Returns default culture name which is the first name decalared (e.g. en-US) /// <returns></returns> return _cultures[0];

While my keyboard gently weeps... Globalization, Internationalization and Localization in ASP.NET MVC 3, JavaScript and jQuery - Part 1. ASP.NET MVC - Localization Helpers. In addition to blogging, I'm also using Twitter. Follow me @matthawley Note: This post has been updated to work with MVC 2 RTM. The example code is a bit smelly (use POCOs, please!) But the localization helpers do correctly work with the WebFormViewEngine.

You're localizing your application right? 1: <asp:Label Text="<%$ Resources:Strings, MyGlobalResource %>" runat="server" /> 2: <asp:Label Text="<%$ Resources:MyLocalResource %>" runat="server" /> Of course, you could always use the verbose way and call out to the HttpContext to get local and global resources, but I really enjoy writing the expression syntax much better as it truly implies that the code knows the context of your view / page. 1: <%= HttpContext.Current.GetGlobalResourceString("Strings", "MyGlobalResources", 2: CultureInfo.CurrentUICulture) %> 3: <%= HttpContext.Current.GetLocalResourceString("~/views/products/create.aspx", 4: "MyLocalResource", CultureInfo.CurrentUICulture) %> Okay, now you're all set. 12: return RenderView();

MVC 2: Полное руководство по локализации / ASP.NET MVC. В данной статье мы рассмотрим все аспекты локализации веб приложения основанного на ASP.NET MVC. Я использую последнюю доступную MVC 2 RC 2 версию на время написания данного топика. До того, как мы начнем я хотел бы поблагодарить команду MVC, отличная работа ребята, я наслаждаюсь процессом написания веб-приложений, когда использую данный фреймворк. Я искал фреймворк такого типа, после небольшого опыта работы с Ruby on Rails. Мы рассмотрим следующие проблемы: Валидация представленийПростой механизм переключения культурЛокализация сообщений валидации моделиЛокализация атрибута DisplayNameКэш и локализацияДля работы вам понадобится Visual Studio 2008 Express и ASP.NET MVC 2 RC2, а также создать новый MVC 2 веб-проект.

Локализация представлений Для локализированного текста будет, конечно же, использованы файлы ресурсов, но мы не будем использовать для хранения стандартные папки asp.net. Я предлагаю следующую структуру директорий: Views — файлы ресурсов для aspx страниц. Файлы ресурсов Важно! ASP.NET MVC 2 Localization complete guide. In this article we are going to explore all aspects of localization web application based on ASP.NET MVC framework. The version I'll be using for that purpose will be 2 RC 2 which is last available at the time of writing.

NOTE 01.09.2010: In this article Session is used for storing current culture, please also as an addition consider reading my next post about localization where routing mechanism used for that purpose(better SEO and simpler implementation). Also you will find there link to the source code. Before we start I would like to thank the MVC framework team, great job guys, I really like it :) I really enjoy writing web application with the framework. OK, lets see what issues we'll cover Views validationSimple culture switching mechanismModel Validation messages localizationDisplayName attribute localizationOutputCache and LocalizationFor this guide you'll need Visual Studio 2008 Express and ASP.NET MVC 2 RC2 installed. Views localization Here is folder structure I suggest 14: get. Localization in ASP.NET MVC – 3 Days Investigation, 1 Day Job. An upgraded article and solution had been posted here. I migrated the project to ASP.NET MVC 4 with some features added. - Upgraded to ASP.NET MVC 4, Visual Studio 2012. - Moved the solution to a separated project. - Moved the procedure originally executed in base controller's ExecuteCore to a separated class.

Now can use the this solution without needing inherit from the localization base controller. - Implemented the localization resource provders so that can use any data source (database, XML file, etc.) to store the localization resource. - Improved the language selector bar. Now can use partial view as the selected and unselected link content with images, scripts, etc. Localization is a common issue when we develop a world wide web application. The key point of making your application localizable is to separate the page content from your logic implementation. Last week I was implementing the localization on my ASP.NET MVC application. Localization supported by ASP.NET MVC 8: <h2><%