Comments (2)
I made a connection to the local Libre Translate for myself. Hastily done, the url and api key are not editable. I got the list of languages through the AI chatbot, but I didn't check everything.
from .base import * import requests @register_translator('LibreTranslate') class LibreTranslator(BaseTranslator): concate_text = False params: Dict = { } def _setup_translator(self): self.lang_map['العربية'] = 'ar' self.lang_map['Azərbaycan dili'] = 'az' self.lang_map['中文'] = 'zh' self.lang_map['繁體中文'] = 'zht' self.lang_map['čeština'] = 'cs' self.lang_map['Dansk'] = 'da' self.lang_map['Nederlands'] = 'nl' self.lang_map['English'] = 'en' self.lang_map['Esperanto'] = 'eo' self.lang_map['Suomi'] = 'fi' self.lang_map['Français'] = 'fr' self.lang_map['Deutsch'] = 'de' self.lang_map['Ελληνικά'] = 'el' self.lang_map['עברית'] = 'he' self.lang_map['हिन्दी'] = 'hi' self.lang_map['magyar nyelv'] = 'hu' self.lang_map['Bahasa Indonesia'] = 'id' self.lang_map['Gaeilge'] = 'ga' self.lang_map['Italiano'] = 'it' self.lang_map['日本語'] = 'ja' self.lang_map['ⵜⴰⵇⴱⴰⵢⵍⵉⵜ'] = 'kab' self.lang_map['한국어'] = 'ko' self.lang_map['occitan'] = 'oc' self.lang_map['پارسی'] = 'fa' self.lang_map['Polski'] = 'pl' self.lang_map['Português'] = 'pt' self.lang_map['русский язык'] = 'ru' self.lang_map['slovenčina'] = 'sk' self.lang_map['Español'] = 'es' self.lang_map['Svenska'] = 'sv' self.lang_map['Türkçe'] = 'tr' self.lang_map['українська мова'] = 'uk' self.lang_map['Tiếng Việt'] = 'vi' def _translate(self, src_list: List[str]) -> List[str]: # URL of the LibreTranslate API server url = "http://localhost:5000/translate" # Empty list to store the translated strings result = [] # Loop through the source list for src in src_list: # Make a POST request to the API with the source string and the languages response = requests.post(url, data={"q": src, "source": self.lang_map[self.lang_source], "target": self.lang_map[self.lang_target], "format": "text", "api_key": ""}) # Check if the response is successful if response.ok: # Parse the JSON response and get the translated text translated = response.json()["translatedText"] # Append the translated text to the result list result.append(translated) else: # Handle the error print(f"Request failed with status code: {response.status_code}") print(f"Response text: {response.text}") # Return the result list return result
chat gpt help? :)
from ballonstranslator.
chat gpt help? :)
claude
from ballonstranslator.
Related Issues (20)
- chatgpt使用3rd party url没有效果,所有翻译都留空 HOT 12
- 可以增加gpt-3.5-turbo-16k模型或者自定义模型功能吗 官网GPTapi容易封号中转api不封不过得用这个模型才行 另外加一个小问题反馈 HOT 3
- 改字号的时候程序停止响应 HOT 6
- 请问可以自行添加字体库吗?
- How to add another language translation? HOT 3
- 请问可以重新渲染全部图片到 result 文件夹里吗?(软件没识别到文字被修改,就没法重新保存图片) HOT 6
- Add Gemini Translator HOT 2
- Add Gemini ai 🥺 HOT 4
- Cropped text on different font HOT 2
- BT MOD (set up like Photoshop) enhancement HOT 1
- Want to add thai language translation HOT 2
- Text stroke not saved properly HOT 2
- 右键选中翻译后文字选择删除并恢复被抹除文字不起作用 HOT 16
- latin text wrapping is wrong HOT 1
- GPT "hallucinations" are put onto the pages without being checked. HOT 3
- Translation API requests are made seperately for each page, prompt template and chat system template overheads add up in token cost.
- chargpt翻译 token过长报错 HOT 1
- Can't update HOT 1
- export to photoshop HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ballonstranslator.