My Development Notes

By Haemoglobin
3/10/2010 (revision 1)

Globalization

Local Resources

Local resources specific to a single web page.

App_LocalResources //in each folder
    PageName.aspx.resx //Default if it can't find a match. Use Tools &rarr Generate Local Resource to create this - properties like Text, ToolTip, Title, Caption and other string based properties for each control will be transfered (Label1Resource1.Text = ).
    PageName.aspx.es.resx //language specific (copy and paste default and modify)
    PageName.aspx.es-mx.resx //culture specific

asp:Label id="Label1" Text="My Label" meta:resourcekey="Label1Resource1"

Resources for different languages can be tested by changing the language preferences in the web browser.

Global Resources

These define strings that can be read from any web page.

App_GlobalResources
    LocalizedText.resx //Named whatever, contains strings, images, icons, audio files etc
    LocalizedText.es.resx //copy and pasted and modified.

Now in design mode on a control, click ellipsis on the Controls "Expressions" property. In the window you can map a property to the resource file and resource item name. This adds:

asp:Label ID="Label1" Text="<$ Resources:LocalizedText, ResourceName%>" 

//Or in the code behind
Label1.Text = Resources.LocalizedText.ResourceName; //The Localize control can be used for static text (much like Literal control) 
//If not available at design time need to use
Label1.Text = (string)GetLocalResourceObject("Button1.Text").ToString();

Setting Current Culture

If the user is travelling the browser might be set to an incorrect culture setting. Should allow them to choose their language from within the web application. You can then set it as follows:

proctected override void InitializeCulture()
{
    //Define language
    UICulture = //User selection

    //Define formatting (requires specific culture
    Culture = //User selection

    base.InitializeCulture(); 
}

//Lists of cultures can be listed with
CultureInfo.GetCultures(CultureTypes.AllCultures|NeutralCultures|SpecificCultures);

//Can specify culture in web.config
globalization uiculture="es" culture="es-MX" //or at the page level
//By default, these are auto.

Accessibility

  • Some controls provide support automatically like Menu, TreeView, Wizard support skipping links.
  • Provide alt text for images
  • Write useful link text
  • Use tables correctly (with thead)
  • Avoid requiring client scripts
  • Provide good keyboard navigation, default buttons and logical tab orders.
  • Visual studio can provide accessibility checking for WCAG priority 1/2 and Access board selection 508.

Comments

Powered by BlogEngine.NET 1.6.1.0 | Design by styleshout | Enhanced by GravityCube.net | 1.4.5 Changes by zembian.com | Adapted by HamishGraham.NET
(c) 2010 Hamish Graham. Banner Image (c) Chris Gin