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.
npm install
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.
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"
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 errors will be translated as an empty string ""
. The object translation process is not stopped if query for a given key fails.