Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-i18n-pug

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-i18n-pug

Gulp plugin to compile Pug templates with internationalization support based on JS/JSON/YAML files

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

gulp-i18n-pug

Build Status

Package Quality

Gulp plugin to compile Pug templates with internationalization support based on JS/JSON/YAML files

Inspired by grunt-pug-i18n.

It adds high level support for Pug template internationalization based on JSON/YAML/JS files.

Usage

Example JSON locale file (es_ES.json)
{
  "hello": {
    "world": "Hola Mundo"
  }
}
Example Pug template
body
  h1 #{$i18n.hello.world}!
  p Using locale #{$localeName}
gulp.task('pugI18n', function () {
  var options = {
    i18n: {
      dest: 'dist',
      locales: 'test/locales/*.*'
    },
    pretty: true
  };
  return gulp.src('myPugTemplates/directory/*.pug')
    .pipe(pugI18n(options))
    .pipe(gulp.dest(options.i18n.dest));
});
gulp.task('pugI18n', function () {
  var options = {
    i18n: {
      locales: 'test/locales/*',
      namespace: '$t',
      localeExtension: true
    },
    client: false,
    pretty: true
  };
  return gulp.src('myPugTemplates/directory/*.pug')
    .pipe(pugI18n(options))
    .pipe(gulp.dest(options.i18n.dest));
});
gulp.task('pugI18n', function () {
  var options = {
    i18n: {
      dest: '.tmp'
    },
    data: {
      $i18n: {
        message: 'Hello world!',
        nested: {
          msg: 'and hello to you'
        }
      }
    },
    pretty: true
  };
  return gulp.src('myPugTemplates/directory/*.pug')
    .pipe(pugI18n(options))
    .pipe(gulp.dest(options.i18n.dest));
});

Options

Only i18n specific options are listed below

locales

Type: string|array

Path to localization files. Please check the examples in tests. Glob patterns can be used

JSON, YAML and JS formats are supported for the translation templates

namespace

Type: string Default: $i18n

Namespace to expose translation keys in Pug template

localeExtension

Type: boolean Default: false

Generate the HTML output files with the extension prefix with the current language. By default it will create different folders for each language

Setting this option into true, the generated HTML files will look like this:

html/
├── view.en-en.html
└── view.es-es.html

... instead of:

html/
├── en-EN/
│   └── view.html
└── es-ES/
    └── view.html

Release History

Read the full changelog.

License

MIT © Felix Zapata

Keywords

FAQs

Package last updated on 29 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc