grunt-google-translate

Automatically generate localized json files using angular-translate source files, and Google Translate REST API

grunt-google-translate

Automatically generate localized json files using angular-translate source files, and Google Translate REST API

This plugin requires Grunt ~0.4.4

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-google-translate --save-dev

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

grunt.loadNpmTasks('grunt-google-translate');

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

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

Type: String Default value: ``

The API key used to access Google Translation services.

Type: String Default value: en

The language code that will be treated as the "source".

Type: String Default value: ./il8n/**/en.json

The path Grunt will use to find the available source files.

Type: Array Default value: []

If included, the translation will be limited to the language codes provided in the array. For example:

['de','fr']

will only create German and French translations.

This example will first generate Spanish and German translations from English. It will then USE the German translation as the source, and generate a French translation.

grunt.initConfig({
    google_translate: {
      default_options: {
        options: {
            srcPath: './il8n/**/en.json'
            sourceLanguageCode: 'en',
            googleApiKey: '<INSERT GOOGLE API KEY HERE>',
            restrictToLanguages: ['es', 'de']
        }
      },
    german_to_french: {
        options: {
            googleApiKey: '<INSERT GOOGLE API KEY HERE>',
            restrictToLanguages: ['fr'],
            sourceLanguageCode: 'de'
        }
      }
    }
 });

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.

(Nothing yet)