Socket
Socket
Sign inDemoInstall

i18next-conv

Package Overview
Dependencies
76
Maintainers
4
Versions
68
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 12.1.1 to 13.0.0

index.js

96

bin/index.js
#!/usr/bin/env node
import path from 'path';
import path from 'node:path';
import { createRequire } from 'node:module';
import { existsSync } from 'node:fs';
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import { program } from 'commander';
import {
mkdirSync, existsSync, readFileSync, promises as fsp,
} from 'fs'; // node 12 does not support fs/promises
import { createRequire } from 'module';
import {
red, green, blue, yellow,

@@ -18,26 +18,8 @@ } from 'colorette';

i18nextToMo,
} from 'i18next-conv'; // eslint-disable-line import/no-unresolved,n/no-extraneous-import
// https://github.com/import-js/eslint-plugin-import/issues/1649
// eslint-disable-next-line import/no-unresolved,node/no-missing-import
} from 'i18next-conv';
const { writeFile, readFile } = fsp;
const require = createRequire(import.meta.url);
const { version } = require('../package.json');
// test calls:
// gettext -> i18next
// node bin -l en -s ./test/_testfiles/en/translation.utf8.po -t ./test/_tmp/en.json
// node bin -l de -s ./test/_testfiles/de/translation.utf8.po -t ./test/_tmp/de.json
// node bin -l ru -s ./test/_testfiles/ru/translation.utf8.po -t ./test/_tmp/ru.json
// With filter:
// node bin -l en -s ./test/_testfiles/en/translation.utf8.po -t ./test/_tmp/en.json -f path/to/filter.js
// i18next -> gettext
// node bin -l de -s ./test/_testfiles/de/translation.utf8.json -t ./test/_tmp/de.po
// and back
// node bin -l de -s ./test/_tmp/de.po -t ./test/_tmp/de.json
// program

@@ -70,3 +52,3 @@ program

filter,
base: baseArg,
base,
...options

@@ -76,39 +58,34 @@ } = program.opts();

if (filter && existsSync(filter)) {
options.filter = require(path.resolve(filter)); // eslint-disable-line global-require,import/no-dynamic-require
options.filter = require(path.resolve(filter)); // eslint-disable-line import/no-dynamic-require
}
if (baseArg && existsSync(baseArg)) {
options.base = readFileSync(baseArg);
if (base && existsSync(base)) {
options.base = await readFile(base);
}
const {
language,
pot,
base,
} = options;
if (source && language) {
if (pot && !base) {
if (source && options.language) {
if (options.pot && !options.base) {
console.log(red('at least call with argument -p and -b.'));
console.log('(call program with argument -h for help.)');
process.exit(1); // eslint-disable-line no-process-exit
}
process.exitCode = 1;
} else {
const { quiet, plurals, language } = options;
if (!quiet) console.log(yellow('start converting'));
if (!options.quiet) console.log(yellow('start converting'));
if (plurals) {
const pluralsPath = path.join(process.cwd(), plurals);
options.plurals = require(pluralsPath); // eslint-disable-line import/no-dynamic-require
if (options.plurals) {
const pluralsPath = path.join(process.cwd(), options.plurals);
options.plurals = require(pluralsPath); // eslint-disable-line global-require,import/no-dynamic-require
if (!quiet) console.log(blue(`use custom plural forms ${pluralsPath}`));
}
if (!options.quiet) console.log(blue(`use custom plural forms ${pluralsPath}`));
processFile(language, source, target, options)
.then(() => {
if (!quiet) console.log(green('file written'));
})
.catch((/* err */) => {
console.log(red('failed writing file'));
process.exitCode = 1;
});
}
processFile(language, source, target, options)
.then(() => {
if (!options.quiet) console.log(green('file written'));
})
.catch((/* err */) => {
console.log(red('failed writing file'));
process.exitCode = 1;
});
} else {

@@ -161,7 +138,4 @@ console.log(red('at least call with argument -l and -s.'));

if (!existsSync(targetDir)) {
mkdirSync(targetDir, { recursive: true });
}
return converter(locale, body, options);
return mkdir(targetDir, { recursive: true })
.then(() => converter(locale, body, options));
})

@@ -173,10 +147,10 @@ .then((data) => {

})
.catch((err) => {
if (err.code === 'ENOENT') {
.catch((e) => {
if (e.code === 'ENOENT') {
console.log(red(`file ${source} was not found.`));
} else {
console.log(red(err.message));
console.log(red(e.message));
}
throw err;
throw e;
});
}

@@ -9,13 +9,9 @@ {

],
"version": "12.1.1",
"version": "13.0.0",
"type": "module",
"engines": {
"node": ">= 12.2"
"node": ">= 14.0"
},
"main": "dist/index.cjs",
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},
".": "./index.js",
"./package.json": "./package.json"

@@ -28,3 +24,4 @@ },

"bin",
"dist"
"lib",
"index.js"
],

@@ -37,15 +34,14 @@ "repository": {

"scripts": {
"build": "rollup -c",
"lint": "eslint --cache .",
"test": "mocha",
"cover": "c8 npm test",
"prepare": "npm run build"
"cover": "c8 npm test"
},
"dependencies": {
"c8": "^7.11.0",
"colorette": "^2.0.16",
"commander": "^9.1.0",
"c8": "^7.11.3",
"colorette": "^2.0.17",
"commander": "^9.3.0",
"gettext-converter": "^1.2.2",
"gettext-parser": "^5.1.2",
"node-gettext": "^3.0.0"
"node-gettext": "^3.0.0",
"p-from-callback": "^1.0.0"
},

@@ -55,10 +51,11 @@ "devDependencies": {

"chai-as-promised": "^7.1.1",
"eslint": "^8.13.0",
"eslint": "^8.16.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-mocha": "^10.0.4",
"eslint-plugin-node": "^11.1.0",
"mocha": "^9.2.2",
"rollup": "^2.70.1"
"eslint-plugin-mocha": "^10.0.5",
"eslint-plugin-n": "^15.2.1",
"eslint-plugin-unicorn": "^42.0.0",
"mocha": "^10.0.0"
}
}

@@ -6,4 +6,2 @@ # i18next-gettext-converter

[![Coverage Status][coveralls-badge]][coveralls]
[![Dependency Status][dependency-status-badge]][dependency-status]
[![devDependency Status][dev-dependency-status-badge]][dev-dependency-status]

@@ -179,7 +177,1 @@ ## Introduction

[coveralls]: https://coveralls.io/r/i18next/i18next-gettext-converter
[dependency-status-badge]: https://david-dm.org/i18next/i18next-gettext-converter.svg?style=flat-square
[dependency-status]: https://david-dm.org/i18next/i18next-gettext-converter
[dev-dependency-status-badge]: https://david-dm.org/i18next/i18next-gettext-converter/dev-status.svg?style=flat-square
[dev-dependency-status]: https://david-dm.org/i18next/i18next-gettext-converter#info=devDependencies
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc