New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gengojs

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gengojs

the best i18n middleware for Node.js

  • 1.0.0-alpha.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20
decreased by-9.09%
Maintainers
1
Weekly downloads
 
Created
Source

gengo.js

Build Status Dependency Status License Status Downloads Version

News

Hey! Sorry for any delays! gengo.js has been through some transitions and hopefully it lead it to a better library but here's what happened:

  • gengo.js has moved into a dedicated GitHub account
  • All official plugins have been updated and can be found at the dedicated account.
  • All plugins and the core have been documented.

In the coming weeks I will be working on a revamped version of the website/documentation with the updated gengo.js. In the meantime, please don't hesitate to create issues and/or contribute to this awesome open source project. And to let everyone know, I am looking for maintainers. This project isn't very big and shouldn't be difficult to understand on how it works, so if you are interested, feel free to DM me through Gitter or Twitter (@iwatakeshi). :)

It's here! It's finally here! Welcome to version 1.0.0-alpha. As the version implies, this version of gengo is not production ready. It's published so that I can get some feedback and of course test it myself. In fact, I already have a couple of thoughts about bringing the core and the plugins into the same repo because individually maintaining them myself is a difficult task. In the meantime, feel free to try it out and report any bugs or suggestions. As far as docs are concerned, it may take a while for me to write as I try to organize everything up and make gengo.js simple enough to extend and make it the best i18n module for Node.

Introduction

gengo.js is an i18n/l10n library that is powered by it's very small core. Along with the core, it is also managed by six plugins. The combinations of the these create a powerful and a unique library that enables developers to take over the core and extend its capabilities. The core is essentialy an empty shell that provides the basics such as a way of accessing a plugin's options or the plugin itself. As a starter, begin hacking the core and the plugins to find out how you can develop your own plugins and create the ultimate combination to create the best i18n library for Node.js.

Usage

// Modules used in example
var path = require('path');

// Options used in example
var options = {
  parser: {
    type: '*'
  },
  backend: {
    directory: path.join(__dirname, '/config/locales/')
  },
  header: {
    supported: ['en-US', 'ja']
  }
};

// Express
var gengo = require('gengojs');
var app = require('express')();
// Use gengo
app.use(gengo(options));

// Koa
var gengo = require('gengojs/koa');
var app = require('koa')();
// Use gengo
app.use(gengo(options));

// Hapi
var server = new require('hapi').Server();
var gengo = require('../../hapi/');
// Register gengo
server.register(gengo(options), function(error) {
  if (error) console.log('an error occurred: ' + error);
});

Options

These are the complete option for the official plugins. Loading options is quite simple in gengo.js.

{
  "api" : {
    "global": "__",
    "localize": "__l"
  },
  "backend": {
    "directory": "./locales",
    "extension": "json",
    "prefix": "",
    "cache": true
  },
  "header": {
    "detect": {
      "query": false,
      "subdomain": false,
      "url": false,
      "cookie": false,
      "header": true
    },
    "keys": {
      "cookie": "locale",
      "query": "locale"
    },
    "supported": ["en-US"],
    "default": "en-US"
  },
  "parser": {
    "type": "default",
    "markdown": {
     "enabled": false,
      "html": false,
      "xhtmlOut": false,
      "breaks": false,
      "langPrefix": "language-",
      "linkify": false,
      "typographer": false,
      "quotes": "“”‘’"
    },
    "template": {
      "enabled": true,
      "open": "{{",
      "close": "}}"
    },
    "sprintf": { "enabled": true },
    "keywords": {
      "default": "default",
      "translated": "translated",
      "global": "global"
    }
  },
  "router": { "enabled": true } 
}

There are three file extensions supported:

  • JSON
  • YAML
  • JS

Each plugin have their own defaults (if applicable) but to override them simply use one of the following ways:

  • Use a path to the options:
gengo('path to options');
  • Directly override the options:
gengo({
  "parser": {/* ... */}
});

Test

# make sure to install the node modules
npm install

# run test
gulp test

Keywords

FAQs

Package last updated on 08 Oct 2015

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