Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/celsodias12/i18n-auto-translate
https://github.com/celsodias12/i18n-auto-translate
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/celsodias12/i18n-auto-translate
- Owner: celsodias12
- License: mit
- Created: 2022-04-03T14:53:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-17T14:12:23.000Z (9 months ago)
- Last Synced: 2024-02-17T15:26:20.190Z (9 months ago)
- Language: JavaScript
- Size: 462 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Translate JSON
This project aims to translate JSON files into multiple languages using the Google Cloud translation API.
## Installation
To install the project dependencies, run the following command:
```bash
npm install
```## Usage
To use the project, import the `runTranslateObject` function from the `index.mjs` file and pass the following parameters:
- `jsonToTranslate`: the JSON object to be translated.
- `targetLanguages`: an array with the target languages for translation.
- `translateCredentials`: an object with the credentials to access the Google Cloud translation API.Example:
```javascript
import { runTranslateObject } from './index.mjs'const jsonToTranslate = {
hello: 'Hello',
world: 'World',
nested: {
key: 'Nested key',
},
}const targetLanguages = ['pt', 'es']
const translateCredentials = {
type: process.env.TYPE,
project_id: process.env.PROJECT_ID,
private_key_id: process.env.PRIVATE_KEY_ID,
private_key: process.env.PRIVATE_KEY,
client_email: process.env.CLIENT_EMAIL,
client_id: process.env.CLIENT_ID,
auth_uri: process.env.AUTH_URI,
token_uri: process.env.TOKEN_URI,
auth_provider_x509_cert_url: process.env.AUTH_PROVIDER_X509_CERT_URL,
client_x509_cert_url: process.env.CLIENT_X509_CERT_URL,
keyTranslateAPI: process.env.KEY_GOOGLE_TRANSLATE_API,
}runTranslateObject(jsonToTranslate, targetLanguages, translateCredentials)
```## License
This project is licensed under the MIT License. See the LICENSE file for more information.