Grunt build task to concatenate & pre-load your Angular Translate translations using $translateCache
Last updated 3 years ago by ugo.poool .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @poool/grunt-angular-translate-cache 
SYNC missed versions from official npm registry.


Grunt build task to concatenate & pre-load your Angular Translate translations using $translationCache

Output example :

angular.module('test-app').run(['$translationCache', function($translationCache) {
  $translationCache.put("languages/en.json", {"test":"This is a <span class=\"test\">test</span>"});
  $translationCache.put("languages/fr.json", {"test":"Ceci est un test"});

Then, when you use a translation file with angular-translate-loader-static-files it will already be loaded without having to do another Ajax request !


This plugin requires Grunt ~1.0.0

Usemin integration requires grunt-usemin ~3.0.0

Install the plugin :

  • NPM : $ npm install @poool/grunt-angular-translate-cache --save-dev
  • Yarn : $ yarn add @poool/grunt-angular-translate-cache

Enable the plugin within your Gruntfile :




Global namespace for Angular.

If you use angular.noConflict(), then set this value to whatever you re-assign angular to. Otherwise, it defaults to angular.


Callback to modify the bootstraper that registers lang files with $translationCache.

By default, the bootstrap script wraps function($translationCache) { ... } with:

angular.module('app').run(['$translationCache', ... ]);

If you want to create your own wrapper so you register the templates as an AMD or CommonJS module, set the bootstrap option to something like:

bootstrap: function(module, script) {
  return 'module.exports[module] = ' + script + ';';


String of the angular.module to register templates with.

If not specified, it will automatically be the name of the ngTranslateCache subtask (e.g. app, based on the examples below).


String to prefix template URLs with. Defaults to ''

If you need to use absolute urls:

ngTranslateCache: {
  app: {
    options: {
      prefix: '/'

If you serve static assets from another directory, you specify that as well.


Boolean indicated if the templates are part of an existing module or a standalone. Defaults to false.

  • If the value is false, the module will look like angular.module('app'), meaning app module is retrieved.
  • If the value is true, the module will look like angular.module('app', []), meaning app module is created.


Path to <!-- build:js [path/to/output.js] --> usemin target

This should be the output path of the compiled JS indicated in your HTML, such as path/to/output.js shown here.


ngTranslateCache: {
    options: {
        module: "app",
        usemin: "scripts/scripts.js"
    app: {
        cwd: "app",
        src: "languages/**/*.json",
        dest: "build/translateCache.js"


Feel free to contribute to this repository by making pull requests to http://github.com/p3ol/grunt-angular-translate-cache and create any related issue on the same github repository.


Copyright (c) 2017 Ugo Stephant. Licensed under MIT license.

Current Tags

  • 0.1.1                                ...           latest (3 years ago)

2 Versions

  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (9)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |