Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
A workflow utility to ease localization in JS(X) apps by automizing the following steps:
narp push
narp pull
The JSON translations are formatted for node-gettext.
To use it easily, install narp globally with:
npm install -g narp
To use it in an automatization pipeline in your project, install it as a dev dependency:
npm install --save-dev narp
# get help
narp -h
# extract + merge pots + upload pot
narp push [<credentials>]
# download po's + convert to json + write to file
narp pull [<credentials>]
# extract messages to stdout (no password required)
narp extract [./path/to/comps]
Optionally put a path as arg 2 to just extract from the folder. Protip, pipe to file if you want to use it.
import { push, pull } from 'narp';
const configs = {
/* all the configs */
};
push(configs).then(/* ... */).catch(/* ... */);
pull(configs).then(/* ... */).catch(/* ... */);
This is the shape of narp's configuration. It can be provided as an object to the pull()
and push()
functions, or defined as a JSON object in .narprc
.
{
// The vendor object differs depending on the vendor
"vendor": {
// The name of the translation service you use.
// Must be "transifex" or "poeditor"
"name": "pick one"
// Credentials used to make authorized HTTP requests.
// See the section below on how to provide passwords
// and tokens.
"credentials": {
// Transifex needs a username and password
"username": "my-tfx-username",
"password": "do not store this in a file",
// POEditor needs a token
"token": "do not store this in a file"
},
// The vendor.options object contain project specific
// options, some of which differ depending on the vendor
"options": {
// Project ID.
"project": "project-id",
// The source language code. This corresponds to whatever
// the vendor is naming it as.
"sourceLanguage": "en",
// Transifex only: The slug of the resource
"resource": null,
}
},
// Configs that are passed to react-gettext-parser
"extract": {
// A glob string (npmjs.com/glob) that matches all source files
// that may contain translatable strings.
"source": null,
// These two are passed directly to react-gettext-parser,
// see the react-gettext-parser readme
"componentPropsMap": { /* react-gettext-parser defaults */ },
"funcArgumentsMap": { /* react-gettext-parser defaults */ }
},
// Where to put all the translations
"output": "messages.json",
// If true, will output debug information to the console
"verbose": false
}
You will have to provide different credentials depending on the translation service you use. Transifex requires a username and password, whilst POEditor requires an API token.
First, provide the Transifex username via the vendor.credentials.username
config (see the config shape section). Then, there are three ways you can provide a password:
a. Via the ---password
argument
b. Via the NARP_VENDOR_PASSWORD
environment variable
c. Via the vendor.credentials.password
config passed to the API functions
Never store passwords in your code!
There are three ways of providing an API token:
a. Via the --token
argument
b. Via the NARP_VENDOR_TOKEN
environment variable
c. Via the vendor.credentials.token
config passed to the API functions
Never store secret tokens in your code!
.narprc
is narp's configuration file. Any configurations you put there will be parsed and applied whenever you use narp.
v3 introduced vendors, which replaces the hard-coded Transifex support with a modularised vendor support, adding POEditor into the mix. To transition your Transifex configuration, you change .narprc
from
{
"transifex": {
"username": "yourusername",
"project": "yourproject",
"resource": "yourresource",
"sourceLang": "xx"
},
// More configs...
}
to
{
"vendor": {
"name": "transifex",
"credentials": {
"username": "yourusername"
},
"options": {
"project": "yourproject",
"resource": "yourresource",
"sourceLanguage": "xx" // Note that this key is different
}
},
// More configs...
}
# Create a build from source
npm run build
# Build continuously as you save files
npm run build -- --watch
cd path/to/narp && npm link
Follow semver when bumping the version number, commit it and run
npm publish
FAQs
The worlds best super translation manager package handler
The npm package narp receives a total of 29 weekly downloads. As such, narp popularity was classified as not popular.
We found that narp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.