Localization Approach for ASP.NET Web site

String Resources

For string resources we will use local/global resources connecting to DB using DbResourceProvider from  “Creating a Data Driven ASP.NET Localization Resource Provider and Editor”

It also has  DbResourceControl,  that shows controls with Localizable attribute and connect them to editor.

From http://guysmithferrier.com/Downloads/Top10TipsI18NASPNET.pdf and
To convert your HTML controls to equivalent ASP.NET server side controls, look at the I18NRefactorings (an add-in for VS) in the download at http://www.dotneti18n.com/Downloads.aspx (folder VS2010/ASPNETSpecifics/I18NRefactorings/I18NRefactorings in the 2010 zip)that will help automate this process.

Javascript Files

For javascripts we should separate localizable and non-localizable functions ,e.g. MyScript.js and MyScript.L10n.js(L10n stands for localization)  and
use ResourceUICultures to specify languages supported, e.g.(from Around the World with ASP.NET ASP.NET AJAX documentation Applications http://msdn.microsoft.com/en-us/magazine/cc135974.aspx#S3)

<asp:ScriptManager ID=”ScriptManager1″ runat=”server”



   <asp:ScriptReference Path=”MyScript.L10n.js”     ResourceUICultures=”ru”/>



Consider to use CompositeScript as described in
http://bellouti.wordpress.com/2008/09/14/combining-javascript-files-with-ajax-toolkit-library/ and

ASP.NET Control to extract Resource information as JSON http://www.codeproject.com/KB/custom-controls/ResourcesToJavaScript.aspx

ScriptManager links
Other related links
Check if a language file is loaded for jQuery Globalization plugin

CSS Files
For CSS consider to use different themes for different cultures.
(examples not L10n specific
Dynamically Applying Themes To Your ASP.Net Site With A Sitemap
ASP.NET Themes and Skins http://msdn.microsoft.com/en-us/library/ykzx33wh.aspx

From http://stackoverflow.com/questions/3230576/load-different-css-for-site-localization
void Page_PreInit(object sender, EventArgs e)
   //If current context has no session then abort
   if (HttpContext.Current.Session == null)

   //Get current page context
   Page page = (Page)sender;

   switch (page.Culture) {
       case “en-US”:
           page.Theme = “en-USTheme”;
       case “fr-FR”:
           page.Theme = “fr-FRTheme”;
           page.Theme = “DefaultTheme”;
Additionally  FallBack implementation is required.

Alternative css -related solutions
http://stackoverflow.com/questions/1221441/localize-images-via-css has a few suggestions, not something too attractive.
CSS Loader from resource http://forums.asp.net/t/1346799.aspx/1?CSS+with+localization not attractive for me- prefer to maintain css in file system

Concerns about themes from  http://forums.asp.net/t/1176552.aspx/1

I have abandoned the concept of Themes, at least the ASP.NET way. There are several reasons for that:

  1. One cannot control the CSS files used on a page through Theming. All CSS files in a Theme gets applied, even if you plan to use just one for a page.
  2. One cannot localize a Theme, one need to create a copy of the default and apply the changes to it, creating a theme that is culture specific.


The solution I opted for is to create my own Styles folder in which different ‘Themes’ are place in their respective subfolders. I can now control the CSS & apply text-direction when neccessary.


Localized Files

string cultureSpecificFileName = String.Format(“TOS_{0}.pdf”, CultureInfo.CurrentCulture.Name)
In the example given, the file would have to be named TOS_en-US.pdf. It you want to use the 2-letter ISO culture names, use CurrentCulture.TwoLetterISOLanguageName and then the file name would be TOS_en.pdf.
You can create page specific resource files or global resource file and localize imageurl there.
For example, in Default.en-GB.aspx (in App_LocalResources): Image1.ImageUrl = “xxx”, while add meta:resourceKey=”Image1″ in .aspx to the Image to localize~
Or make a MyGlobal.en-GB.resx (in App_GlobalResources), Image1Url = “xxx”, and then add ImageUrl=”<%$ Resources:MyGlobal, Image1Url %>” to the Image to localize.

From http://www.globalme.net/web-localization/aspnet-localization
If possible, try avoiding images and graphics with embedded text. Using background images and retrieving the text from a resource file will make the localization effort much easier. If that is not possible, point the source of the image to the resx file which will let you easily change it depending on the language. This applies to other external assets such as pdf and doc files as well.

Tools for adding Localization to an ASP.NET project

Resharper for localization -http://www.jetbrains.com/resharper/webhelp/Resources__Index.html
If don’t have Resharper -try free Resource Refactoring Tool (http://resourcerefactoring.codeplex.com/)

Zeta Resource Editor http://zetaresourceeditor.codeplex.com/ also lists a few other tools.

Consider GetCultureFromUrl(Request.Url);
(from http://guysmithferrier.com/Downloads/Top10TipsI18NASPNET.pdf)

General Localization related links:

Localizing Resources for Component Libraries Overview


http://www.beansoftware.com/ASP.NET-Tutorials/Globalisation-Multilingual-CultureInfo.aspx http://www.asp.net/general/videos/how-do-i-create-a-multi-lingual-site-with-localization

Generate a local resource file from an ASP.NET Web page



Localize ASP.NET MVC 2 DataAnnotations validation messages with a custom resource provider

Why we have both CurrentCulture and CurrentUICulture

Extending the ASP.NET 2.0 Resource-Provider Model
BONUS CHAPTER 1.Resources and Localization