Translating Views Using HotTowel (Durandal Framework) + VS2012

I am developing an ASP.NET MVC solution with Durandal and Breeze. I need to translate the interface into French and Dutch. How to continue working with Durandal / knockout?

In the classic ASP.NET MVC solution, we have the ability to display representations on the server side (thanks to the razor).

Thank you for your help.

+5
source share
3 answers

To deploy Rob's answer on trying to connect to the i18n.js plugin for require.js, here are the steps I followed (I'm working on a Durandal starter template in Visual Studio).

  • Download the i18n.js plugin and put it in a folder App.
  • App/nls, require.js, . App/nls/welcomeBundle.js.

    define({
        "root": {
            "displayName": "Welcome to the Durandal Starter Project!"
        },
        "fr-fr": true
    });
    
  • , , require.js, . App/nls/fr-fr/welcomeBundle.js, - ( le: D)

    define({
        "displayName": "Welcome to le Durandal Starter Project!"
    });
    
  • require.js ( ). main.js getLocale() , locale require.js:

    function getLocale() {
        var locale = 'en-us';
        if (localStorage) {
            var storedLocale = localStorage.getItem('locale');
            locale = storedLocale || locale;
        }
        return locale;
    }
    
    requirejs.config({
        paths: {
            'text': 'durandal/amd/text'
        },
        locale: getLocale()
    });
    
  • welcome.js displayName:

    define(function(require) {
        var bundle = require('i18n!nls/welcomeBundle');
        return {
            displayName: bundle.displayName,
            ...
        }
    });
    
  • JavaScript:

     localStorage.setItem('locale', 'fr-fr');
     location.reload();
    

, :)

: 2013-04-04: , main.js, shell.js, - . , .

+7
0

All Articles