Giter Club home page Giter Club logo

grunt-i18n's Introduction

grunt-i18n Build Status

![Gitter](https://badges.gitter.im/Join Chat.svg)

Internationalization support for grunt.

Getting started

This plugin requires Grunt ~0.4.0

Please note this is a coffeescript task and the sources are located in src folder, javascript is generated.

i18n task

Run this task with the grunt i18n command. Task targets, files and options may be specified according to the grunt Configuring tasks guide.

This plugin provides a localization mechanism for grunt templates. It was developed as a tool for localizing AngularJS templates during a grunt build process. Since localization is done once during the build there is no performance hit on the application, as oppose to dynamic localization.

Usage example

Please check the test as they demonstrate the usage pretty well. In short you need localization files and a HTML template/s. As an output you get one translated HTML template/s per localization file.

Options

Available options to configure the task.

locales

Type: String|Array

Path to localization files. Please check the examples in tests. Glob patterns can be used.

output

Type: String

Root output folder.

base

Type: String

Base folder for HTML templates which should not be preserved while translating. Please check the tests if you don't get it ;)

delimiters

Type: String

Custom delimiters name to be used instead of the default <% %>. See the grunt.template documentation for more details.

format

Type: String

Supports 'json', 'yaml', 'transifex', 'properties'.

Locales from Transifex have all their translations below one root property, the name of the translation:

{
  "en_US": {
    "message": "Hello world!",
    "nested": {
      "msg": "and hello to you"
    }
  }
}

parser

Type: Object

Custom parser to read locale files. There are 2 functions which have to be provided:

  • resolveLocale: (localePath) -> locale - get locale from locale path
  • readLocaleData: (localePath) -> data - read locale file

For example check src/parsers.coffee

Release History

  • 2013-11-11   v0.7.0   Properties parser. Custom parsers
  • 2013-12-31   v0.6.0   Transifex locale format added
  • 2013-12-06   v0.5.0   Can read locals in yaml format
  • 2013-11-29   v0.4.0   Custom delimiters and localization file existence checks
  • 2013-10-23   v0.3.0   Fix for separator in output path. Add logging messages
  • 2013-10-22   v0.2.0   Might be useful for others
  • 2013-05-28   v0.1.0   Initial release, not really useful for anybody except me ;)

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.