Preparing translation

pull/9/head
aandrew-me 3 years ago
parent a16edc0fe4
commit 7df3da21a0

@ -11,10 +11,10 @@
</head>
<body>
<a id="back">Home</a>
<h1>ytDownloader</h1>
<a id="back">Homepage</a>
<h1>ytDownloader <span id="version"></span></h1>
<p>ytDownloader lets you download videos (and sometimes audios) from hundreds of sites like Youtube, Facebook, Instagram, Tiktok, Twitter and so on.
<p>ytDownloader lets you download videos (and sometimes audios) from hundreds of sites like Youtube, Facebook, Instagram, Tiktok, Twitter and so on
</p>
<p>It's a Free and Open Source app built on top of Node.js and Electron. yt-dlp has been used for downloading</p>
@ -24,6 +24,11 @@
<script>
const { ipcRenderer, shell } = require("electron")
ipcRenderer.send("get-version")
ipcRenderer.once("version", (event, version) => {
document.getElementById("version").textContent = version;
})
document.getElementById("back").addEventListener("click", ()=>{
ipcRenderer.send("close-secondary") })
document.getElementById("sourceLink").addEventListener("click", ()=>{

@ -11,11 +11,14 @@
<script src="../src/renderer.js" defer></script>
<script src="../src/index.js" defer></script>
<!-- Translating -->
<script>window.i18n = new(require('../translations/i18n'));</script>
</head>
<div id="popupBox">
<div id="popup">
<p>yt-dlp is being downloaded.</p>
<p>yt-dlp is being downloaded</p>
<svg id="popupSvg" version="1.1" id="L4" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100"
enable-background="new 0 0 0 0" xml:space="preserve">
@ -73,7 +76,7 @@
<button class="toggleBtn" id="videoToggle">Video</button>
<button class="toggleBtn" id="audioToggle">Audio</button>
</div>
<p id="title">Title: </p>
<p id="title">Title </p>
<div id="videoList">
<label>Select Format - </label>
@ -97,11 +100,11 @@
</div>
<div id="advanced">
<p>Download particular time-range</p>
<p id="rangeText">Download particular time-range</p>
<label>Start</label>
<input type="text" id="startTime" class="time" placeholder="00:00" title="If kept empty, it will start from the beginning">
:
<input type="text" id="endTime" class="time" placeholder="10:00" title="If kept empty, it will be downloaded to the end.">
<input type="text" id="endTime" class="time" placeholder="10:00" title="If kept empty, it will be downloaded to the end">
<label>End</label>
</div>
@ -114,6 +117,10 @@
<div id="list">
</div>
<script>
require("../src/translate_index")
</script>
</body>
</html>

@ -8,15 +8,15 @@
<link rel="stylesheet" href="../assets/css/extra.css">
</head>
<body>
<a id="back">Home</a>
<a id="back">Homepage</a>
<h1>Preferences</h1>
<p>1. Download location</p>
<strong>Download location</strong>
<p>Default location: <span id="path"></span></p>
<button id="selectLocation">Select Download Location</button>
<p id="msg"></pid>
<p>2. Enable transparent dark (only Linux, needs restart) <input type="checkbox" id="enableTransparent"></p>
<p>Enable transparent dark (only Linux, needs restart)<input type="checkbox" id="enableTransparent"></p>
<script>
let downloadPath = localStorage.getItem("downloadPath")

@ -1,5 +1,6 @@
const { app, BrowserWindow, dialog, ipcMain } = require("electron");
const { autoUpdater } = require("electron-updater");
autoUpdater.autoDownload = false;
let win, secondaryWindow;
function createWindow() {
@ -24,10 +25,14 @@ function createWindow() {
// win.setMenu(null)
win.show();
// win.webContents.openDevTools();
autoUpdater.checkForUpdatesAndNotify();
autoUpdater.checkForUpdates();
}
app.whenReady().then(() => {
// Logging
console.log("Locale:" + app.getLocale());
console.log("Version: " + app.getVersion());
createWindow();
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
@ -39,6 +44,20 @@ app.whenReady().then(() => {
}
});
ipcMain.on("get-version", () => {
const version = app.getVersion();
secondaryWindow.webContents.send("version", version);
console.log("Sent " + version);
});
ipcMain.on("get-locale", () => {
const locale = app.getLocale();
win.webContents.send("locale", locale);
if (secondaryWindow) {
secondaryWindow.webContents.send("locale", locale);
}
});
ipcMain.on("load-page", (event, file) => {
secondaryWindow = new BrowserWindow({
webPreferences: {
@ -49,9 +68,8 @@ ipcMain.on("load-page", (event, file) => {
modal: true,
show: false,
});
// win.loadFile(file);
secondaryWindow.loadFile(file);
secondaryWindow.setMenu(null)
// secondaryWindow.setMenu(null);
secondaryWindow.maximize();
secondaryWindow.show();
});
@ -78,27 +96,33 @@ app.on("window-all-closed", () => {
});
// Auto updater events
autoUpdater.on("update-available", (_event, releaseNotes, releaseName) => {
const dialogOpts = {
type: "info",
buttons: ["Ok"],
title: "Application Update",
message: process.platform === "win32" ? releaseNotes : releaseName,
detail: "A new version is being downloaded.",
buttons: ["Update", "No"],
title: "Update Available",
detail: process.platform === "win32" ? releaseNotes : releaseName,
message: "A new version is available, do you want to update?",
};
dialog.showMessageBox(dialogOpts, (response) => {});
dialog.showMessageBox(dialogOpts, (buttonIndex) => {
if (buttonIndex === 0) {
autoUpdater.downloadUpdate();
}
});
});
autoUpdater.on("update-downloaded", (_event, releaseNotes, releaseName) => {
const dialogOpts = {
type: "info",
buttons: ["Restart", "Later"],
title: "Application Update",
message: process.platform === "win32" ? releaseNotes : releaseName,
detail: "A new version has been downloaded. Restart the application to apply the updates.",
title: "Update Ready",
message: "Install and restart now?",
};
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) autoUpdater.quitAndInstall();
if (returnValue.response === 0) {
autoUpdater.quitAndInstall();
} else {
autoUpdater.autoInstallOnAppQuit();
}
});
});

@ -1,9 +1,15 @@
const cp = require("child_process");
const os = require("os");
let ffmpeg;
ffmpeg = __dirname + "/../ffmpeg"
if (os.platform() === "win32"){
ffmpeg = __dirname + "\\..\\ffmpeg.exe"
}
else{
ffmpeg = __dirname + "/../ffmpeg"
}
const fs = require("fs");
const os = require("os");
const path = require("path");
const { shell, ipcRenderer, clipboard } = require("electron");
const { default: YTDlpWrap } = require("yt-dlp-wrap-extended");

@ -0,0 +1,9 @@
function getId(id){
return document.getElementById(id)
}
function querySelector(element){
return document.querySelector(element)
}
var i18n = new(require('../translations/i18n'))
// Translating texts

@ -0,0 +1,21 @@
function getId(id){
return document.getElementById(id)
}
function querySelector(element){
return document.querySelector(element)
}
var i18n = new(require('../translations/i18n'))
// Translating texts
getId("pasteUrl").textContent = i18n.__("Click to paste video URL or ID [Ctrl + V]")
querySelector("#popup p").textContent = i18n.__("yt-dlp is being downloaded")
getId("preferenceWin").textContent = i18n.__("Preferences")
getId("aboutWin").textContent = i18n.__("About")
getId("title").textContent = i18n.__("Title ")
querySelector("#videoList label").textContent = i18n.__("Select Format ")
getId("videoDownload").textContent = i18n.__("Download")
getId("audioDownload").textContent = i18n.__("Download")
getId("advancedToggle").textContent = i18n.__("Advanced")
getId("rangeText").textContent= i18n.__("Download particular time-range")
getId("startTime").title = i18n.__("If kept empty, it will start from the beginning")
getId("endTime").title = i18n.__("If kept empty, it will be downloaded to the end")

@ -0,0 +1,9 @@
function getId(id){
return document.getElementById(id)
}
function querySelector(element){
return document.querySelector(element)
}
var i18n = new(require('../translations/i18n'))
// Translating texts

@ -0,0 +1,28 @@
{
"Click to paste video URL or ID [Ctrl + V]":"",
"Preferences":"",
"About":"",
"Download location":"",
"Default location:" : "",
"Enable transparent dark (only Linux, needs restart)" : "",
"yt-dlp is being downloaded" : "",
"Video": "",
"Audio": "",
"Title " : "",
"Select Format ": "",
"Download":"",
"Select Download Location":"",
"Advanced": "",
"Start":"",
"Download particular time-range":"",
"End":"",
"If kept empty, it will start from the beginning":"",
"If kept empty, it will be downloaded to the end":"",
"Homepage":"",
"ytDownloader lets you download videos (and sometimes audios) from hundreds of sites like Youtube, Facebook, Instagram, Tiktok, Twitter and so on":"",
"It's a Free and Open Source app built on top of Node.js and Electron. yt-dlp has been used for downloading":"",
"Source Code is available":"",
"here":""
}

@ -0,0 +1,34 @@
const path = require("path")
const electron = require('electron')
const fs = require('fs');
const { ipcRenderer } = require("electron");
let loadedLanguage;
let locale;
if(electron.app){
locale = app.getLocale()
}
else{
ipcRenderer.send("get-locale")
ipcRenderer.once("locale", (event, locale)=>{
locale = locale
})
}
module.exports = i18n;
function i18n() {
if(fs.existsSync(path.join(__dirname, locale + '.json'))) {
loadedLanguage = JSON.parse(fs.readFileSync(path.join(__dirname, locale + '.json'), 'utf8'))
}
else {
loadedLanguage = JSON.parse(fs.readFileSync(path.join(__dirname, 'en.json'), 'utf8'))
}
}
i18n.prototype.__ = function(phrase) {
let translation = loadedLanguage[phrase]
if(translation === undefined) {
translation = phrase
}
return translation
}
Loading…
Cancel
Save