Video: Twitter MicroPresentation

On Saturday at Modern .NET I gave my second micro-presentation. This time it was on Twitter. Micro-presentations are also called Pecha Kucha (Japanese for "chit-chat") and 20/20 so called because these presentations are always 20 slides where each slide is 20 seconds (because PowerPoint is set to auto-advance after 20 seconds). I recorded a sound track for the micro-presentation and recorded the slides and have put together a video (6 minutes 52 seconds) that you can download here. Phil Winstanley has a real video filmed on a camcorder that you can watch here (the first 10 seconds or so are missing but there's a better atmosphere).

Thanks to everyone who attended and endured my particular stance on this. Also thanks to @Plip for being such a good sport. And thanks to Phil Winstanley, Dave Sussman and all of the speakers for a great day.

One final thought to leave you with: DDD 9 is on Saturday 29th January 2011. They will probably be looking for micro-presentations there as well. Give it a go - it's loads of pain and stress fun.

Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: guysmithferrier
Posted on: Monday, October 25, 2010 at 3:06 PM
Categories: Events | Miscellaneous - Other | DDD
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (1) | Post RSSRSS comment feed

Building Localized XAP Resource Files For Silverlight 4

The steps for localizing Silverlight applications using standard .resx files are relatively straight forwards. You can follow these steps on my "Internationalizing Silverlight" slides and see a completed demo in the downloadable source code for the same presentation (see the Localization101 folder). The main problem to resolve in this scenario is that the strongly typed resource class must be public and must have a public constructor. The solution to this problem lies in a previous blog post. This blog post discusses the next stage.

Silverlight faces the same deployment problem that ClickOnce applications face: if you follow the regular localization route then your deployment solution includes all languages for all users. Purely for performance reasons this is not desirable. The optimum solution is to provide the user with only the resources for the one required language. There is no built-in solution in Visual Studio 2010 that covers this scenario - that is what this blog post is about.

The solution is to build one XAP file with the Silverlight application and fallback resources (e.g. SilverlightApplication1.xap) and a separate XAP containing language-specific satellite resource assemblies for each deployed culture (e.g. SilverlightApplication1.fr-FR.xap, SilverlightApplication.es-ES.xap). At runtime the Silverlight application dynamically loads the required XAP resource file. In earlier versions of Silverlight this was possible using WebClient to download the XAP file and AssemblyPart.Load to load the satellite resource assembly into the Silverlight application's domain. This is still possible but MEF (Managed Extensibility Framework) provides a much neater solution (MEF, however, performs almost exactly the same steps as the original solution). To load and use the XAP resource file change the App.Application_Startup event in App.xaml.cs to:-

private void Application_Startup(object sender, StartupEventArgs e)
{
    string xapResourceFilename = String.Format("{0}.{1}.xap",
        "SilverlightApplication1",
        Thread.CurrentThread.CurrentUICulture.Name);

    DeploymentCatalog catalog = new DeploymentCatalog(
        new Uri(xapResourceFilename, UriKind.Relative));

    CompositionHost.Initialize(catalog);

    catalog.DownloadCompleted += (s, args) =>
    {
        this.RootVisual = new MainPage();
    };

    catalog.DownloadAsync();
}

This code uses MEF's DeploymentCatalog to load the XAP resource file (e.g. SilverlightApplication1.fr-FR.xap) containing the application's satellite resource assembly (e.g. SilverlightApplication1.resources.dll). The new MainPage is only created once the download is complete (or has failed). At this point the satellite resource assembly has been loaded into the Silverlight application's app domain and the regular ResourceManager (or whatever resource manager class you use) can get to work resolving the resources. You can see a completed demo in the downloadable source code (see the DownloadOnDemand folder).

The hardest part to solve in this process is the creation of the XAP resource files (e.g. SilverlightApplication1.fr-FR.dll). There is no support for this scenario in Visual Studio 2010 so you have to build this bit yourself. Or rather, you have to download the MSBuild tasks that I have created to solve this problem. Silverlight.Build.Tasks.zip contains the source code to build a library of MSBuild tasks (Silverlight.Build.Tasks.dll) and an MSBuild targets file (Silverlight.Build.Tasks.targets) that you add to your Silverlight application's .csproj file. Full details are in the solution's ReadMe.txt but in essence you add the following lines to the bottom of your .csproj file:-

<Import Project="$(ProgramFiles)\MSBuild\I18N\Silverlight\v4.0\Silverlight.Build.Tasks.targets" />

<Target Name="AfterBuild" DependsOnTargets="XapResourcePackager">
</Target>

Then you add the following line immediately below your .csproj's </SupportedCultures> line:-

<PackageCultures>fr-FR</PackageCultures>

(where <PackageCultures> contains a comma delimited list of cultures to create XAP resource files for).

The result is that when you build your Silverlight application the necessary XAP resource files are also built. If your Silverlight application has a corresponding website that hosts the Silverlight application then those XAP files are copied to the website's ClientBin folder just like the Silverlight application's XAP. You can see a completed demo in the downloadable source code (see the DownloadOnDemandAutomatedBuild folder).

Of course this only covers one Silverlight deployment scenario but it is common enough that it demands a solution.

Enjoy.

Currently rated 3.4 by 13 people

  • Currently 3.384615/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: GuySmithFerrier
Posted on: Sunday, October 10, 2010 at 10:25 PM
Categories: Internationalization | Silverlight
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (4) | Post RSSRSS comment feed