{"id":50,"date":"2022-07-04T14:42:22","date_gmt":"2022-07-04T14:42:22","guid":{"rendered":"https:\/\/hyacinth.rocks\/?p=50"},"modified":"2022-07-04T14:45:35","modified_gmt":"2022-07-04T14:45:35","slug":"installing-libretranslate-on-an-ubuntu-server","status":"publish","type":"post","link":"https:\/\/hyacinth.rocks\/index.php\/2022\/07\/04\/installing-libretranslate-on-an-ubuntu-server\/","title":{"rendered":"Installing LibreTranslate on an Ubuntu Server"},"content":{"rendered":"\n<p>I discovered this great docker package the other day.   I think it would be great if OpenSim users or grid owners could provide their own translation services .<br><br>If someone wants to offer this as a free service, they would be a real hero. \ud83d\ude42<\/p>\n\n\n\n<p>Below are the steps I followed to install it on an Ubuntu 18.04 server.<\/p>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background\"><code>apt update\napt install docker-compose\n\na2enmod proxy_http\na2enmod proxy\n\ngit clone https:\/\/github.com\/uav4geo\/LibreTranslate\ncd LibreTranslate\ndocker-compose up -d --build\n\ndocker run -ti --rm -p 5000:5000 libretranslate\/libretranslate\n<\/code><\/pre>\n\n\n\n<p>To set up a reverse-proxy in Apache 2&#8230;<\/p>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background\"><code>\n\n\n\n###In \/etc\/apache2\/sites-enabled\/your-domain.conf\n\n  #add thins inside your virtual host\n  #below   ServerName ...  ServerAlias ... etc.\n  \n  \n    ProxyPreserveHost On\n    ProxyRequests Off\n    ProxyVia On\n\n    ProxyPass \/ http:\/\/127.0.0.1:5000\/\n    ProxyPassReverse \/ http:\/\/127.0.0.1:5000\/\n\n\n# I think it needs an SSL certificate to run right\n#\n#  certbot --apache -d yourdomain.com\n#  service apache2 restart\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p>Below is an example translation HUD script that I use with my own translation service.    It can definitely be improved.<\/p>\n\n\n\n<p>This was adapted from an old Yandex translator that was no longer working.<\/p>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background\"><code>key owner = NULL_KEY;\nstring baseurl=\"https:\/\/changetoyourdomain.com\/translate\";\nstring fromlang = \"en\";\nstring tolang = \"it\";\ninteger menuchanA = 14856350;\ninteger menuchanB = 16871861;\nstring speaker = \"\";\nstring msg = \"\";\nstring cname;\nkey req;\n\ndefault\n{\n    state_entry()\n    {\n        llSetText(\"Select your language\", &lt;1,1,0&gt;, 1);\n        owner = llGetOwner();\n        llListen(0, \"\", NULL_KEY, \"\");\n        llListen(menuchanA, \"\", owner, \"\");\n        llListen(menuchanB, \"\", owner, \"\");\n        llDialog(owner, \"\\n\\nPlease choose your Native Language:\", &#91;\"en\", \"de\", \"it\", \"es\", \"fr\", \"pt\", \"nl\", \"sv\", \"sq\", \"ar\", \"Page 2\", \"Page 3\"], menuchanA);\n    }\n    \n    on_rez(integer num)\n    {\n        llResetScript();\n    } \n    \n    touch_start(integer num)\n    {\n        key id = llDetectedKey(0);\n        if (id == owner)\n            llDialog(owner, \"\\n\\nPlease choose your Native Language:\", &#91;\"en\", \"de\", \"it\", \"es\", \"fr\", \"pt\", \"nl\", \"sv\", \"sq\", \"ar\", \"Page 2\", \"Page 3\"], menuchanA);\n    }\n    \n    listen(integer channel, string name, key id, string message)\n    {\n        if (channel == 0)\n        {\n            if (id == owner)\n            {\n                if (fromlang != tolang)\n                {\n                    \n        \n        \n        string json;        \n        json = llJsonSetValue(json,&#91;\"q\"],message);\n        json = llJsonSetValue(json,&#91;\"source\"],fromlang);\n        json = llJsonSetValue(json,&#91;\"target\"],tolang);\n        json = llJsonSetValue(json,&#91;\"format\"],\"text\");\n        json = llJsonSetValue(json,&#91;\"api_key\"],\"\");       \n        list httphead = &#91;HTTP_VERIFY_CERT,FALSE,HTTP_METHOD,\"POST\",HTTP_MIMETYPE,\"application\/json\"];\n        cname = name;\n        req=llHTTPRequest(baseurl,httphead,json); \n        \n                }\n            }\n\n        }\n        else if (channel == menuchanA)\n        {\n            if (message == \"Page 2\")\n                llDialog(owner, \"\\n\\nPlease choose your Native Language:\", &#91;\"hy\", \"sr\", \"bg\", \"ca\", \"hr\", \"cs\", \"zh\", \"da\", \"fi\", \"el\", \"Page 1\", \"Page 3\"], menuchanA);\n            else if (message == \"Page 1\")\n                llDialog(owner, \"\\n\\nPlease choose your Native Language:\", &#91;\"en\", \"de\", \"it\", \"es\", \"fr\", \"pt\", \"nl\", \"sv\", \"sq\", \"ar\", \"Page 2\", \"Page 3\"], menuchanA);\n            else if (message == \"Page 3\")\n                llDialog(owner, \"\\n\\nPlease choose your Native Language:\", &#91;\"he\", \"hu\", \"id\", \"ja\", \"ko\", \"no\", \"pl\", \"ro\", \"ru\", \"tr\", \"Page 1\", \"Page 2\"], menuchanA);\n            else\n            {\n                llSetText(\"Choose a translation language\", &lt;1,1,0&gt;, 1);\n                fromlang = message;\n                llDialog(owner, \"\\n\\nPlease choose a Translation Language:\", &#91;\"en\", \"de\", \"it\", \"es\", \"fr\", \"pt\", \"nl\", \"sv\", \"sq\", \"ar\", \"Page 2\", \"Page 3\"], menuchanB);\n            }\n        }\n        else if (channel == menuchanB)\n        {\n            if (message == \"Page 2\")\n                llDialog(owner, \"\\n\\nPlease choose a Translation Language:\", &#91;\"hy\", \"sr\", \"bg\", \"ca\", \"hr\", \"cs\", \"zh\", \"da\", \"fi\", \"el\", \"Page 1\", \"Page 3\"], menuchanB);\n            else if (message == \"Page 1\")\n                llDialog(owner, \"\\n\\nPlease choose a Translation Language:\", &#91;\"en\", \"de\", \"it\", \"es\", \"fr\", \"pt\", \"nl\", \"sv\", \"sq\", \"ar\", \"Page 2\", \"Page 3\"], menuchanB);\n            else if (message == \"Page 3\")\n                llDialog(owner, \"\\n\\nPlease choose a Translation Language:\", &#91;\"he\", \"hu\", \"id\", \"ja\", \"ko\", \"no\", \"pl\", \"ro\", \"ru\", \"tr\", \"Page 1\", \"Page 2\"], menuchanB);\n            else\n            {\n                tolang = message;\n                llSetText(\"Ready\", &lt;0,1,0&gt;, 1);\n                llSleep(0.5);\n                llSetText(\"\", &lt;1,1,1&gt;, 1);\n            }\n        }\n    }\n    \n    http_response(key id, integer status, list metadata, string body)\n    {\n\n            string myname = llGetObjectName();\n            string newname = llKey2Name(owner) + \" (\" + fromlang + \" -&gt; \" + tolang + \")\";\n            llSetObjectName(newname);\n            list li = llJson2List(body);\n\n            llSay(0,llUnescapeURL(llList2String(li,1)));\n            llSetObjectName(myname);\n\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I discovered this great docker package the other day. I think it would be great if OpenSim users or grid owners could provide their own translation services . If someone wants to offer this as a free service, they would be a real hero. \ud83d\ude42 Below are the steps I followed to install it on &hellip; <a href=\"https:\/\/hyacinth.rocks\/index.php\/2022\/07\/04\/installing-libretranslate-on-an-ubuntu-server\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Installing LibreTranslate on an Ubuntu Server<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-50","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/hyacinth.rocks\/index.php\/wp-json\/wp\/v2\/posts\/50","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hyacinth.rocks\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hyacinth.rocks\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hyacinth.rocks\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hyacinth.rocks\/index.php\/wp-json\/wp\/v2\/comments?post=50"}],"version-history":[{"count":4,"href":"https:\/\/hyacinth.rocks\/index.php\/wp-json\/wp\/v2\/posts\/50\/revisions"}],"predecessor-version":[{"id":54,"href":"https:\/\/hyacinth.rocks\/index.php\/wp-json\/wp\/v2\/posts\/50\/revisions\/54"}],"wp:attachment":[{"href":"https:\/\/hyacinth.rocks\/index.php\/wp-json\/wp\/v2\/media?parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hyacinth.rocks\/index.php\/wp-json\/wp\/v2\/categories?post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hyacinth.rocks\/index.php\/wp-json\/wp\/v2\/tags?post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}