Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rune/hermes
Automating machine translations via Crowdin
https://github.com/rune/hermes
Last synced: about 2 months ago
JSON representation
Automating machine translations via Crowdin
- Host: GitHub
- URL: https://github.com/rune/hermes
- Owner: rune
- Created: 2021-02-27T02:42:58.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-11-22T14:46:15.000Z (about 1 year ago)
- Last Synced: 2024-04-24T18:52:44.587Z (9 months ago)
- Language: JavaScript
- Size: 47.9 KB
- Stars: 1
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#### Usage
Hermes provides utility functions that help automate the machine translation workflow. It doesn't perform any extraction for strings to be translated, handle resolving human & machine translations, nor logic for when files should be committed.
```
const trSync = require("@runeai/hermes");(async function() {
await trSync({
"languageData": {
"15": { "iso6391code": "zh", "crowdinLocaleCode": "zh-CN" },
"17": { "iso6391code": "es", "crowdinLocaleCode": "es-ES" },
"22": { "iso6391code": "ru", "crowdinLocaleCode": "ru" },
},
"filePaths": ["translations/en/messages.po"],
"crowdinInfo": {
"projectName": "superawesomeproject",
"apiKey": "xxxxxxxxx"
},
"processables": [
{ "phrase": "Friend Boost", "processor": "lowercase" },
{ "phrase": "Quick Match", "processor": "lowercase" }
]
})
})()
```#### How it works
1. The function will first create a copy of the provided file paths. This is the source of truth to help ensure integrity of original strings after the processing step.
2. If `processables` are provided, the function will match the `phrase` in any locale files and process it by one of the predetermined processors (see list below).
3. Update the source file in Crowdin, so any strings added/modified will be there ready to be translated.
4. Next, it'll machine translate the files using Google translate into the specified locales in the `languageData` payload when invoked.
5. When translations are done, the function will download all files into their respective locale folder, based on the language's ISO 639-1 code.
6. Finally, it'll replace all message strings to the original and clean up any of the copies made in the first step.#### Existing list of processors
`lowercase` - lowercases the entire string
...more to come!