0.1.2 • Published 8 years ago

grunt-language2js v0.1.2

Weekly downloads
1
License
-
Repository
github
Last release
8 years ago

grunt-language2js npm version Build Status

Grunt plugin for converting .properties language files into an AngularJS module

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-language2js --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-language2js');

The "language2js" task

Overview

In your project's Gruntfile, add a section named language2js to the data object passed into grunt.initConfig().

grunt.initConfig({
  language2js: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});

Options

options.module

Type: String Default value: 'language-properties'

A string value that is used as the module name for the AngularJS module

options.localSeparator

Type: String Default value: '.'

A character that is used to separate the locale from the rest of the file name - will be matched according to somefilename{{localSeparator}}{{locale}}.properties

Usage Examples

Default Options

In this example, the default options are used to generate an AngularJS module from all *.properties files in the solution.

grunt.initConfig({
  language2js: {
    options: {},
    files: {
      'dest/angular-language-module.js': ['**/*.properties'],
    },
  },
});

Custom AngularJS module name

In this example, the generated AngularJS module will get my-language-module as its module name.

grunt.initConfig({
  language2js: {
    options: {
        module: "my-language-module"
    },
    files: {
      'dest/angular-language-module.js': ['**/*.properties'],
    },
  },
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.