Socket
Socket
Sign inDemoInstall

angular-translate-csv-to-json

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    angular-translate-csv-to-json

A CLI build tool to generate JSON files required by Angular Translate from a single CSV file


Version published
Weekly downloads
162
increased by27.56%
Maintainers
1
Install size
22.3 kB
Created
Weekly downloads
 

Readme

Source

angular-translate-csv-to-json

A CLI build tool to generate JSON files required by Angular Translate from a single CSV file

npm version

Overview

This is a lightweight, dependency-free command line build tool that converts CSV/TSV files to JSON files Angular Translate can consume during runtime. This enables you to have a single table of translations containing all supported languages. This tool also supports namespacing, so keys like users.create.labelFirstName will produce a nested JSON structure.

Example CSV input

idenfr
users.create.labelFirstNameFirst NamePrénom
users.create.labelLastNameLast NameNom
users.toastValidationEmailSentToUserEmailValidation email sent to {{userEmail}}E-mail de validation envoyé à {{userEmail}}

Example JSON output

English:

{
    "users": {
        "create": {
            "labelFirstName": "First Name",
            "labelLastName": "Last Name"
        },
        "toastValidationEmailSentToUserEmail": "Validation email sent to {{userEmail}}"
    }
}

French:

{
    "users": {
        "create": {
            "labelFirstName": "Prénom",
            "labelLastName": "Nom"
        },
        "toastValidationEmailSentToUserEmail": "E-mail de validation envoyé à {{userEmail}}"
    }
}

Note: Output JSON will not be pretty-printed as above, but compact.

Installation

npm install angular-translate-csv-to-json --save-dev

Usage

node node_modules/angular-translate-csv-to-json config/angular-translate-csv-to-json.config.json

The first (and only) parameter is the path to a config file, which is required.

Configuration:

This is an example configuration you can adapt to your needs:

{
    "csvFileIn": "src/angular/i18n/translations.tsv",
    "jsonDirOut": "src/angular/i18n",
    "jsonFileName": "translations",
    "jsonExt": "json",
    "csvFieldSeparator": "\t"
}

Options

csvFileIn

Type: String

The path to the input CSV file to be processed.

jsonDirOut

Type: String

Output directory to store the generated JSON files in.

jsonFileName

Type: String

The first part of the JSON file name. The file name is constructed as the following: {jsonFileName}.{languageCode}.{jsonFileExt} (e.g. translations.en.json, translations.fr.json, etc.)

jsonFileExt

Type: String

The extension of the generated JSON file.

csvFieldSeparator

Type: String

Field separator of input CSV file.

Keywords

FAQs

Last updated on 22 Feb 2018

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.

Install

Related posts

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