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.
@appgrade/translation-xtractor
Advanced tools
Converts a key-value translation JSON to CSV and vice versa
This package enables you to export your translation JSON file(s) to the CSV file format, which can then be edited in a more user-friendly environment like Microsoft Excel or Google Spreadsheets. The other way around is of course also supported. After making your edits in the CSV file, you can then import this file again so that your application has got its translations updated, in the form of one or multiple JSON files.
Working on an application with internationalisation, someone needs to take care of the translations used in the app. Often, this is someone with a less technical background and it would be nice to present them a translation file which is easier to edit. In our case, we use Angular in combination with @ngx/translate. This library reads translations from one or more JSON files, one per language. For English, this file could look like this:
{
"header.banner-text": "Hello",
"login-component.username": "Username",
"login-component.password": "Password",
"footer-component.copyright": "Copyright"
}
And in French like this:
{
"header.banner-text": "Bonjour",
"login-component.username": "Utilisateur",
"login-component.password": "Mot de passe",
"footer-component.copyright": "Copyright"
}
This library then takes in the translation files and spits them out in a format a spreadsheet editor can read. An example of this could look like the table below.
Note that the headers are the component's name and "feature" and the name of the language(s), which are retrieved from the file name(s).
Component | Field name | en | fr |
---|---|---|---|
header | banner-text | Welcome | Bonjour |
login-component | username | Username | Utilisateur |
login-component | password | Password | Mot de passe |
footer-component | copyright | Copyright | Copyright |
After the modifications are done, the CSV file is presented to this package and you get your JSON files again.
To install this package locally, run:
npm i @appgrade/translation-xtractor
You can then reference translation-xtractor
from your npm scripts.
If you want to use it globally, pass the global flag:
npm i -g @appgrade/translation-xtractor
To export your translation files to CSV, use the export
command. You have to specify one or
more input files (with --input
or -i
) and you can specify the name and path of the output
file (with --output
or -o
). By default, this is output.csv
in the current folder.
Some valid examples are:
translation-xtractor export --input english.json
translation-xtractor export -i assets/english.json
translation-xtractor export -i english.json -i french.json -i spanish.json
translation-xtractor export -i english.json --output some-folder/my-file.csv
To import the CSV file again, you can use the import
command. You have to specify one input file (with --input
or -i
) and you can specify the path where the JSON files will be placed. By default, this is the current folder.
Some valid examples are:
translation-xtractor import --input output.csv
translation-xtractor import -i some-folder/output.csv
translation-xtractor import -i some-folder/output.csv -o assets/i18n
--delimiter
alias: -d
You can specify the delimiter for both the import
and export
command. This defaults to ,
(comma).
--merge
alias: -m
You can choose to keep new keys in the output file(s) so that they are not overridden when importing. This defaults to false.
Shoot! You can reach us at info@appgrade.be or create an issue or pull request on our GitHub.
export
and import
commands.FAQs
Converts a key-value translation JSON to CSV and vice versa
We found that @appgrade/translation-xtractor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.