Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Node.js command line client for crusca, the ES6 compatible gettext alternative to extract translation strings
crusca-cli
is the Node client for crusca
, a drop-in replacement for xgettext
to
extract translation strings from Javascript files.
xgettext
falls short on ES6 template strings, that are incidentally the best and more modern
way to create translation strings in JS clients.
From this approach that implies an String.prototype.format
hack in place
const str1 = t('Organisation {0} is now {1} #orgStatus').format(orgName, orgStatus);
const str2 = t('Fill in the {0} #academy').format('<strong>{0}</strong>').format(this.state.title);
To this purely native approach
const str1 = t`Organisation ${orgName} is now ${orgStatus} #orgStatus`;
const str2 = t`Fill in the ${this.state.title} #academy`;
In it's very simplest form, this is it
# from this
find app/assets -type f -iname '*.js' | xargs xgettext --no-wrap --default-domain=javascripts --keyword=t --from-code=UTF-8 -o $pot_file
# to this
node_modules/.bin/crusca-cli -i app/assets -o $pot_file
crusca-cli -i path/to/files -o output.pot [-e -g -c -v]
Scanning the directory /Users/domo/projects/myPrj
to look for .js
files and extract strings
using all the default parameters.
crusca-cli -i /Users/domo/projects/myPrj -o myPrj.pot
Parse a single file and extract strings from it.
Note: any --ignore
or --ext
option will be ignored when parsing a single file.
crusca-cli -i file.js -o strings.pot
You can either install crusca-cli
as a global package or local to your project.
npm install -g crusca-cli
You can then use it anywhere by simply calling crusca-cli
npm install --save-dev crusca-cli
crusca-cli
will then be available in node_modules/.bin/crusca-cli
.
You can either use it from an NPM-script simply by calling it or you can reference to it's path to
access it from anywhere, like a shell script.
E.g.
"scripts": {
"extract": "crusca-cli -i ./src -o strings.pot -e .js -e .jsx"
}
or
#!/bin/bash
prj_dir=./src
output=strings.pot
node_modules/.bin/crusca-cli -i $prj_dir -o $output
crusca-cli
can be configured using a config file which takes the same options listed in the
options section, except --config
obviously.
{
"ignore": [
"bower_components",
"node_modules"
],
"extensions": ["js", "jsx"]
}
Bold options are required
Options | Default | Description |
---|---|---|
-i, --in | -- | File or directory to search for translation strings |
-o, --out | -- | Output file that will contain the extracted strings |
-e, --ext | .js | Whitelist file extensions you want to parse (adds leading dot, if missing). Multiple entries are allowed |
-g, --ignore | [] | Blacklist file or directories you don't want to scan. Support minimatch glob expressions. Multiple entries are allowed |
-c, --config | ./cruscarc | Custom config path |
-v, --verbose | false | Enable chatty version |
-q, --quite | false | Completely silent on success |
-h, --help | -- | Show help |
It is important to note that there is a priority when supplying options
config_file (default or custom with -c)
├── cli_arguments
├───── default_arguments
For example
crusca-cli -i some/folder -o strings.pot -c ./conf -e js -e jsx -g test
Where ./conf is
{
"ext": "js"
}
Will only consider .js
files, because the config has higher priority, while still
ignoring the folder test
, since it has not been overridden in the config file
crusca
options to crusca-cli
config file and command linecruscarc
The MIT License (MIT)
Copyright (c) 2016 Domenico Matteo
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Node.js command line client for crusca, the ES6 compatible gettext alternative to extract translation strings
The npm package crusca-cli receives a total of 1 weekly downloads. As such, crusca-cli popularity was classified as not popular.
We found that crusca-cli 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.