From f3d592bebcd66a6ddd9a58ce6da295bbc4e0e66d Mon Sep 17 00:00:00 2001 From: hidao80 <8155294+hidao80@users.noreply.github.com> Date: Wed, 28 Jun 2023 05:51:20 +0900 Subject: [PATCH] fix: Internationalize the message in the confirmation dialog --- docs/app.js | 10 +++++----- docs/i18n.js | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/docs/app.js b/docs/app.js index 0225c7f..da3289f 100644 --- a/docs/app.js +++ b/docs/app.js @@ -84,19 +84,19 @@ window.addEventListener("load", function () { const colon = code.data.indexOf(":") + 1; if (/^https?:\/\/[\w/:%#\$&\?\(\)~\.=\+\-]+$/.test(code.data)) { // If the content is a URL, display a link to it. - confirm("Open this link?\n\n" + code.data) && linkClick(code.data); + confirm(i18n.translate("OpenThisLink?") + "\n\n" + code.data) && linkClick(code.data); } else if (/^tel:\d{6,11}$/.test(code.data)) { // If the content is a phone number, dial a number to it. - confirm("Call this number?\n\n" + code.data.slice(colon)) && linkClick(code.data); + confirm(i18n.translate("CallThisNumber?") + "\n\n" + code.data.slice(colon)) && linkClick(code.data); } else if (/^mailto:[\w\.-]+?@[\w\.-]+$/.test(code.data)) { // If the content is a deep link, launch the application. - confirm("Send mail?\n\n" + code.data.slice(colon)) && linkClick(code.data); + confirm(i18n.translate("SendMail?") + "\n\n" + code.data.slice(colon)) && linkClick(code.data); } else if (/^javascript:.+$/.test(code.data)) { // If the content is a javascript, run the script. - confirm("Open this apps?\n\n" + code.data.slice(0, colon - 1)) && linkClick(code.data); + confirm(i18n.translate("RunThisBookmarklet?") + "\n\n" + code.data.slice(0, colon - 1)) && linkClick(code.data); } else if (/^\w+:[\w\.-@/#%]+$/.test(code.data)) { // If the content is a deep link, launch the application. - confirm("Open this apps?\n\n" + code.data.slice(0, colon - 1)) && linkClick(code.data); + confirm(i18n.translate("OpenThisApps?") + "\n\n" + code.data.slice(0, colon - 1)) && linkClick(code.data); } } } diff --git a/docs/i18n.js b/docs/i18n.js index 03c6ff0..0b616ca 100644 --- a/docs/i18n.js +++ b/docs/i18n.js @@ -14,6 +14,11 @@ export default class i18n { "loadingMessage": "🎥 Unable to access video stream (please make sure you have a webcam enabled)", "outputData": "Detecting...", "LoadingVideo": "⌛ Loading video...", + "OpenThisLink?": "Do you want to open this link?", + "CallThisNumber?": "Call this number?", + "SendMail?": "Send an email?", + "RunThisBookmarklet?": "Run this bookmarklet?", + "OpenThisApps?": "Open this app?", }, // Japanese "ja": { @@ -21,6 +26,11 @@ export default class i18n { "loadingMessage": "🎥 ビデオストリームにアクセスできません。", "outputData": "検出中...", "LoadingVideo": "⌛ ビデオをロード中...", + "OpenThisLink?": "このリンクを開きますか?", + "CallThisNumber?": "この番号に電話しますか?", + "SendMail?": "メールを送信しますか?", + "RunThisBookmarklet?": "このブックマークレットを実行しますか?", + "OpenThisApps?": "このアプリを開きますか?", }, // Spanish "es": { @@ -28,6 +38,11 @@ export default class i18n { "loadingMessage": "🎥 No se puede acceder al flujo de vídeo (asegúrese de que tiene una cámara web habilitada).", "outputData": "Detectar...", "LoadingVideo": "⌛ Cargando vídeo...", + "OpenThisLink?": "¿Quieres abrir este enlace?", + "CallThisNumber?": "¿Llamar a este número?", + "SendMail?": "¿Enviar un correo electrónico?", + "RunThisBookmarklet?": "¿Ejecutar este bookmarklet?", + "OpenThisApps?": "¿Abrir esta aplicación?", }, // Russian "ru": { @@ -35,6 +50,11 @@ export default class i18n { "loadingMessage": "🎥 Невозможно получить доступ к видеопотоку (убедитесь, что у вас включена веб-камера)", "outputData": "Обнаружение...", "LoadingVideo": "⌛ Загрузка видео...", + "OpenThisLink?": "", + "CallThisNumber?": "", + "SendMail?": "", + "RunThisBookmarklet?": "", + "OpenThisApps?": "", }, // French "fr": { @@ -42,6 +62,11 @@ export default class i18n { "loadingMessage": "🎥 Impossible d'accéder au flux vidéo (assurez-vous que votre webcam est activée)", "outputData": "Détecter...", "LoadingVideo": "⌛ Chargement de la vidéo...", + "OpenThisLink?": "Вы хотите открыть эту ссылку?", + "CallThisNumber?": "Позвонить по этому номеру?", + "SendMail?": "Отправить электронное сообщение?", + "RunThisBookmarklet?": "Запустить этот букмарклет?", + "OpenThisApps?": "Открыть это приложение?", }, // German "de": { @@ -49,6 +74,11 @@ export default class i18n { "loadingMessage": "🎥 Zugriff auf Videostream nicht möglich (bitte stellen Sie sicher, dass Sie eine Webcam aktiviert haben)", "outputData": "Aufspüren...", "LoadingVideo": "⌛ Video wird geladen...", + "OpenThisLink?": "Möchten Sie diesen Link öffnen?", + "CallThisNumber?": "Diese Nummer anrufen?", + "SendMail?": "Eine E-Mail senden?", + "RunThisBookmarklet?": "Dieses Bookmarklet ausführen?", + "OpenThisApps?": "Diese App öffnen?", }, // Chinese "zh": { @@ -56,6 +86,11 @@ export default class i18n { "loadingMessage": "🎥 无法访问视频流(请确保你有一个网络摄像头启用)。", "outputData": "探测...", "LoadingVideo": "⌛ 正在加载视频...", + "OpenThisLink?": "你想打开这个链接吗?", + "CallThisNumber?": "拨打这个号码?", + "SendMail?": "发送电子邮件?", + "RunThisBookmarklet?": "运行这个小书签?", + "OpenThisApps?": "打开这个应用程序?", }, // korean "ko": { @@ -63,6 +98,11 @@ export default class i18n { "loadingMessage": "🎥 동영상 스트림에 액세스할 수 없습니다(웹캠이 활성화되어 있는지 확인하세요).", "outputData": "감지 중...", "LoadingVideo": "⌛ 동영상 로드 중...", + "OpenThisLink?": "이 링크를 열어보시겠습니까?", + "CallThisNumber?": "이 번호로 전화하시겠습니까?", + "SendMail?": "이메일을 보내시겠습니까?", + "RunThisBookmarklet?": "이 북마크릿을 실행하시겠습니까?", + "OpenThisApps?": "이 앱을 열겠습니까?", }, }