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

intl-utils-aws-translate

v1.0.3

Published

Helps to automatically translate files for intl-utils using AWS Translate

Downloads

42

Readme

intl-utils-aws-translate

This utility generates or populates the translation files used by intl-utils based on AWS Translate.

Please note you need to have the AWS credentials configured when running the command so they can be used by the utility. See Setting Credentials in Node.js

Usage

  1. Install by running npm i -D intl-util-aws-translate

  2. Add a script to your package.json as follows:

"scripts": {
    "translate": "intl-utils-translate ..."
    ...
  },

See below the options for the command

  1. Run npm run translate to translate all the files in your project.

Options

Usage: intl-util-aws-translate [options]

Where the options are:

  • -V, --version: output the version number
  • -p, --pattern [pattern]: the pattern of the files (default: "**/*.translations.js"). The tool supports JS/TS/JSON (i.e. *.js, *.ts and *.json)
  • -f, --from [language]: the language we are translating from
  • -t, --to [languages...]: the languages to translate to
  • --no-unchanged: suppress the log of unchanged files
  • -h, --help: display help for command

Example: intl-util-aws-translate -f en -t es fr it

Note: The code for the language/languages (es, en, etc.) are the AWS Translate ones (see supported languages in here: Supported languages and language codes)

Note: When changing the pattern in a shell remember to use quotes to prevent the pattern to expand itself (i.e. -p "**/*.translation.js" not just -p **/*.translation.js)

Note: You can add more keys to an existing file and they will be translated.

Long Example

Let's suppose you have to translate: "Hello World!" and "loading..." to Spanish, French and Italian for intl-utils and you want the translations in a JS file.

Then those are the steps you have to follow:

  1. Generate a file named sample.translations.js with all the keys as follows:
module.exports = {
  "es": {
    "Hello World!": "",
    "loading...": ""
  }
}

The structure of the file is:

module.exports = {
  LANGUAGE: {
    KEY: TRANSLATED_KEY
  }
}

Where TRANSLATED_KEY is the translation of KEY on LANGUAGE

  1. Call the utility: intl-util-aws-translate -f en -t es fr it

Note: The language you use the keys below has to be some of the languages you want to translate to (i.e. in this case es=Spanish, fr=French or it=Italian). The utility will look for all the keys you mentioned in the sample file.

Note: **/*.translations.js is the default pattern for the files so it is not required to be specified in the command.

JSON Example

Same but the file will be like:

{
  LANGUAGE: {
    KEY: TRANSLATED_KEY
  }
}

And the command like: intl-util-aws-translate -f en -t es fr it --pattern "**/*.translations.json"

TS Example

Same but the file will be like:

export default {
  LANGUAGE: {
    KEY: TRANSLATED_KEY
  }
}

And the command like: intl-util-aws-translate -f en -t es fr it --pattern "**/*.translations.ts"