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

gulp-gridfw

v1.0.4

Published

Gridfw plugin for Gulp

Downloads

2

Readme

gulp-gridfw

Gridfw plugin for gulp

Compile i18n files

Features

  • Translate literals
  • Pluralize literals
  • Switch value depending on some value
  • Text combining
  • Compatible with Gridfw and Grid-Reactor

USE

// If the message doesn't contain arguments, just call it as follow
i18n.myMessage

// If the message contains arguments, call it as a function like this:
i18n.messageWithArguments({param1:'value', param2:'value', ...})


// SERVER SIDE:
// For performance issues, we recommand to keep "i18n" as named.
app.get('/route', function(ctx){
	console.log('My message: ', ctx.i18n.myMessage);
	console.log('Message with arguments: ', ctx.i18n['i bought %books']({books: ['book1', 'book2']}) );
});

// INSIDE VIEWS:
// Just use: i18n.yourMessageKey
// or: i18n.yourMessageKeyWithArgs(args)


// BROWSER SIDE: (you can change "i18n" by any other variable in the browser side)
// call: i18n.yourMessage
// or: i18n.yourMessageKeyWithArgs(args)


// Get a specific local
app.get('/route', async function(ctx){
	enI18n= await app.getLocale('en');
	console.log('My message in user language: ', ctx.i18n.myMessage);
	console.log('My message in EN: ', enI18n.myMessage);
});

Format

Each i18n file has the following format:

###*
 * Map a key to a value for all locales
 */
key: 'value'

###*
 * Map a value for each locale
 */
key2:
	locale_1: 'value in locale_1'
	locale_2: 'value in locale_2'
	locale_n: 'value in locale_n'

###*
 * Parametred value
 * You can use any valid Pug format to add variables or any javascript expression
 * use: #{varname} to insert varname after escaping it's value
 * use: !{varname} to insert varname without escaping it
 * use: #[b kkk] to add: <b>kkk</b>
 * use: #[b #{varname}] to add: <b>content</b>
 *
 * <!> warn: use simple quoted string only, using double quoted will result an error.
 */
key3:
	locale_1: 'lorem #{param1} !{enescaped_param2}'
key4:
	locale_1: 'my name is #[b #{fullName}]'

###*
 * Insert an other messages from i18n
 */
key5:
	locale_1: 'This is my message: #{i18n.mySecondMessage}'
key6:
	locale_1: 'This is my message: #{i18n.mySecondMessage2({name: name, age:31})}'

###*
 * Do more controle using functions
 */
key5:
	# Using coffeescript style
	locale_1: (data)-> 'generated message'

	# Using javascript style
	locale_2: ```function(data){
		return 'generated message'
	}```

Examples


appName: 'My App' # used for all locales

'hello everybody':
	en: 'Hello everybody'
	fr: 'Bonjour tout le monde'

'hello %fullName':
	en: 'Hello #{fullName}'
	fr: 'Bonjour #{fullName}'

'i bought %books':
	en: (data)->
		switch data.books.length
			when 0 then 'I bought no book'
			when 1 then 'I bought a book'
			when 2 then 'I bought two books'
			else "I bought #{data.books.length} books"

Reserved attributes

i18n.locale: Contain current locale i18n.locales: map local and it's name