Tuesday, December 3, 2013

Yeoman-scaffolded applications and i18next

i18next is a great lib to handle internationalization in javascript. When i first attempted to use it with Yeoman, I had to slightly change the Gruntfile.js to tell it to package the translations in the dist repository.

You first add the dependency to your project :

bower install i18next --save

Then, if you store your translations in the default path (/locales/en/translations.json and so on) then add the following to the Gruntfile.j copy:dist definition :

copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            'bower_components/**/*',
            'images/{,*/}*.{gif,webp}',
            'fonts/*',
            'locales/**/*'
          ]
        }

No comments:

Post a Comment