Skip to content

Commit d9474c3

Browse files
LibreTranslate (#5154)
Co-authored-by: push-app-to-main[bot] <203845782+push-app-to-main[bot]@users.noreply.github.com> Co-authored-by: Slaviša Arežina <[email protected]>
1 parent f5a5e48 commit d9474c3

File tree

4 files changed

+187
-0
lines changed

4 files changed

+187
-0
lines changed

ct/headers/libretranslate

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__ _ __ ______ __ __
2+
/ / (_) /_ ________/_ __/________ _____ _____/ /___ _/ /____
3+
/ / / / __ \/ ___/ _ \/ / / ___/ __ `/ __ \/ ___/ / __ `/ __/ _ \
4+
/ /___/ / /_/ / / / __/ / / / / /_/ / / / (__ ) / /_/ / /_/ __/
5+
/_____/_/_.___/_/ \___/_/ /_/ \__,_/_/ /_/____/_/\__,_/\__/\___/
6+

ct/libretranslate.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: Slaviša Arežina (tremor021)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/LibreTranslate/LibreTranslate
7+
8+
APP="LibreTranslate"
9+
var_tags="${var_tags:-Arr}"
10+
var_cpu="${var_cpu:-2}"
11+
var_ram="${var_ram:-2048}"
12+
var_disk="${var_disk:-20}"
13+
var_os="${var_os:-debian}"
14+
var_version="${var_version:-12}"
15+
var_unprivileged="${var_unprivileged:-1}"
16+
17+
header_info "$APP"
18+
variables
19+
color
20+
catch_errors
21+
22+
function update_script() {
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
27+
if [[ ! -d /opt/libretranslate ]]; then
28+
msg_error "No ${APP} Installation Found!"
29+
exit
30+
fi
31+
RELEASE=$(curl -s https://api.github.com/repos/LibreTranslate/LibreTranslate/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
32+
if [[ "${RELEASE}" != "$(cat $HOME/.libretranslate)" ]] || [[ ! -f $HOME/.libretranslate ]]; then
33+
msg_info "Stopping $APP"
34+
systemctl stop libretranslate
35+
msg_ok "Stopped $APP"
36+
37+
msg_info "Updating $APP to ${RELEASE}"
38+
cd /opt/libretranslate
39+
source .venv/bin/activate
40+
$STD pip install -U libretranslate
41+
msg_ok "Updated $APP to ${RELEASE}"
42+
43+
msg_info "Starting $APP"
44+
systemctl start libretranslate
45+
msg_ok "Started $APP"
46+
47+
msg_ok "Update Successful"
48+
else
49+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
50+
fi
51+
exit
52+
}
53+
54+
start
55+
build_container
56+
description
57+
58+
msg_ok "Completed Successfully!\n"
59+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
60+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
61+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:5000${CL}"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "LibreTranslate",
3+
"slug": "libretranslate",
4+
"categories": [
5+
0
6+
],
7+
"date_created": "2025-06-13",
8+
"type": "ct",
9+
"updateable": true,
10+
"privileged": false,
11+
"interface_port": 5000,
12+
"documentation": "https://github.com/LibreTranslate/LibreTranslate?tab=readme-ov-file#settings--flags",
13+
"website": "https://libretranslate.com/",
14+
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/libretranslate.webp",
15+
"config_path": "",
16+
"description": "Free and Open Source Machine Translation API, entirely self-hosted. Unlike other APIs, it doesn't rely on proprietary providers such as Google or Azure to perform translations. Instead, its translation engine is powered by the open source Argos Translate library.",
17+
"install_methods": [
18+
{
19+
"type": "default",
20+
"script": "ct/libretranslate.sh",
21+
"resources": {
22+
"cpu": 2,
23+
"ram": 2048,
24+
"hdd": 20,
25+
"os": "debian",
26+
"version": "12"
27+
}
28+
}
29+
],
30+
"default_credentials": {
31+
"username": null,
32+
"password": null
33+
},
34+
"notes": [
35+
{
36+
"text": "During the installation, application will download language models used for translation. Depending on how fast your internet/host is, this can take 5-10 minutes.",
37+
"type": "info"
38+
},
39+
{
40+
"text": "At every boot of LXC, application will look for updates for language models installed. This can prolong the startup of the LXC.",
41+
"type": "info"
42+
}
43+
]
44+
}

install/libretranslate-install.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: Slaviša Arežina (tremor021)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/LibreTranslate/LibreTranslate
7+
8+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
msg_info "Installing dependencies"
17+
$STD apt-get install -y --no-install-recommends \
18+
pkg-config \
19+
gcc \
20+
g++ \
21+
libicu-dev
22+
msg_ok "Installed dependencies"
23+
24+
msg_info "Setup Python3"
25+
$STD apt-get install -y \
26+
python3-pip \
27+
python3-dev \
28+
python3-icu
29+
msg_ok "Setup Python3"
30+
31+
setup_uv
32+
fetch_and_deploy_gh_release "LibreTranslate/LibreTranslate"
33+
34+
msg_info "Setup LibreTranslate (Patience)"
35+
cd /opt/libretranslate
36+
$STD uv venv .venv
37+
$STD source .venv/bin/activate
38+
$STD uv pip install --upgrade pip setuptools
39+
$STD uv pip install Babel==2.12.1
40+
$STD .venv/bin/python scripts/compile_locales.py
41+
$STD uv pip install torch==2.2.0 --extra-index-url https://download.pytorch.org/whl/cpu
42+
$STD uv pip install "numpy<2"
43+
$STD uv pip install .
44+
$STD uv pip install libretranslate
45+
$STD .venv/bin/python scripts/install_models.py
46+
msg_ok "Installed LibreTranslate"
47+
48+
msg_info "Creating Service"
49+
cat <<EOF >/etc/systemd/system/libretranslate.service
50+
[Unit]
51+
Description=LibreTranslate
52+
After=network.target
53+
54+
[Service]
55+
User=root
56+
Type=idle
57+
Restart=always
58+
Environment="PATH=/usr/local/lib/python3.11/dist-packages/libretranslate"
59+
ExecStart=/opt/libretranslate/.venv/bin/python3 /opt/libretranslate/.venv/bin/libretranslate --host * --update-models
60+
ExecReload=/bin/kill -s HUP
61+
KillMode=mixed
62+
TimeoutStopSec=1
63+
64+
[Install]
65+
WantedBy=multi-user.target
66+
EOF
67+
systemctl enable -q --now libretranslate
68+
msg_ok "Created Service"
69+
70+
motd_ssh
71+
customize
72+
73+
msg_info "Cleaning up"
74+
$STD apt-get -y autoremove
75+
$STD apt-get -y autoclean
76+
msg_ok "Cleaned"

0 commit comments

Comments
 (0)