Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/duck4i/hnlp-translate
Translate JSON localizations automatically - Helsinki NLP model
https://github.com/duck4i/hnlp-translate
helsinki-nlp llm-inference transformers
Last synced: 28 days ago
JSON representation
Translate JSON localizations automatically - Helsinki NLP model
- Host: GitHub
- URL: https://github.com/duck4i/hnlp-translate
- Owner: duck4i
- Created: 2024-09-21T14:50:34.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-21T16:45:50.000Z (4 months ago)
- Last Synced: 2024-11-17T15:20:12.840Z (2 months ago)
- Topics: helsinki-nlp, llm-inference, transformers
- Language: Python
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HNLP-Translate
Helsinki NLP model AI translation tool - translate JSON localizations files automatically.
## About
A small python tool using Helsinki NLP models to translate the JSON based localizations from one language to another.
Runs locally on your machine, using CPU or CUDA, depending on your machine.## How to use
Using a python `venv` is recommended.
```
# Install deps Deps
pip3 install -r requirements.txt
``````
python3 translate.py [input_json] [output_json] [source_language] [target_language] [target_ext_optional]# Example English to French
python3 translate.py en.json fr.json en fr# Example English to Spanish
python3 translate.py en.json es.json en es
```Translating models with extension target is also supported, NLP models for languages like Baltic or Slavic languages require it.
```
# Slavic languages are SLA code with desired extension code# Example English to Slavic Bosnian (lat)
python3 translate.py en.json ba.json en sla bos_Latn# Example Enlish to Slavic Serbian (cyr)
python3 translate.py en.json sr.json en sla srp_Cyrl
```## Example of translation
Input:
```
{
"global": {
"buttonNext" : "Next"
}
}
```Output (Spanish):
```
{
"global": {
"buttonNext" : "Siguiente"
}
}
```## Model docs:
* https://huggingface.co/Helsinki-NLP
* https://huggingface.co/Helsinki-NLP/opus-mt-en-sla