Socket
Socket
Sign inDemoInstall

generate-transifex-config

Package Overview
Dependencies
1
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    generate-transifex-config

Script to generate a Transifex config file for a project, used by command line client.


Version published
Maintainers
2
Install size
29.9 kB
Created

Readme

Source

Generate Transifex config

This module generates a Transifex CLI client config file (.tx/config) for a whole project.

Usually there’s need to run a client command for each file or add them to .tx/config manually, one by one. This project makes it easier for projects with multiple language files.

See Transifex command line client to learn more of this feature.

Installation

npm install --save-dev generate-transifex-config

Usage

This module exports a function that receives an object with parameters:

ParameterTypeDescription
projectNamestringIs the url name from the Transifex project to be updated.
sourceLocalestringThe locale (language) of your source files.
sourcePathstringThe path to the folder where all source language files are located.
destinationPathstringThe path to the file where config will be stored (a file with the same name will be overwritten).
mainobjectAn object containg all configuration for the "main" block (needed by Transifex client).
fileTypesarrayAn array with configuration for each file type.
fileTypes.extensionstringThe extension that will filter the files to apply this configuration.
fileTypes.typestringThe Transifex type for the files matching the extension (see Transifex docs).

Example

Given a project where language files are organized as following:

i18n/
  |-en/
  |  |-file1.json
  |  |-file2.json
  |  \-subfolder
  |     \-file3.md
  \-es/
    ...

The module can be used like this:

const generateTransifexConfig = require('generate-transifex-config');

const params = {
  projectName: 'my-project',
  sourceLocale: 'en',
  sourcePath: '/my-project/i18n/en/',
  destinationPath: '/my-project/.tx/config',
  main: {
    host: 'https://www.transifex.com'
  },
  fileTypes: [
    {
      extension: 'json',
      type: 'KEYVALUEJSON'
    },
    {
      extension: 'md',
      type: 'MARKDOWN'
    }
  ]
};

generateTransifexConfig(params);

This will generate the file /my-project/.tx/config, containing:

[main]
host = https://www.transifex.com

[my-project.file1-json]
source_lang = en
source_file = i18n/es/file1.json
file_filter = i18n/<lang>/file1.json
type = KEYVALUEJSON

[my-project.file2-json]
source_lang = en
source_file = i18n/es/file2.json
file_filter = i18n/<lang>/file2.json
type = KEYVALUEJSON

[my-project.subfolder-file3-md]
source_lang = en
source_file = i18n/es/subfolder/file3.md
file_filter = i18n/<lang>/subfolder/file3.md
type = MARKDOWN

💡 Pro-tip: You can create a file generate-config.js in .tx folder with the required parameters and a call to this module. That way anybody in your team just need to run:

node .tx/generate-config.js

...and the .tx/config file will be updated.

Testing

npm test

Contribution

Anybody is welcome to contribute. Just please follow the rules:

  • Stick to the same code style.
  • Include enough tests.
  • Update README if necessary.

License

MIT

Keywords

FAQs

Last updated on 22 Aug 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