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

vue3-gettext

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue3-gettext - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0-alpha.1

17

dist/bin/gettext_compile.js

@@ -92,3 +92,3 @@ #!/usr/bin/env node

var loadConfig = function (cliArgs) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
var moduleName = "gettext";

@@ -120,12 +120,13 @@ var explorer = cosmiconfig.cosmiconfigSync(moduleName);

exclude: ((_d = config.input) === null || _d === void 0 ? void 0 : _d.exclude) || [],
jsExtractorOpts: (_e = config.input) === null || _e === void 0 ? void 0 : _e.jsExtractorOpts,
},
output: {
path: languagePath,
potPath: joinPathIfRelative((_e = config.output) === null || _e === void 0 ? void 0 : _e.potPath) || joinPath("./messages.pot"),
jsonPath: joinPathIfRelative((_f = config.output) === null || _f === void 0 ? void 0 : _f.jsonPath) ||
(((_g = config.output) === null || _g === void 0 ? void 0 : _g.splitJson) ? joinPath("./") : joinPath("./translations.json")),
locales: ((_h = config.output) === null || _h === void 0 ? void 0 : _h.locales) || ["en"],
flat: ((_j = config.output) === null || _j === void 0 ? void 0 : _j.flat) === undefined ? false : config.output.flat,
linguas: ((_k = config.output) === null || _k === void 0 ? void 0 : _k.linguas) === undefined ? true : config.output.linguas,
splitJson: ((_l = config.output) === null || _l === void 0 ? void 0 : _l.splitJson) === undefined ? false : config.output.splitJson,
potPath: joinPathIfRelative((_f = config.output) === null || _f === void 0 ? void 0 : _f.potPath) || joinPath("./messages.pot"),
jsonPath: joinPathIfRelative((_g = config.output) === null || _g === void 0 ? void 0 : _g.jsonPath) ||
(((_h = config.output) === null || _h === void 0 ? void 0 : _h.splitJson) ? joinPath("./") : joinPath("./translations.json")),
locales: ((_j = config.output) === null || _j === void 0 ? void 0 : _j.locales) || ["en"],
flat: ((_k = config.output) === null || _k === void 0 ? void 0 : _k.flat) === undefined ? false : config.output.flat,
linguas: ((_l = config.output) === null || _l === void 0 ? void 0 : _l.linguas) === undefined ? true : config.output.linguas,
splitJson: ((_m = config.output) === null || _m === void 0 ? void 0 : _m.splitJson) === undefined ? false : config.output.splitJson,
},

@@ -132,0 +133,0 @@ };

@@ -18,2 +18,3 @@ #!/usr/bin/env node

var treeAdapter = require('parse5-htmlparser2-tree-adapter');
var typescript = require('typescript');
var child_process = require('child_process');

@@ -31,3 +32,3 @@

var loadConfig = function (cliArgs) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
var moduleName = "gettext";

@@ -59,12 +60,13 @@ var explorer = cosmiconfig.cosmiconfigSync(moduleName);

exclude: ((_d = config.input) === null || _d === void 0 ? void 0 : _d.exclude) || [],
jsExtractorOpts: (_e = config.input) === null || _e === void 0 ? void 0 : _e.jsExtractorOpts,
},
output: {
path: languagePath,
potPath: joinPathIfRelative((_e = config.output) === null || _e === void 0 ? void 0 : _e.potPath) || joinPath("./messages.pot"),
jsonPath: joinPathIfRelative((_f = config.output) === null || _f === void 0 ? void 0 : _f.jsonPath) ||
(((_g = config.output) === null || _g === void 0 ? void 0 : _g.splitJson) ? joinPath("./") : joinPath("./translations.json")),
locales: ((_h = config.output) === null || _h === void 0 ? void 0 : _h.locales) || ["en"],
flat: ((_j = config.output) === null || _j === void 0 ? void 0 : _j.flat) === undefined ? false : config.output.flat,
linguas: ((_k = config.output) === null || _k === void 0 ? void 0 : _k.linguas) === undefined ? true : config.output.linguas,
splitJson: ((_l = config.output) === null || _l === void 0 ? void 0 : _l.splitJson) === undefined ? false : config.output.splitJson,
potPath: joinPathIfRelative((_f = config.output) === null || _f === void 0 ? void 0 : _f.potPath) || joinPath("./messages.pot"),
jsonPath: joinPathIfRelative((_g = config.output) === null || _g === void 0 ? void 0 : _g.jsonPath) ||
(((_h = config.output) === null || _h === void 0 ? void 0 : _h.splitJson) ? joinPath("./") : joinPath("./translations.json")),
locales: ((_j = config.output) === null || _j === void 0 ? void 0 : _j.locales) || ["en"],
flat: ((_k = config.output) === null || _k === void 0 ? void 0 : _k.flat) === undefined ? false : config.output.flat,
linguas: ((_l = config.output) === null || _l === void 0 ? void 0 : _l.linguas) === undefined ? true : config.output.linguas,
splitJson: ((_m = config.output) === null || _m === void 0 ? void 0 : _m.splitJson) === undefined ? false : config.output.splitJson,
},

@@ -121,3 +123,3 @@ };

jsParser.parseString(source, fileName, {
scriptKind: 1,
scriptKind: typescript.ScriptKind.Deferred,
lineNumberStart: (element.sourceCodeLocation && element.sourceCodeLocation.startLine) || 0,

@@ -129,9 +131,16 @@ });

var extractFromFiles = function (filePaths, potPath) { return tslib.__awaiter(void 0, void 0, void 0, function () {
var extr, jsParser, htmlParser;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
var extractFromFiles = function (filePaths, potPath, config) { return tslib.__awaiter(void 0, void 0, void 0, function () {
var extr, emptyExtractors, extractors, jsParser, htmlParser;
var _a, _b;
return tslib.__generator(this, function (_c) {
switch (_c.label) {
case 0:
extr = new gettextExtractor.GettextExtractor();
jsParser = extr.createJsParser([
emptyExtractors = new Array();
extractors = ((_b = (_a = config === null || config === void 0 ? void 0 : config.input) === null || _a === void 0 ? void 0 : _a.jsExtractorOpts) === null || _b === void 0 ? void 0 : _b.reduce(function (acc, item, index, array) {
console.log("custom keyword: ".concat(chalk__default["default"].blueBright(item.keyword)));
acc.push(gettextExtractor.JsExtractors.callExpression([item.keyword, "[this].".concat(item.keyword)], item.options));
return acc;
}, emptyExtractors)) || emptyExtractors;
jsParser = extr.createJsParser(tslib.__spreadArray([
gettextExtractor.JsExtractors.callExpression(["$gettext", "[this].$gettext"], {

@@ -172,4 +181,4 @@ content: {

},
}),
]);
})
], extractors, true));
htmlParser = extr.createHtmlParser([

@@ -241,3 +250,3 @@ gettextExtractor.HtmlExtractors.elementContent("translate, [v-translate]", {

case 1:
_a.sent();
_c.sent();
extr.savePotFile(potPath);

@@ -253,3 +262,3 @@ console.info("".concat(chalk__default["default"].green("Extraction successful"), ", ").concat(chalk__default["default"].blueBright(potPath), " created."));

return new Promise(function (resolve) {
child_process.exec(cmd, function (error, stdout, stderr) {
child_process.exec(cmd, { env: process.env }, function (error, stdout, stderr) {
if (error) {

@@ -331,3 +340,3 @@ console.warn(error);

console.info();
return [4 /*yield*/, extractFromFiles(files, config.output.potPath)];
return [4 /*yield*/, extractFromFiles(files, config.output.potPath, config)];
case 2:

@@ -350,4 +359,15 @@ _b.sent();

return [3 /*break*/, 8];
case 5: return [4 /*yield*/, execShellCommand("msginit --no-translator --locale=".concat(loc, " --input=").concat(config.output.potPath, " --output-file=").concat(poFile))];
case 5:
// https://www.gnu.org/software/gettext/manual/html_node/msginit-Invocation.html
// msginit will set Plural-Forms header if the locale is in the
// [embedded table](https://github.com/dd32/gettext/blob/master/gettext-tools/src/plural-table.c#L27)
// otherwise it will read [$GETTEXTCLDRDIR/common/supplemental/plurals.xml](https://raw.githubusercontent.com/unicode-org/cldr/main/common/supplemental/plurals.xml)
// so execShellCommand should pass the env(GETTEXTCLDRDIR) to child process
return [4 /*yield*/, execShellCommand("msginit --no-translator --locale=".concat(loc, " --input=").concat(config.output.potPath, " --output-file=").concat(poFile))];
case 6:
// https://www.gnu.org/software/gettext/manual/html_node/msginit-Invocation.html
// msginit will set Plural-Forms header if the locale is in the
// [embedded table](https://github.com/dd32/gettext/blob/master/gettext-tools/src/plural-table.c#L27)
// otherwise it will read [$GETTEXTCLDRDIR/common/supplemental/plurals.xml](https://raw.githubusercontent.com/unicode-org/cldr/main/common/supplemental/plurals.xml)
// so execShellCommand should pass the env(GETTEXTCLDRDIR) to child process
_b.sent();

@@ -354,0 +374,0 @@ fs__default["default"].chmodSync(poFile, 438);

@@ -576,2 +576,10 @@ 'use strict';

setGlobalProperties: true,
globalProperties: {
language: ['$language'],
gettext: ['$gettext'],
pgettext: ['$pgettext'],
ngettext: ['$ngettext'],
npgettext: ['$npgettext'],
interpolate: ['$gettextInterpolate'],
},
provideDirective: true,

@@ -607,9 +615,27 @@ provideComponent: true,

if (mergedOptions.setGlobalProperties) {
var globalProperties = app.config.globalProperties;
globalProperties.$gettext = gettext.$gettext;
globalProperties.$pgettext = gettext.$pgettext;
globalProperties.$ngettext = gettext.$ngettext;
globalProperties.$npgettext = gettext.$npgettext;
globalProperties.$gettextInterpolate = gettext.interpolate;
globalProperties.$language = gettext;
var globalProperties_1 = app.config.globalProperties;
var properties = mergedOptions.globalProperties.gettext || ['$gettext'];
properties.forEach(function (p) {
globalProperties_1[p] = gettext.$gettext;
});
properties = mergedOptions.globalProperties.pgettext || ['$pgettext'];
properties.forEach(function (p) {
globalProperties_1[p] = gettext.$pgettext;
});
properties = mergedOptions.globalProperties.ngettext || ['$ngettext'];
properties.forEach(function (p) {
globalProperties_1[p] = gettext.$ngettext;
});
properties = mergedOptions.globalProperties.npgettext || ['$npgettext'];
properties.forEach(function (p) {
globalProperties_1[p] = gettext.$npgettext;
});
properties = mergedOptions.globalProperties.interpolate || ['$gettextInterpolate'];
properties.forEach(function (p) {
globalProperties_1[p] = gettext.interpolate;
});
properties = mergedOptions.globalProperties.language || ['$language'];
properties.forEach(function (p) {
globalProperties_1[p] = gettext;
});
}

@@ -616,0 +642,0 @@ if (mergedOptions.provideDirective) {

import * as vue from 'vue';
import { ObjectDirective, UnwrapRef, WritableComputedRef, App } from 'vue';
import { IJsExtractorOptions } from 'gettext-extractor/dist/js/extractors/common';

@@ -108,2 +109,10 @@ /**

setGlobalProperties: boolean;
globalProperties: {
language?: Array<string>;
gettext?: Array<string>;
pgettext?: Array<string>;
ngettext?: Array<string>;
npgettext?: Array<string>;
interpolate?: Array<string>;
};
provideDirective: boolean;

@@ -143,2 +152,7 @@ provideComponent: boolean;

exclude: string[];
/** js extractor options, for custom extractor keywords */
jsExtractorOpts?: {
keyword: string;
options: IJsExtractorOptions;
}[];
};

@@ -145,0 +159,0 @@ output: {

{
"name": "vue3-gettext",
"version": "2.4.0",
"version": "2.5.0-alpha.1",
"description": "Translate Vue 3 applications with gettext",

@@ -5,0 +5,0 @@ "homepage": "https://jshmrtn.github.io/vue3-gettext/",

@@ -1,6 +0,6 @@

<p align="center">
<h1 align="center">
<a href="https://www.npmjs.com/package/vue3-gettext" target="_blank">
<h1>Vue 3 Gettext πŸ’¬</h1>
Vue 3 Gettext πŸ’¬
</a>
</p>
</h1>
<br/>

@@ -12,3 +12,3 @@

<p align="center">
<a href="https://jshmrtn.github.io/vue3-gettext/">Getting started</a> | <a href="https://jshmrtn.github.io/vue3-gettext/demo.html">Demo</a> | <a href="https://jshmrtn.github.io/vue3-gettext/setup.html">Documentation</a>
<a href="https://jshmrtn.github.io/vue3-gettext/">Getting started</a> | <a href="https://jshmrtn.github.io/vue3-gettext/demo.html">Demo</a> | <a href="https://jshmrtn.github.io/vue3-gettext/setup.html">Documentation</a> | <a href="README_zh.md">δΈ­ζ–‡</a>
</p>

@@ -15,0 +15,0 @@ <br>

Sorry, the diff of this file is not supported yet

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