Skip to content

JSON translation made easier. Add your client code and translate whole applications

Notifications You must be signed in to change notification settings

mgonzalezg9/i18n-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

i18n Translator

Introduction

I18n Translator is a tool for translating your application into different languages. It is connected to my i18n repository. However you can use the translation service you prefer, feel free to fork the project and change src/api/service.ts calls to fit your API specifications.

Installation

npm install

Usage

Create a .env file with a content like the following:

TRANSLATOR_URL = YOUR_TRANSLATOR_API_URL
TO = YOUR_TARGET_LANGUAGE
FROM = YOUR_SOURCE_LANGUAGE
INPUT_FILE = YOUR_INPUT_FILE
OUTPUT_FILE = YOUR_OUTPUT_FILE
MAX_QUERIES_PER_LEVEL = MAXIMUM_NO_OF_QUERIES # Can be omitted, by default is 5

Notice all the paths are relative to the root of the project. For example:

TRANSLATOR_URL = "http://localhost:3000"
TO = "en"
FROM = "es"
INPUT_FILE = "./test/test.json"
OUTPUT_FILE = "./test/out.json"
MAX_QUERIES_PER_LEVEL = 2

Feel free of running the app using npm start. The following video illustrates its usage.

Test Generation

You can generate a test file using the npm run test:generate command. Be sure of having the following keys added to your environment variables:

TEST_FILE = THE_LOCATION_WHERE_YOUR_TEST_FILE_WILL_BE_PLACED
TEST_KEYS = NO_OF_JSON_TEST_KEYS
TEST_TEXT = YOUR_TEST_TO_TRANSLATE_TESTING

Example:

TEST_FILE = "./test/test.json"
TEST_KEYS = 15
TEST_TEXT = "Hola mundo"

Debugging

VS Code debugging is available through .vscode/launch.json file. This file requires ts-node to be either installed locally or globally with the module linked to this project. In order to link ts-node, you can run npm link ts-node.

Translation API

Translation API errors will be translated as an empty string "". The object translation process is not stopped if query for a given key fails.

Technologies

About

JSON translation made easier. Add your client code and translate whole applications

Topics

Resources

Stars

Watchers

Forks