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

transl8r

v1.0.1

Published

Manage JSON translation files.

Downloads

3

Readme

Transl8r ✍️

역자 - 译者 - μεταφράστης - ਅਨੁਵਾਦਕ - tercüman - thông dịch viên - مترجم

A simple utility for managing JSON language files in projects.

  • [x] Add/remove keys to multiple languages at once.
  • [x] Automatically provide fallback translations (provided by Google Translate).
  • [x] Perform basic sanity checking.
  • [x] Sort translation files.
  • [x] Validate translation files.
  • [x] Export TODO language translations as CSV.
  • [x] Import CSV language files.

Install

  • Install the package.
  • Create a .transl8r.yml configuration in your project root.
  • (Optional) Set up your Google Translate Credentials (required for --add, --alt and --backfill commands)

Example

.transl8r.yml

group: example
languages:
  base: en
  other: ['fr', 'de']
namespaces:
  target: base.generated
  other: ['legal', 'base']
path: '/resources/lang/{{lang}}/{{namespace}}.json'
validation:
  mismatchedPlaceholders:
    - error.validation.required

Basic Usage

Get a full list of commands like this:

yarn transl8r --help

Usage

Housekeeping

--lint Lint translation files

Lets you know if there's any issues that may affect the translation files.

Failed to validate, there were 2 errors:
fr: "error.validation.required" has mismatched markup tags:
 - <0>,</0> vs <none>
fr: "error.validation.required" has mismatched placeholders:
 - {{label}} vs <none>

You may use the YAML file to silence warnings for mismatched placeholders.

--clean Clean unreachable translations

Remove dead keys from generated files where they exist in the professional translation file.

yarn transl8r --clean
  fr:     Up to date ✓
  de:     Purged 14 unreachable key(s).
  ✨  Done in 0.53s.

--sort Sort translation files

Sort all the language files by key.

Managing translations

--add (or -a) Add single key

Adds a new generated key to all language files, including the base language.

yarn transl8r -a button.dismiss.label
  >> value:  Dismiss

  el:     Απολύω
          → Fire
  it:     Respingere
          → Reject
  ...
✨  Done in 3.87s.

--alt Lost in translation?

Use alternative copy for the translations, without affecting the base (English) translation.

For example: "Dismiss" has many meanings in English, such as "to treat as unworthy of serious consideration". A phrase like "Close prompt" may translate better.

yarn transl8r --alt button.dismissPrompt.label  -l ar it zh-tw
>> translateAs:  Close prompt

ar:     موجه إغلاق
        → Close prompt

it:     Chiudi prompt
        → Close prompt

zh-tw:  關閉提示
        → Turn off the prompt

✨  Done in 1.46s.

--remove Remove a single key

When you've added a key you no longer want:

yarn transl8r --remove button.legacy.close

--backfill Backfill missing translations

Note: This command currently does not reverse translations for sanity checking.

yarn transl8r --backfill

# ...or specific languages only
yarn transl8r --backfill -l fr de

CSV import/export

--exportTodo Export strings that need translating

Exports a .ZIP archive containing CSV files ready to translate.

my-app-todo-2022-07-23.zip/
  my-app.es.csv
  my-app.fr.csv
  my-app.zh-cn.csv
Format example

| contextKey | en | fr | | ------------- | ------------- | ----- | | btn.continue | Continue | | | btn.cancel | Cancel | | | btn.dismiss | Dismiss | |

--importCsv Import strings that need translating

Exports a .ZIP archive containing CSV files ready to translate.

Accepts these formats:

Translated base format

| contextKey | en | fr | | ------------- | ------------- | --------- | | btn.continue | Continue | Continuez | | btn.cancel | Cancel | Annuler | | btn.dismiss | Dismiss | Rejeter |

Translations only format

| contextKey | fr | | ------------- | --------- | | btn.continue | Continuez | | btn.cancel | Annuler | | btn.dismiss | Rejeter |

Options

  • -l - Supply list of language codes to fetch (space seperated: -l fr de es)
  • -p - Path to match the language files on (use {{lang}} and {{namespace}} placeholders)
  • -b - Base language to translate from (default: en)
  • -n - The destination namespace (default: base.generated)

Say for example, you add a new translation for Catalyst into French, and you want to backfill it to English and Chinese (Traditional).

yarn transl8r --backfill  -b fr  -l en zh-TW