tranzlate.js

1.0.3 • Public • Published

tranzlate logo

A command line interface tool to automatically translate .xcstring catalogs using OpenAI.

English · Chinese (Simplified) · French · Spanish · German

Setup · Usage · Configuration · Markdown · Common Issues · Motivation · Contributing · Contributors

https://github.com/wkaisertexas/tranzlate/assets/27795014/6702dc3c-7f4b-4619-b792-e47949c5b373


Tranzlate CLI Interface

Setup

The minimum supported version of Node.js is v14

  1. Install tranzlate globally:

    npm install -g tranzlate.js
  2. Retrieve your API key from OpenAI

    Note: If you haven't already, you'll have to create an account and set up billing.

  3. Set the key so tranzlate can use it. You can do this by running:

    echo export OPENAI_API_KEY=<your token> >> ~/.bashrc

    or alternatively, provide the key when running the command

Usage

tranzlate

Then you will get a output like this, which takes you through the process of translating a string catalog:

┌   tranzlate: automatic string translation
│
◇  Enter input file
│  Localizable.xcstrings
│
◇  Enter the output file
│  Localizable.xcstrings
│
◆  Select languages to translate to.
│  ◻ Arabic
│  ◻ Catalan
│  ◻ Chinese (Simplified)
│  ◻ Chinese (Traditional)
│  ◻ Croatian
│  ◼ Czech
│  ◼ Danish
│  ◻ Dutch
│  ◻ English
│  ◻ English (Australia)
│  ◻ English (Canada)
│  ◻ English (U.K.)
│  ◻ English (U.S.)
│  ◻ Finnish
│  ◻ French
│  ◻ French (Canada)
│  ◻ German
│  ◻ Greek
│  ◻ Hebrew
│  ◻ Hindi
│  ◻ Hungarian
│  ◼ Indonesian
│  ◻ Italian
│  ◻ Japanese
│  ◻ Korean
│  ◻ Malay
│  ◻ Norwegian
│  ◻ Polish
│  ◼ Portuguese (Brazil)
│  ◻ Portuguese (Portugal)
│  ◻ Romanian
│  ◻ Russian
│  ◻ Slovak
│  ◻ Spanish (Mexico)
│  ◼ Spanish (Spain)
│  ◻ Swedish
│  ◻ Thai
│  ◻ Turkish
│  ◼ Ukrainian
└  ◻ Vietnamese

Configuration

https://github.com/wkaisertexas/tranzlate/assets/27795014/5ae6ca30-d030-4ec8-8c59-e2d1593084dc

Because only supporting a single language would be ironic as a translation utility, we support changing your configuration language. You can set your language by running:

tranzlate set-language <language>

Where <language> is one of the following:

Language Key
English en
Simplified Chinese zh-Hans
Traditional Chinese zh-Hant
Spanish es
Japanese ja
Korean ko
French fr
German de
Russian ru
Ukrainian uk
Vietnamese vi
Arabic ar
Portuguese pt-BR
Turkish tr

For instance, if you want to switch to Simplified Chinese, you can do so by setting the LANGUAGE value to zh-Hans:

tranzlate set-language zh-Hans

This will set your language to Simplified Chinese.

Markdown

Support for markdown translations is supported. To enter markdown mode, run:

tranzlate markdown

You will be prompted for a markdown file or glob to translate. Output translations append the ISO language code to the end of each file name. For instance, if you translate README.md to Simplified Chinese (zh-Hans), the output file will be README.zh-Hans.md.

┌   tranzlate: automatic markdown translation

◇  Enter a markdown file or glob
│  ./README.md

◇  Select languages to translate to
│  fi - Finnish, hu - Hungarian, pl - Polish, ru - Russian

◇  Select a model
│  gpt-3.5-turbo
◆  Translating README.md...

Note: Markdown translation is in beta. Please report any issues you encounter.

Common Issues

429 error

Some users are reporting a 429 from OpenAI. This is due to incorrect billing setup or excessive quota usage. Please follow this guide to fix it.

You can activate billing at this link. Make sure to add a payment method if not under an active grant from OpenAI.

Motivation

I am not a language expert. My proficiency in translation extends only to middle-school level Spanish. However, I believe in software and its importance. Who software is developed for matters. Localization is not nor never should be an afterthought. By utilizing AI translation tools, conversations about the impact software has on different communities can be had earlier in product development, not later.

Accelerating conversations about software's impact leads to meaningful change before feature sets are locked in. This is why I believe in the power of, often imperfect, AI translation tools. Do not let perfect be the enemy of good.

Easy translation, of string catalogs, and hopefully many more file formats to come is why I created tranzlate.

Contributing

If you want to help fix a bug or implement a feature in Issues, please do so. Swift development is somewhat new to me, so I would appreciate community feedback.

Contributors

Alt

Thanks to the ai-shell for their README which I used as a template.

Package Sidebar

Install

npm i tranzlate.js

Weekly Downloads

5

Version

1.0.3

License

MIT

Unpacked Size

76.5 kB

Total Files

8

Last publish

Collaborators

  • wdkaiser