Giter Site home page Giter Site logo

grunt-localizr's Introduction

grunt-localizr

Build Status

A grunt task to support i18n using localizr module for dust templates. i18n is solved the way kraken supports today using .properties files.

The localizr module is a tool to apply localization to dust templates before rendering. This plugin uses that localizr module, and scans your project under the root app directory for

  • .dust files in public/templates
  • .properties content files for corresponding .dust files in locales/ folder

and puts the localized files in tmp/ dir. For example: Localizing public/templates/foo/bar.dust with locales/US/en/foo/bar.properties will generate tmp/US/en/foo/bar.dust

##Usage

In your Gruntfile.js

module.exports = function localizr(grunt) {
	// Load task
	grunt.loadNpmTasks('grunt-localizr');

	// Options
	return {
	    files: ['public/templates/**/*.dust'],
        options: {
            contentPath: ['locales/**/*.properties']
        }
	};
};

Using with kraken 1.0 apps

If you use generator-kraken for scaffolding your kraken apps, you will see that the generated Gruntfile.js will be automatically setting up the i18n task for you.

grunt-localizr's People

Contributors

aredridel avatar gabrielcsapo avatar grawk avatar hiroshi-maybe avatar jeffharrell avatar mikehedman avatar pvenkatakrishnan avatar thefourtheye avatar totherik avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-localizr's Issues

Leading character of file path removed

When using options such as the following:

{
        files: ['public/templates/**/*.dust', 'node_modules/pkg/public/templates/**/*.dust'],
        options: {
            contentPath: ['locales/**/*.properties']
        }
};

The grunt task generates at the following locations

Output: ./tmp/US/en/ode_modules/pkg/errors/404.dust
Expected: ./tmp/US/en/node_modules/pkg/errors/404.dust

Update: The script finds the correct files in node_modules but puts the localized versions in ode_modules

compiled file using wrong template

It can not compile a file in a subfolder correctly when we have another file that has the same file name on the root.

For example, we have 2 error.dust files. One under the root of the public/templates and another one under public/templates/portal/error folder. Each of them has the corresponding error.properties file.

If you run “grunt build” or “grunt i18n” and check the compiled templates in the .build folder, you can see the one under portal/error is messed up – it uses the template from the root and has snowmen in all content entries.

If I rename the dust and properties files to portError or just delete the error.properties file on the root, the problem is gone.

localizing dust files of same name in different directories

can result in wrong dust file localized against wrong locale bundle in wrong directory.

E.g.

With dust:

public/templates/application/create.dust 
public/templates/create.dust

And locale bundles:

locales/US/en/application/create.properties 
locales/US/en/create.properties 
  • grunt-localize will localize application/create.dust with application/create.properties and write to output/application/create.dust
  • grunt-localize will then localize create.dust with application/create.properties and overwrite output/application/create.dust
  • grunt-localize will localize create.dust with create.properties and write to output/create.dust

This happens because fileBundles will return an array of both create.properties files when it tries to localize templates/create.dust ([ 'locales/US/en/application/create.properties', 'locales/US/en/create.properties' ]). processWithBundles then will localize templates/create.dust twice, overwriting output/application/create.dust

Bump graceful-fs dependency

graceful-fs versions lower than v4 reevaluate native fs module source, which is not supported.
You should update your graceful-fs dependency to v4 or later.

Tracking issue: nodejs/node#5213.

Client side localized templates

I'm having a hard time wrapping my head around how to localize client side templates. I'm using webpack to bundle up my dust templates but I'm not sure how to localize them -- hoping someone can point me in the right direction. Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.