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-browser-i18n-localize

v1.0.1

Published

> A gulp plugin that hardcodes localized messages into files that utilize browser internationalization APIs (`browser.i18n.*` / `chrome.i18n.*`).

Downloads

1

Readme

gulp-browser-i18n-localize NPM version Build status

A gulp plugin that hardcodes localized messages into files that utilize browser internationalization APIs (browser.i18n.* / chrome.i18n.*).

Why?

This gulp plugin was originally written to help convert browser web extensions into legacy userscripts. Proper web extensions support translations, which is easy enough to do with the browser APIs, but those APIs are not available to userscripts. Using this plugin, a web extension with translations can be built into a userscript (or a series of userscripts, for all supported locales) where the API functionality is replaced with the hard-coded translations for each locale.

Usage

First, install gulp-browser-i18n-localize as a development dependency:

npm install --save-dev gulp-browser-i18n-localize

Then, add it to your gulpfile.js:

Basic Configuration

var localize = require('gulp-browser-i18n-localize');

gulp.task('templates', function(){
  gulp.src(['file.js'])
    .pipe(localize())
    .pipe(gulp.dest('dist/'));
});

Options

localesDir

Type: string

Default: _locales

Description: Specifies the path to the root directory for the locales (this path should end in _locales), since that is the convention specified for Web Extensions (see Providing localized strings in _locales on MDN).

locales

Type: array

Default: []

Description: Specifies the locales to use. When empty, all available locales (from the _locales directory) are used.

schema

Type: string

Default: $filename.$locale.$ext

Description: Specifies the naming schema used for the localized files in the stream/buffer. The default schema inserts the locale name used just before the extension (i.e. myfile.en-US.js). To disable renaming, set schema to false. Note that you should NOT disable renaming if you are using multiple locales, as you will not be able to write out all of the files at the end of your task (since they will all have the same name).

NOTE: Empty files are not renamed in the stream/buffer.

| Placeholder | Description | Example Value | | ------------- | ------------- | ------------- | | $filename | This is the original file name, minus path and extension | myfile | | $locale | This is the locale used during processing | en-US | | $ext | This is the original file's extension (minus leading period) | js |

You could use /$locale/$filename.$ext to place all translated files into sub-directories corresponding to their locale.

direction

Type: string

Default: ltr

Description: Specifies the BIDI direction string to be inserted wherever BIDI methods/messages are used.

regexMessages

Type: RegExp

Default: /__MSG_([\S]+)__/gi

Description: Specifies the regular expression used to find __MSG_ + messageName + __ strings. This regular expression should include one capture group that will contain the actual message name.

regexMethods

Type: RegExp

Default: /(?:browser|chrome)\.i18n\.([a-zA-Z]+)\(([^\)]+)?\)/gi

Description: Specifies the regular expression used to find browser.i18n.* and chrome.i18n.* methods. This regular expression should include two capture groups: one for the method name, and one for the (optional) arguments supplied to the method.