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/**/*'
          ]
        }

Yeoman and images handling issues (on Windows 7 64b at least)

I'm trying out Yeoman these days, along with AngularJS, Bootstrap and the Yeoman Maven plugin to integrate everything in a tool I already know :-)

The bootstrapping phase works great, even on Windows assuming that you already have a batch like cygwin installed. However I started facing some issues as soon as I added some images in the project.

After adding some images, I got the following error during grunt build :

   Warning:
    g:\dev\proj\intranet-homepage\yo\node_modules\grunt-contrib-compass\node_modules\tmp\lib\tmp.js:261
      throw err;
            ^
    Error: spawn ENOENT
        at errnoException (child_process.js:980:11)
        at Process.ChildProcess._handle.onexit (child_process.js:771:34) Use --force to continue.


As it turns out, Grunt does not like jpg files. That is, the imagemin module does not. So, converting those jpg files to png did the trick.