Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: translate yt-dlp backend errors to user locale

InstaZDLL5c8e24405ec5
diff --git a/src/lib/error-translate.ts b/src/lib/error-translate.ts
new file mode 100644
index 00000000..88641ded
--- /dev/null
+++ b/src/lib/error-translate.ts
@@ -0,0 +1,50 @@
+/**
+ * Maps backend yt-dlp error strings (from translate_ytdlp_error in Rust) to i18n keys.
+ * The backend returns fixed English strings — we detect them and return the translated version.
+ */
+
+const BACKEND_ERROR_MAP: Record<string, string> = {
+ "Video requires login. Use browser cookies or try another URL.":
+ "errors.login_required",
+ "Server returned error 429 (too many requests). Try again later.":
+ "errors.rate_limited",
+ "Access denied (403). The video may be private or region-restricted.":
+ "errors.access_denied",
+ "Video extraction failed. Update yt-dlp or try again.":
+ "errors.extraction_failed",
+ "Requested format is not available. The download will retry with a compatible format.":
+ "errors.format_unavailable",
+ "Video unavailable or removed.": "errors.video_unavailable",
+ "This video is private.": "errors.video_private",
+ "Video blocked due to copyright.": "errors.copyright_blocked",
+ "Video restricted in your region.": "errors.geo_restricted",
+ "Connection timed out. Check your internet and try again.":
+ "errors.connection_timeout",
+ "FFmpeg not found. Install FFmpeg to download this format.":
+ "errors.ffmpeg_missing",
+ "Unsupported URL. Check that the link is correct.": "errors.unsupported_url",
+ "Failed to access the page. Check the link and your connection.":
+ "errors.page_access_failed",
+ "No video formats found for this link.": "errors.no_formats",
+};
+
+/**
+ * Translate a backend error string to the user's locale.
+ * Strips the "Failed to get formats: " prefix added by the Tauri command layer.
+ * Falls back to the original message if not recognized.
+ */
+export function translateBackendError(
+ msg: string,
+ t: (key: string) => string
+): string {
+ if (!msg) return t("common.unknown_error");
+
+ // Strip prefix added in downloads.rs ("Failed to get formats: ...")
+ const stripped = msg.replace(/^Failed to get formats:\s*/, "").trim();
+
+ const key = BACKEND_ERROR_MAP[stripped];
+ if (key) return t(key);
+
+ // Fallback: return the message as-is (may be an unrecognized yt-dlp error)
+ return stripped || msg;
+}
diff --git a/src/lib/i18n/el.json b/src/lib/i18n/el.json
index eaf438db..92514d7f 100644
--- a/src/lib/i18n/el.json
+++ b/src/lib/i18n/el.json
@@ -452,5 +452,21 @@
"unknown_error": "Άγνωστο σφάλμα",
"ytdlp_missing": "Το yt-dlp δεν είναι εγκατεστημένο. Εγκαταστήστε το στις Ρυθμίσεις για να ενεργοποιήσετε τις λήψεις.",
"go_to_settings": "Πήγαινε στις Ρυθμίσεις"
+ },
+ "errors": {
+ "login_required": "Απαιτείται σύνδεση — χρησιμοποιήστε τα cookies του browser ή δοκιμάστε άλλο URL",
+ "rate_limited": "Πολλά αιτήματα (429) — δοκιμάστε αργότερα",
+ "access_denied": "Πρόσβαση απορρίφθηκε (403) — το βίντεο μπορεί να είναι ιδιωτικό ή με γεωγραφικό αποκλεισμό",
+ "extraction_failed": "Αποτυχία εξαγωγής — ενημερώστε το yt-dlp ή δοκιμάστε ξανά",
+ "format_unavailable": "Η ζητούμενη μορφή δεν είναι διαθέσιμη",
+ "video_unavailable": "Το βίντεο δεν είναι διαθέσιμο ή έχει αφαιρεθεί",
+ "video_private": "Αυτό το βίντεο είναι ιδιωτικό",
+ "copyright_blocked": "Αποκλεισμός λόγω πνευματικών δικαιωμάτων",
+ "geo_restricted": "Δεν είναι διαθέσιμο στην περιοχή σας",
+ "connection_timeout": "Λήξη χρόνου σύνδεσης — ελέγξτε τη σύνδεσή σας",
+ "ffmpeg_missing": "Το FFmpeg δεν βρέθηκε — εγκαταστήστε το στις Ρυθμίσεις",
+ "unsupported_url": "Μη υποστηριζόμενο URL — ελέγξτε τον σύνδεσμο",
+ "page_access_failed": "Αδυναμία πρόσβασης στη σελίδα — ελέγξτε τον σύνδεσμο και τη σύνδεση",
+ "no_formats": "Δεν βρέθηκαν μορφές βίντεο για αυτόν τον σύνδεσμο"
}
}
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index 6c5f73c0..f35e37fc 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -452,5 +452,21 @@
"unknown_error": "Unknown error",
"ytdlp_missing": "yt-dlp is not installed. Install it in Settings to enable downloads.",
"go_to_settings": "Go to Settings"
+ },
+ "errors": {
+ "login_required": "Login required — use browser cookies or try another URL",
+ "rate_limited": "Too many requests (429) — try again later",
+ "access_denied": "Access denied (403) — video may be private or region-restricted",
+ "extraction_failed": "Extraction failed — update yt-dlp or try again",
+ "format_unavailable": "Requested format not available",
+ "video_unavailable": "Video unavailable or removed",
+ "video_private": "This video is private",
+ "copyright_blocked": "Blocked due to copyright",
+ "geo_restricted": "Not available in your region",
+ "connection_timeout": "Connection timed out — check your internet",
+ "ffmpeg_missing": "FFmpeg not found — install it in Settings",
+ "unsupported_url": "Unsupported URL — check the link",
+ "page_access_failed": "Could not access the page — check the link and connection",
+ "no_formats": "No video formats found for this link"
}
}
diff --git a/src/lib/i18n/fr.json b/src/lib/i18n/fr.json
index bce3e915..651acf24 100644
--- a/src/lib/i18n/fr.json
+++ b/src/lib/i18n/fr.json
@@ -440,5 +440,21 @@
"unknown_error": "Erreur inconnue",
"ytdlp_missing": "yt-dlp n'est pas installé. Installez-le dans les Paramètres pour activer les téléchargements.",
"go_to_settings": "Aller aux Paramètres"
+ },
+ "errors": {
+ "login_required": "Connexion requise — utilisez les cookies du navigateur ou essayez une autre URL",
+ "rate_limited": "Trop de requêtes (429) — réessayez plus tard",
+ "access_denied": "Accès refusé (403) — la vidéo est peut-être privée ou géo-bloquée",
+ "extraction_failed": "Extraction échouée — mettez yt-dlp à jour ou réessayez",
+ "format_unavailable": "Format demandé indisponible",
+ "video_unavailable": "Vidéo introuvable ou supprimée",
+ "video_private": "Cette vidéo est privée",
+ "copyright_blocked": "Bloquée pour droits d'auteur",
+ "geo_restricted": "Non disponible dans votre région",
+ "connection_timeout": "Connexion expirée — vérifiez votre réseau",
+ "ffmpeg_missing": "FFmpeg introuvable — installez-le dans Paramètres",
+ "unsupported_url": "URL non supportée — vérifiez le lien",
+ "page_access_failed": "Impossible d'accéder à la page — vérifiez le lien et la connexion",
+ "no_formats": "Aucun format vidéo trouvé pour ce lien"
}
}
diff --git a/src/lib/i18n/it.json b/src/lib/i18n/it.json
index 348fea90..761c992f 100644
--- a/src/lib/i18n/it.json
+++ b/src/lib/i18n/it.json
@@ -440,5 +440,21 @@
"unknown_error": "Errore sconosciuto",
"ytdlp_missing": "yt-dlp non è installato. Installalo nelle Impostazioni per abilitare i download.",
"go_to_settings": "Vai alle Impostazioni"
+ },
+ "errors": {
+ "login_required": "Accesso richiesto — usa i cookie del browser o prova un altro link",
+ "rate_limited": "Troppe richieste (429) — riprova più tardi",
+ "access_denied": "Accesso negato (403) — il video potrebbe essere privato o geo-bloccato",
+ "extraction_failed": "Estrazione fallita — aggiorna yt-dlp o riprova",
+ "format_unavailable": "Formato richiesto non disponibile",
+ "video_unavailable": "Video non disponibile o rimosso",
+ "video_private": "Questo video è privato",
+ "copyright_blocked": "Bloccato per copyright",
+ "geo_restricted": "Non disponibile nella tua regione",
+ "connection_timeout": "Connessione scaduta — controlla la connessione",
+ "ffmpeg_missing": "FFmpeg non trovato — installalo nelle Impostazioni",
+ "unsupported_url": "URL non supportato — controlla il link",
+ "page_access_failed": "Impossibile accedere alla pagina — controlla il link e la connessione",
+ "no_formats": "Nessun formato video trovato per questo link"
}
}
\ No newline at end of file
diff --git a/src/lib/i18n/ja.json b/src/lib/i18n/ja.json
index 73ce89ed..47689411 100644
--- a/src/lib/i18n/ja.json
+++ b/src/lib/i18n/ja.json
@@ -440,5 +440,21 @@
"unknown_error": "不明なエラー",
"ytdlp_missing": "yt-dlpがインストールされていません。ダウンロードを有効にするには設定からインストールしてください。",
"go_to_settings": "設定へ移動"
+ },
+ "errors": {
+ "login_required": "ログインが必要です — ブラウザのCookieを使用するか別のURLをお試しください",
+ "rate_limited": "リクエストが多すぎます (429) — しばらく後でお試しください",
+ "access_denied": "アクセス拒否 (403) — 動画が非公開か地域制限されている可能性があります",
+ "extraction_failed": "抽出に失敗しました — yt-dlpを更新するか再試行してください",
+ "format_unavailable": "要求したフォーマットは利用できません",
+ "video_unavailable": "動画は利用できないか削除されています",
+ "video_private": "この動画は非公開です",
+ "copyright_blocked": "著作権によりブロックされています",
+ "geo_restricted": "お住まいの地域では利用できません",
+ "connection_timeout": "接続がタイムアウトしました — インターネット接続を確認してください",
+ "ffmpeg_missing": "FFmpegが見つかりません — 設定からインストールしてください",
+ "unsupported_url": "サポートされていないURL — リンクを確認してください",
+ "page_access_failed": "ページにアクセスできませんでした — リンクと接続を確認してください",
+ "no_formats": "このリンクには動画フォーマットが見つかりません"
}
}
diff --git a/src/lib/i18n/pt.json b/src/lib/i18n/pt.json
index 66bddda9..9dda8dc2 100644
--- a/src/lib/i18n/pt.json
+++ b/src/lib/i18n/pt.json
@@ -440,5 +440,21 @@
"unknown_error": "Erro desconhecido",
"ytdlp_missing": "yt-dlp não está instalado. Instale nas Configurações para habilitar downloads.",
"go_to_settings": "Ir para Configurações"
+ },
+ "errors": {
+ "login_required": "Login necessário — use cookies do navegador ou tente outro URL",
+ "rate_limited": "Muitas solicitações (429) — tente novamente mais tarde",
+ "access_denied": "Acesso negado (403) — o vídeo pode ser privado ou bloqueado por região",
+ "extraction_failed": "Extração falhou — atualize o yt-dlp ou tente novamente",
+ "format_unavailable": "Formato solicitado indisponível",
+ "video_unavailable": "Vídeo indisponível ou removido",
+ "video_private": "Este vídeo é privado",
+ "copyright_blocked": "Bloqueado por direitos autorais",
+ "geo_restricted": "Não disponível na sua região",
+ "connection_timeout": "Conexão expirou — verifique sua internet",
+ "ffmpeg_missing": "FFmpeg não encontrado — instale nas Configurações",
+ "unsupported_url": "URL não suportado — verifique o link",
+ "page_access_failed": "Não foi possível acessar a página — verifique o link e a conexão",
+ "no_formats": "Nenhum formato de vídeo encontrado para este link"
}
}
diff --git a/src/lib/i18n/zh.json b/src/lib/i18n/zh.json
index ad501303..002ea58f 100644
--- a/src/lib/i18n/zh.json
+++ b/src/lib/i18n/zh.json
@@ -440,5 +440,21 @@
"unknown_error": "未知错误",
"ytdlp_missing": "未安装 yt-dlp。请在设置中安装以启用下载功能。",
"go_to_settings": "前往设置"
+ },
+ "errors": {
+ "login_required": "需要登录 — 请使用浏览器 Cookie 或尝试其他链接",
+ "rate_limited": "请求过多 (429) — 请稍后再试",
+ "access_denied": "访问被拒绝 (403) — 视频可能是私密的或受地区限制",
+ "extraction_failed": "提取失败 — 请更新 yt-dlp 或重试",
+ "format_unavailable": "所请求的格式不可用",
+ "video_unavailable": "视频不可用或已删除",
+ "video_private": "该视频是私密的",
+ "copyright_blocked": "因版权被封锁",
+ "geo_restricted": "在您所在地区不可用",
+ "connection_timeout": "连接超时 — 请检查网络",
+ "ffmpeg_missing": "未找到 FFmpeg — 请在设置中安装",
+ "unsupported_url": "不支持的 URL — 请检查链接",
+ "page_access_failed": "无法访问该页面 — 请检查链接和连接",
+ "no_formats": "此链接未找到视频格式"
}
}
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index 01f0171a..e0ba5b09 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -18,6 +18,7 @@
import { onClipboardUrl } from "$lib/stores/clipboard-monitor";
import { getMediaPreview, clearMediaPreview } from "$lib/stores/media-preview-store.svelte";
import { t } from "$lib/i18n";
+ import { translateBackendError } from "$lib/error-translate";
type PlatformInfo = {
platform: string;
@@ -280,7 +281,7 @@
if (gen !== formatFetchGeneration) return;
formats = [];
const msg = typeof e === "string" ? e : e.message ?? "";
- formatError = msg || $t("omnibox.formats_error");
+ formatError = msg ? translateBackendError(msg, $t) : $t("omnibox.formats_error");
} finally {
loadingFormats = false;
}
diff --git a/src/routes/downloads/+page.svelte b/src/routes/downloads/+page.svelte
index 2778ad2f..001d6ea8 100644
--- a/src/routes/downloads/+page.svelte
+++ b/src/routes/downloads/+page.svelte
@@ -1,6 +1,7 @@
<script lang="ts">
import { invoke } from "@tauri-apps/api/core";
import { t } from "$lib/i18n";
+ import { translateBackendError } from "$lib/error-translate";
import { showToast } from "$lib/stores/toast-store.svelte";
import {
getDownloads,
@@ -301,7 +302,7 @@
{/if}
{#if item.status === "error" && item.error}
- <span class="item-error">{item.error}</span>
+ <span class="item-error">{translateBackendError(item.error, $t)}</span>
{/if}
{#if item.status !== "queued"}
@@ -368,7 +369,7 @@
{/if}
{#if item.status === "error" && item.error}
- <span class="item-error">{item.error}</span>
+ <span class="item-error">{translateBackendError(item.error, $t)}</span>
{/if}
<div class="progress-track">