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

@vendure/ngx-translate-extract

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vendure/ngx-translate-extract - npm Package Compare versions

Comparing version 9.0.3 to 9.1.0

dist/cache/cache-interface.d.ts

8

dist/cli/cli.js

@@ -17,2 +17,3 @@ import yargs from 'yargs';

import { normalizePaths } from '../utils/fs-helpers.js';
import { FileCache } from '../cache/file-cache.js';
const y = yargs().option('patterns', {

@@ -78,2 +79,6 @@ alias: 'p',

})
.option('cache-file', {
describe: 'Cache parse results to speed up consecutive runs',
type: 'string'
})
.option('marker', {

@@ -132,2 +137,5 @@ alias: 'm',

extractTask.setParsers(parsers);
if (cli.cacheFile) {
extractTask.setCache(new FileCache(cli.cacheFile));
}
const postProcessors = [];

@@ -134,0 +142,0 @@ if (cli.clean) {

5

dist/cli/tasks/extract.task.d.ts

@@ -1,2 +0,2 @@

import { TranslationCollection } from '../../utils/translation.collection.js';
import { TranslationCollection, TranslationType } from '../../utils/translation.collection.js';
import { TaskInterface } from './task.interface.js';

@@ -6,2 +6,3 @@ import { ParserInterface } from '../../parsers/parser.interface.js';

import { CompilerInterface } from '../../compilers/compiler.interface.js';
import type { CacheInterface } from '../../cache/cache-interface.js';
export interface ExtractTaskOptionsInterface {

@@ -17,5 +18,7 @@ replace?: boolean;

protected compiler: CompilerInterface;
protected cache: CacheInterface<TranslationType[]>;
constructor(inputs: string[], outputs: string[], options?: ExtractTaskOptionsInterface);
execute(): void;
setParsers(parsers: ParserInterface[]): this;
setCache(cache: CacheInterface<TranslationType[]>): this;
setPostProcessors(postProcessors: PostProcessorInterface[]): this;

@@ -22,0 +25,0 @@ setCompiler(compiler: CompilerInterface): this;

36

dist/cli/tasks/extract.task.js

@@ -6,2 +6,3 @@ import { cyan, green, bold, dim, red } from 'colorette';

import { TranslationCollection } from '../../utils/translation.collection.js';
import { NullCache } from '../../cache/null-cache.js';
export class ExtractTask {

@@ -16,2 +17,3 @@ inputs;

compiler;
cache = new NullCache();
constructor(inputs, outputs, options) {

@@ -68,2 +70,3 @@ this.inputs = inputs;

});
this.cache.persist();
}

@@ -74,2 +77,6 @@ setParsers(parsers) {

}
setCache(cache) {
this.cache = cache;
return this;
}
setPostProcessors(postProcessors) {

@@ -84,16 +91,29 @@ this.postProcessors = postProcessors;

extract() {
let collection = new TranslationCollection();
const collectionTypes = [];
let skipped = 0;
this.inputs.forEach((pattern) => {
this.getFiles(pattern).forEach((filePath) => {
this.out(dim('- %s'), filePath);
const contents = fs.readFileSync(filePath, 'utf-8');
this.parsers.forEach((parser) => {
const extracted = parser.extract(contents, filePath);
if (extracted instanceof TranslationCollection) {
collection = collection.union(extracted);
}
skipped += 1;
const cachedCollectionValues = this.cache.get(`${pattern}:${filePath}:${contents}`, () => {
skipped -= 1;
this.out(dim('- %s'), filePath);
return this.parsers
.map((parser) => {
const extracted = parser.extract(contents, filePath);
return extracted instanceof TranslationCollection ? extracted.values : undefined;
})
.filter((result) => result && !!Object.keys(result).length);
});
collectionTypes.push(...cachedCollectionValues);
});
});
return collection;
if (skipped) {
this.out(dim('- %s unchanged files skipped via cache'), skipped);
}
const values = {};
for (const collectionType of collectionTypes) {
Object.assign(values, collectionType);
}
return new TranslationCollection(values);
}

@@ -100,0 +120,0 @@ process(draft, extracted, existing) {

{
"name": "@vendure/ngx-translate-extract",
"version": "9.0.3",
"version": "9.1.0",
"description": "Extract strings from projects using ngx-translate",

@@ -5,0 +5,0 @@ "author": "Kim Biesbjerg <kim@biesbjerg.com>",

@@ -72,2 +72,11 @@ # ngx-translate-extract

**Cache for consecutive runs**
If your project grows rather large, runs can take seconds. With this cache, unchanged files don't need
to be parsed again, keeping consecutive runs under .5 seconds.
```bash
ngx-translate-extract --cache-file node_modules/.i18n-cache/my-cache-file --input ./src --output ./src/i18n/{da,en}.json
```
### JSON indentation

@@ -121,2 +130,3 @@

patterns and multiple paths [array] [required]
--cache-file Cache parse results to speed up consecutive runs [string]
--marker, -m Custom marker function name [string]

@@ -123,0 +133,0 @@

Sorry, the diff of this file is not supported yet

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