Skip to content

argosopentech/LibreTranslate-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LibreTranslate-cpp

LibreTranslate C++17 bindings.

#include <iostream>

#include "LibreTranslate.h"

int main(){
  LibreTranslateAPI libreTranslateAPI;
  std::cout << "translate:" << std::endl;
  std::cout << libreTranslateAPI.translate("Hello World", "en", "es") << std::endl;
  std::cout << std::endl << "languages:" << std::endl;
  std::cout << libreTranslateAPI.languages() << std::endl;
  std::cout << std::endl << "detect:" << std::endl;
  std::cout << libreTranslateAPI.detect("Hello World") << std::endl;
  return 0;
}

translate:
{"translatedText":"Hola Mundo"}

languages:
[{"code":"en","name":"English"},{"code":"ar","name":"Arabic"},{"code":"zh","name":"Chinese"},{"code":"fr","name":"French"},{"code":"de","name":"German"},{"code":"hi","name":"Hindi"},{"code":"id","name":"Indonesian"},{"code":"ga","name":"Irish"},{"code":"it","name":"Italian"},{"code":"ja","name":"Japanese"},{"code":"ko","name":"Korean"},{"code":"pl","name":"Polish"},{"code":"pt","name":"Portuguese"},{"code":"ru","name":"Russian"},{"code":"es","name":"Spanish"},{"code":"tr","name":"Turkish"},{"code":"vi","name":"Vietnamese"}]

detect:
[{"confidence":92.0,"language":"en"}]

Dependencies

libcurl:

sudo apt-get install -y libcurl4-openssl-dev
curl-config --libs

nlohmann/json:

Single file included in source

Building

make

Running

./libretranslate

Clean

make clean

About

LibreTranslate C++ bindings

Resources

License

Stars

Watchers

Forks