Geeks With Blogs

News My Blog has been MOVED to
Michael Freidgeim's OLD Blog My Blog has been MOVED to

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 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 (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

<asp:ScriptManager ID="ScriptManager1" runat="server"
   <asp:ScriptReference Path="MyScript.L10n.js"     ResourceUICultures="ru"/>

Consider to use CompositeScript as described in and

ASP.NET Control to extract Resource information as JSON

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

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 has a few suggestions, not something too attractive.
CSS Loader from resource not attractive for me- prefer to maintain css in file system

Concerns about themes from

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.

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 -
If don’t have Resharper -try free Resource Refactoring Tool (

Zeta Resource Editor also lists a few other tools.

Consider GetCultureFromUrl(Request.Url);

General Localization related links:

Localizing Resources for Component Libraries Overview

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

Posted on Saturday, July 2, 2011 9:00 PM ASP.NET | Back to top

Comments on this post: Localization Approach for ASP.NET Web site

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Michael Freidgeim | Powered by: