Skip to content

Commit

Permalink
fix: Internationalize the message in the confirmation dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
hidao80 committed Jun 27, 2023
1 parent 54381a1 commit f3d592b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
40 changes: 40 additions & 0 deletions docs/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,95 @@ 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": {
"title": "Fire QRコードリーダー",
"loadingMessage": "🎥 ビデオストリームにアクセスできません。",
"outputData": "検出中...",
"LoadingVideo": "⌛ ビデオをロード中...",
"OpenThisLink?": "このリンクを開きますか?",
"CallThisNumber?": "この番号に電話しますか?",
"SendMail?": "メールを送信しますか?",
"RunThisBookmarklet?": "このブックマークレットを実行しますか?",
"OpenThisApps?": "このアプリを開きますか?",
},
// Spanish
"es": {
"title": "Lector de códigos QR",
"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": {
"title": "Считыватель пожарных QR-кодов",
"loadingMessage": "🎥 Невозможно получить доступ к видеопотоку (убедитесь, что у вас включена веб-камера)",
"outputData": "Обнаружение...",
"LoadingVideo": "⌛ Загрузка видео...",
"OpenThisLink?": "",
"CallThisNumber?": "",
"SendMail?": "",
"RunThisBookmarklet?": "",
"OpenThisApps?": "",
},
// French
"fr": {
"title": "Lecteur de code QR",
"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": {
"title": "QR-Code-Leser abfeuern",
"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": {
"title": "消防二维码阅读器",
"loadingMessage": "🎥 无法访问视频流(请确保你有一个网络摄像头启用)。",
"outputData": "探测...",
"LoadingVideo": "⌛ 正在加载视频...",
"OpenThisLink?": "你想打开这个链接吗?",
"CallThisNumber?": "拨打这个号码?",
"SendMail?": "发送电子邮件?",
"RunThisBookmarklet?": "运行这个小书签?",
"OpenThisApps?": "打开这个应用程序?",
},
// korean
"ko": {
"title": "Fire QR 코드 리더",
"loadingMessage": "🎥 동영상 스트림에 액세스할 수 없습니다(웹캠이 활성화되어 있는지 확인하세요).",
"outputData": "감지 중...",
"LoadingVideo": "⌛ 동영상 로드 중...",
"OpenThisLink?": "이 링크를 열어보시겠습니까?",
"CallThisNumber?": "이 번호로 전화하시겠습니까?",
"SendMail?": "이메일을 보내시겠습니까?",
"RunThisBookmarklet?": "이 북마크릿을 실행하시겠습니까?",
"OpenThisApps?": "이 앱을 열겠습니까?",
},
}

Expand Down

0 comments on commit f3d592b

Please sign in to comment.