2011 - dotnetfranken: asp.net mvc localization

31
devcoach.co m ASP.NET MVC Localization Daniel Fisher | devcoach Καλώς Ήλθατε Willkommen Welcome přivítat bienvenido bienvenu sevilen

Upload: daniel-fisher

Post on 31-Jul-2015

50 views

Category:

Software


0 download

TRANSCRIPT

devcoach.com

ASP.NET MVC Localization

Daniel Fisher | devcoach

Καλώς Ήλθατε

Willkommen

Welcome

přivítat

bienvenido

bienvenu

sevilen

devcoach.com

devcoach.comBERTAUNG + SCHULUNG + PROJEKTE

• Themen– Architektur & Technologie

Evaluierung, Performance Optimierung, Entwicklungs-Unterstützung, Security Reviews, QA, POC & Know-how-Transfer

• Technologien– Services: WCF & WF– Data: ADO.NET & EF– Web: ASP.NET, MVC & Silverlight

• Kunden– Versicherung, Finanzindustrie,

Mittelstand, Handel, Kommunikation, Softwarehersteller… Und sie?

• Kontakt– [email protected]

devcoach.com

Daniel Fisher• devcoach.com

– Mit-Gründer und Geschäftsführer

• Justcommunity.de– Mit-Gründer und Vorstand

• nrwconf.de– Mit-Gründer und Organisator

• netug-niederrhein.de– Mit-Gründer und Leiter

• microsoft.com– Community Leader & Insider (CLIP)– Certified Professional Developer– Business Platform Technology Advisor

• lennybacon.com– Blog

• twitter.com– @lennybacon

devcoach.com

Efficient Communication…

devcoach.com

Agenda

• Loco?lize• Server– Thread Localization– Resource Localization– View Localization

• Client– Jquery Localization

• Summary

devcoach.com

Customer

• "Users should select a language (by clicking e.g. a flag) and information will be presented in the corresponding language."

devcoach.com

Developer

• "If the users clicks on a flag I reload the page and transmit the language as parameter to load the information in the corresponding language."

devcoach.com

The process of localization…

Server

HTTP GET

HTTP 200

HTTP GET (select language)

HTTP 200

HTTP GET

HTTP 200

devcoach.com

devcoach.com

Customer

• "Users should select a language (by clicking e.g. a flag) and information will be presented in the corresponding language. The selection should be maintained as long as the user browses out site!"

devcoach.com

The process of localization…

Server

HTTP GET

HTTP 200

HTTP GET (select language)

HTTP 200

HTTP GET

HTTP 200

STATE

devcoach.com

Code

var language = Session["Language"] ?? Request.QueryString["lang"];

if(!string.IsNullOrWhitespace(language ){ Session["Language"] = language ;}

devcoach.com

devcoach.com

devcoach.com

Requirements

• Customer: Information should be presented in the language requested if possible.

devcoach.com

Wait… that is part of HTTP

• RFC2295: Transparent Content Negotiation in HTTP– http://gewis.win.tue.nl/~koen/conneg/rfc

2295.txt

devcoach.com

devcoach.comIn the beginning there was

nothing…

…God said, 'Let there be URI!'

And there was URI. 

devcoach.com

devcoach.com

HTTP://LOCALHOST/EN/DEMO1

Thread Localization

devcoach.com

Resource Localization

• The .NET Way– *.resx– *.de.resx–…

devcoach.com

Resource Localization

• The ASP.NET Web Forms Way– [Page/

Control].GetGlobalResourceObject(…)– [Page/

Control].GetLocalResourceObject(…)–<asp:Button ID="btnSubmit"

runat="server" Text="<%$ Resources:btnSubmit.Text %>" />

–<asp:Button ID="btnSubmit" runat="server" meta:resourcekey="btnSubmit" />

devcoach.com

Resource Localization Tools

• Zeta Resource Editor?

• Kein ASP.NET? WPF?– NLocalize ;-)• http://www.nlocalize.de• Auch hier Sponsor!

devcoach.comResource Localization

Extensibility

ASP.NET

ResourceProviderFactory

ResourceProvider

ResourceReader

Your Code

devcoach.com

HTTP://LOCALHOST/EN/DEMO2

Resource Localization

devcoach.com

devcoach.com

HTTP://LOCALHOST/EN/DEMO3

View Localization

devcoach.com

devcoach.com

devcoach.com

HTTP://LOCALHOST/EN/DEMO4

jQuery Plugins Localization

devcoach.com

THX C U @LENNYBACON