|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +permalink: /internationalization-recap.html |
| 4 | +date: 2012-03-05 22:00 |
| 5 | +title: "Recap: i18n Packages for MVC4" |
| 6 | +author: "@aeoth, @shiftkey and @tobin" |
| 7 | +comments: true |
| 8 | +--- |
| 9 | + |
| 10 | +Rather than boring you with the details of how this week went - it was quiet, then chaotic towards the end - I thought I'd run you through the packages you can install today and see the hard work done. |
| 11 | + |
| 12 | +These packages are split up so that users can pull in the features that they want in their applications, but if you want to start with a new application you can get started quickly. |
| 13 | + |
| 14 | +<div style="width: 700px"> |
| 15 | +<div class="nuget-button-commandWrapper"> |
| 16 | + <div class="nuget-button-commandPrompt"> |
| 17 | + <p class="nuget-button-command">PM> Install-Package <a href="http://nuget.org/List/Packages/Code52.i18n">Code52.i18n</a></p></div></div> |
| 18 | +</div> |
| 19 | + |
| 20 | +The core package contains a helper class for mapping a locale code to a CultureInfo object, with additional helper methods to identify culture-related information. |
| 21 | + |
| 22 | +This also includes a config transform to enable globalization on your website. |
| 23 | + |
| 24 | +<div style="width: 700px"> |
| 25 | +<div class="nuget-button-commandWrapper"> |
| 26 | + <div class="nuget-button-commandPrompt"> |
| 27 | + <p class="nuget-button-command">PM> Install-Package <a href="http://nuget.org/List/Packages/Code52.i18n.MVC4">Code52.i18n.MVC4</a></p></div></div> |
| 28 | +</div> |
| 29 | + |
| 30 | +<div style="width: 700px"> |
| 31 | +<div class="nuget-button-commandWrapper"> |
| 32 | + <div class="nuget-button-commandPrompt"> |
| 33 | + <p class="nuget-button-command">PM> Install-Package <a href="http://nuget.org/List/Packages/Code52.i18n.MVC3">Code52.i18n.MVC3</a></p></div></div> |
| 34 | +</div> |
| 35 | + |
| 36 | +These packages extend the core and allow a user to override their current region inside your application. There are two pieces to this: |
| 37 | + |
| 38 | + * A ```LanguageController``` to handle requests from the browser and set a cookie value. |
| 39 | + * A ```LanguageFilterAttribute``` set globally to detect the cookie and set the culture for the current user to a different value. |
| 40 | + |
| 41 | +<div style="width: 700px"> |
| 42 | +<div class="nuget-button-commandWrapper"> |
| 43 | + <div class="nuget-button-commandPrompt"> |
| 44 | + <p class="nuget-button-command">PM> Install-Package <a href="http://nuget.org/List/Packages/Code52.i18n.MVC4.Example.Razor">Code52.i18n.MVC4.Example.Razor</a></p></div></div> |
| 45 | +</div> |
| 46 | + |
| 47 | +<div style="width: 700px"> |
| 48 | +<div class="nuget-button-commandWrapper"> |
| 49 | + <div class="nuget-button-commandPrompt"> |
| 50 | + <p class="nuget-button-command">PM> Install-Package <a href="http://nuget.org/List/Packages/Code52.i18n.MVC3.Example.Razor">Code52.i18n.MVC3.Example.Razor</a></p></div></div> |
| 51 | +</div> |
| 52 | + |
| 53 | +These are the sample sites which have controllers, views and resources all ready to go. It is recommended that you install these into a **Blank** MVC Project as that's the scenarios we've been testing currently. |
| 54 | + |
| 55 | +Cool features: |
| 56 | + |
| 57 | + * jQuery.globalize support |
| 58 | + * ModelMetadataProvider using [Phil Haack's)[http://haacked.com] [ConventionalModelMetadataProvider](http://haacked.com/archive/2011/07/14/model-metadata-and-validation-localization-using-conventions.aspx) POC. |
| 59 | + |
| 60 | +## 10 Second Introduction |
| 61 | + |
| 62 | +A very quick walkthrough after installing the example site package. You should see a page resembling this: |
| 63 | + |
| 64 | +  |
| 65 | + |
| 66 | +*Start the application and you'll see the label in the top-left with your current language.* |
| 67 | + |
| 68 | +  |
| 69 | + |
| 70 | + *Click on it to slide down a selector with the available languages.* |
| 71 | + |
| 72 | +  |
| 73 | + |
| 74 | + *Pick one and the cookie gets set, reloads the page, and displays the new language.* |
| 75 | + |
| 76 | +A special shout-out to [David Christiansen](http://twitter.com/dchristiansen) who has been a great help this week with his tips and tricks like the above. |
| 77 | + |
| 78 | +## Want to try it out? There be dragons. |
| 79 | + |
| 80 | +Warning: this may drown puppies and kick kittens. Please log any and all feedback you have on the [GitHub site](https://github.com/Code52/internationalization-mvc4/issues) - this is still under active development. |
| 81 | + |
| 82 | +Add this feed to your NuGet Package Source settings: http://www.myget.org/F/Code52 - this contains the latest builds from tonight's integration work. |
| 83 | + |
| 84 | +We'll let you know (by pushing the packages to NuGet officially and tweeting) when its stabilised and ready for general use. |
| 85 | + |
| 86 | +**Note:** Please read the App_Readme before diving straight in - you need to change the _ViewStart.cshtml file to point at the different template: |
| 87 | + |
| 88 | + @{ |
| 89 | + Layout = "~/Views/Shared/_Layout.Code52.cshtml"; |
| 90 | + } |
| 91 | + |
| 92 | + |
| 93 | +## But wait, there's more? |
| 94 | + |
| 95 | +There's a lot more to this story - we timed it when we thought we'd get a lot of interest (sadly that didn't eventuate), and I know there are people keen to get involved. |
| 96 | + |
| 97 | + * Pseudoizer - the build has the ability to generate test resources so you can verify the localization of a site, but we haven't got this integrated into a project. |
| 98 | + * DateTimeOffsetModelBinder - this has been started in [a fork](https://github.com/shiftkey/internationalization-mvc4/tree/ModelBinder-DateTimeOffset), but requires some polishing before we can merge it in to master. |
| 99 | + * NuGet - the packages are generated from a build script, and there's some things we'd like to do that require some more Powershell skills and understanding the hooks available in ```install.ps1```. For example, pointing _ViewStart.cshtml to use a custom layout page rather than the default. |
| 100 | + * Support for other versions/view engines/languages. |
| 101 | + * Improved styles for the project templates - unfortunately the blank project templates are a bit plain... |
| 102 | + |
| 103 | +As we had a lot of interest in this idea, and the number of features still available to implmenet, I hope this is just the beginning. |
0 commit comments