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

polyglotte

v0.1.2

Published

Automatic Translation Generator for Multilingual Applications

Downloads

5

Readme

Polyglotte - Simplifying Translation Generation with JSON files

Have you ever faced the daunting task of populating extensive .json files with translations for various languages?

Polyglotte is a user-friendly tool designed to simplify the process of generating translations for your application in multiple languages.

This versatile tool supports internationalization (i18n) and automatically generates JSON files containing translations for your chosen languages.

Polyglotte leverages the Google Cloud Translation API for precise and dependable translations.

Features

  • Generate translations in JSON files for any language seamlessly.
  • User-friendly tool for i18n support.
  • Leverages the Google Cloud Translation API for precision.

Installation

npm install polyglotte

Usage

import generateTranslations from "polyglotte";

const arrayToTranslate = ["Hello", "my name is", "How", "Are", "You"];

// Specify your target languages
const languages = ["en", "es", "fr"];

// Set freeApi to false (strongly not recommended) if you are not using a free API
const freeApi = true;

// Replace 'your-api-key' with your actual Google Cloud API Key
const apiKey = "your-api-key";

const translations = generateTranslations(
  arrayToTranslate,
  languages,
  freeApi,
  apiKey
);

console.log(translations);

CLI

You can also generate translations through the terminal, just type npx polyglotte in your terminal and respond each prompt.

##
npx polyglotte

## Enter a comma-separated list of phrases to translate:
"Hello", "my name is", "How", "Are", "You"

## Enter a comma-separated list of target languages:
"en", "es", "fr"

## Use the free API? (yes/no):
no

## Enter your Google Cloud API Key:
api-key

## Enter the output directory for translations:
/translations

Example Output

After using Polyglotte to generate translations, your translations folder will support any language, producing files like:

project-root-directory/
|-- translations/
| |-- en.json
| |-- es.json
| |-- fr.json
| |-- your-language.json
|-- other-project-files-and-directories

Parameters

Example

In the example above, the arrayToTranslate contains phrases that you want to translate into English (en), Spanish (es), and French (fr). The translations are automatically generated using the specified languages and stored in JSON files.

Note

Ensure that you have a valid Google Cloud API Key with the necessary permissions for the Translation API.

If using the free API, set freeApi to true. For paid API usage, set freeApi to false and provide your API key. Feel free to contribute and enhance Polyglotte for better multilingual support in your applications!

Please replace `"your-api-key"` with your actual Google Cloud API Key in the code. If you have any further requests or adjustments, feel free to let me know!

Attention Users:

Polyglotte offers a convenient and powerful translation solution using the Google Cloud Translation API. However, please be aware of the following limitations when using the free API:

  1. Limited Requests: The free Google Translate API has usage limitations, including a restricted number of requests per day. If your application demands a higher volume of translations, you may encounter service interruptions.

  2. Consider a Paid Option: For projects with higher translation needs, we strongly recommend considering a paid subscription to the Google Cloud Translation API. This ensures a more reliable and scalable translation service for your application.