GithubHelp home page GithubHelp logo

pilifs / grunt-i18nlint Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jwarby/grunt-i18nlint

0.0 2.0 0.0 1.42 MB

A Grunt task which uses of `i18n-lint` to scan HTML and template source files to find hardcoded, untranslated strings.

Home Page: http://jwarby.github.io/i18n-lint/

JavaScript 100.00%

grunt-i18nlint's Introduction

grunt-i18nlint GitHub version

Build Status Dependency Status devDependency Status

An opinionated Grunt task for finding hardcoded, untranslated strings in HTML and template source files

grunt-i18nlint screenshot

Getting Started

This plugin requires Grunt.

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 jwarby/grunt-i18nlint --save-dev

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

grunt.loadNpmTasks('grunt-i18nlint');

The "i18nlint" task

The task assumes that your translation keys are similar in form to 'my.amazing.key'. The task can be used to detect potentially hardcoded strings in element text nodes, and optionally from a list of HTML attributes (think alt, title, etc.).

Overview

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

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

Options

options.attributes

Type: Array Default value: ['alt', 'title']

An array of HTML attributes which should be checked for hardcoded strings. To disable attribute checking, set this to an empty array or a falsy value.

options.ignoreTags

Type: Array Default value ['script', 'style']

An array of HTML elements to ignore when searching for hardcoded strings.

options.templateDelimiters

Type: Array Default value: []

An array which is to contain the start and end delimiters of the templates to be scanned. Content within template delimiters is ignored.

Examples
EJS
grunt.initConfig({
  i18nlint: {
    options: {
      templateDelimiters: ['<%', '%>']
    },
    src: 'myproject/**/*.ejs'
  }
});
Mustache-like
grunt.initConfig({
  i18nlint: {
    options: {
      templateDelimiters: ['{{', '}}']
    },
    src: [
      'mymodule1/**/*.hbs',
      'mymodule2/**/*.hbs'
    ]
  }
});

options.reporter

Type: String or Function Default value: i18nlint.reporters.default

  • Set the i18n-lint reporter to use when outputting linting results. If a function is provided, it will be called for each input file, with an array containing the errors for found for the file.
  • If a string is provided, it must be a valid path or module name that can be require'd, and required file must export a reporter property. The reporter property should be a function as described above

See the i18n-lint Documentation or visit i18n-lint on GitHub for more information on reporters and error object descriptions.

options.force

Type: Boolean Default value: false

Force Grunt to carry on running even if the task fails.

Usage Examples

Default Options

In this example, the default options are used, which means the task will check text nodes, alt attributes and title attributes:

grunt.initConfig({
  i18nlint: {
    src: '**/*.html'
  },
})

Custom Options

In this example, attribute checking is disabled, and EJS templating is used:

grunt.initConfig({
  i18nlint: {
    options: {
      templateDelimiters: ['<%', '%>'],
      attributes: null
    },
    src: 'test/fixtures/*.ejs'
  }
})

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.

Bugs and Feature Requests

Please raise all bugs and feature requests on the issue tracker.

Release History

(Nothing yet)

License

Copyright (c) 2015 James Warwood. Licensed under the MIT license.

grunt-i18nlint's People

Watchers

 avatar  avatar

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.