Git Product home page Git Product logo

nodejs-i18n's Introduction

NodeJS i18n

Travis Downloads Node Version

Minimalistic internationalization using gettext style for NodeJS

Features

  • Gettext Style
  • Easy Imprementation
  • Create .po via CLI
  • Select Lang per User

Installation

Module available through the npm registry. It can be installed using the npm or yarn command line tool.

# Yarn (Recomend)
yarn global add nodejs-i18n
# NPM 
npm install nodejs-i18n --global

Usage

# Create file
find . | grep .js | sort | nodejs-i18n > en.po

# Create file (all strings) [beta]
find . | grep .js | sort | nodejs-i18n --all > en.po

# Create file (get identifier value) [beta]
find . | grep .js | sort | nodejs-i18n --value > en.po

Example

const { Resources, Translation } = require('nodejs-i18n')

const resources = new Resources()
resources.load('pt', 'pt.po')

const user = new Translation('pt')

//i18n: My Hello World with NodeJs i18n
const world = user._`world` // Mundo
user._`Hello ${world}` // Olá mundo

Documentation

Options

Options :: Resources({})

  • lang - String

Lang id.
Default value: en

Options :: Resources({}).load(lang, file)

Load translation

  • lang - String

Lang id.

  • file - String

File path

Options :: Resources({}).remove()

Remove translation.

  • lang - String

Lang id.

Options :: Translation(lang)

Select translation.

  • lang - String

Lang id.

Options :: Translation(lang)._(string)

String translation.

  • String - String

CLI

Create en.po files with nodejs-i18n. Add in your package.json

"scripts": {
	"i18n": "find . | grep .js | sort | nodejs-i18n > en.po"
}

and run $ npm run i18n or $ yarn i18n

Tests

To run the test suite, first install the dependencies, then run test:

# Using Yarn
yarn test

Dependencies

argv: CLI Argument Parser Author: Corey Hart
License:
Version: 0.0.2
esprima: ECMAScript parsing infrastructure for multipurpose analysis Author: Ariya Hidayat
License: BSD-2-Clause
Version: ^4.0.1
gettext-parser: Parse and compile gettext po and mo files to/from json, nothing more, nothing less Author: Andris Reinman
License: MIT
Version: ^4.0.3
minimist: parse argument options Author: James Halliday
License: MIT
Version: ^1.2.5
tempy: Get a random temporary file or directory path Author: Sindre Sorhus
License: MIT
Version: 0.5.0

Dev Dependency

mocha: simple, flexible, fun test framework Author: TJ Holowaychuk
License: MIT
Version: 7.2.0

Related

gettext-parser: Parse and compile gettext po and mo files to/from json, nothing more, nothing less Author: Andris Reinman
License: MIT

Contributors

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. List of all contributors.

License

MIT © TiagoDanin

nodejs-i18n's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

nodejs-i18n's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency node to v13.14.0

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • argv 0.0.2
  • esprima ^4.0.1
  • gettext-parser ^4.0.4
  • minimist ^1.2.5
  • tempy 1.0.1
  • mocha 8.4.0
  • node >=v14.16.1
travis
.travis.yml
  • node 14
  • node 13
  • node 12
  • node 10

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.