npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generate-transifex-config

v1.0.2

Published

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

Downloads

1

Readme

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:

| Parameter | Type | Description | | ------------- | ------------- | ----------------- | | projectName | string | Is the url name from the Transifex project to be updated. | | sourceLocale | string | The locale (language) of your source files. | | sourcePath | string | The path to the folder where all source language files are located. | | destinationPath | string | The path to the file where config will be stored (a file with the same name will be overwritten). | | main | object | An object containg all configuration for the "main" block (needed by Transifex client). | | fileTypes | array | An array with configuration for each file type. | | fileTypes.extension | string | The extension that will filter the files to apply this configuration. | | fileTypes.type | string | The 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