npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@poool/grunt-angular-translate-cache

v0.1.1

Published

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

Downloads

1

Readme

grunt-angular-translate-cache

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 !

Installation

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 :

grunt.loadNpmTasks("@poool/grunt-angular-translate-cache");

Options

angular

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.

bootstrap

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 + ';';
}

module

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).

prefix

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.

standalone

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.

usemin

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.

Example

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

Contributing

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.

License

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