I develop an ASP.NET MVC solution with Durandal and Breeze. I need to translate frontend to french and dutch. How to proceed with Durandal/knockout?
In a classic ASP.NET MVC solution we have the opportunity to have the views rendered server side (thanks to razor).
Thanks for your help.
To expand on Rob's answer of trying the i18n.js plugin for require.js, here's the steps I followed (I'm working off the Durandal starter template in Visual Studio).
App
folder.Create an
App/nls
folder, which is where you will put the require.js resource bundles, e.g.App/nls/welcomeBundle.js
.You'll see I added a line to tell require.js that there's a French version available. This will be created in
App/nls/fr-fr/welcomeBundle.js
, which I kinda did below (changed the to le :D)require.js needs to be configured initially with the locale (can't be done dynamically). So in the main.js file, I declare the below
getLocale()
function, which I use to configure the locale for require.js:In the welcome.js module I then load the bundle and use it for the displayName property:
I then set the locale to French and reload the page via JavaScript:
Hope that helps :)
Edit: 2013-04-04: I updated the above to initialize the locale in the main.js file and not in the shell.js module, as for some reason the locale wasn't being used correctly when loading the bundle in the shell module. Figure that it should be configured as soon as possible anyway.