More translation stuff
parent
183693a4b5
commit
d55fba8eb3
@ -0,0 +1,42 @@
|
|||||||
|
// Converts the csv translation file to json and puts in translations folder
|
||||||
|
|
||||||
|
// Language of output file
|
||||||
|
const language = "ru"
|
||||||
|
|
||||||
|
const { readFileSync, writeFileSync } = require("fs");
|
||||||
|
|
||||||
|
let csvFile = readFileSync("input.csv", { encoding: "utf-8" });
|
||||||
|
let result = "";
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
let size = csvFile.length;
|
||||||
|
let index = 0
|
||||||
|
|
||||||
|
result += "{";
|
||||||
|
for (let letter of csvFile) {
|
||||||
|
if (letter === `"`) {
|
||||||
|
count++;
|
||||||
|
if (count < 4) {
|
||||||
|
result += letter;
|
||||||
|
index ++;
|
||||||
|
} else {
|
||||||
|
index ++;
|
||||||
|
if (index == size-1){
|
||||||
|
result += `${letter}`;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
result += `${letter},`;
|
||||||
|
}
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result += letter;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result += "}";
|
||||||
|
|
||||||
|
writeFileSync(`translations/${language}.json`, result)
|
||||||
|
|
||||||
|
console.log(`Converted and saved to translations/${language}.json`)
|
||||||
@ -1,61 +1,91 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Preferences</title>
|
<title id="title">Preferences</title>
|
||||||
<link rel="stylesheet" href="../assets/css/extra.css">
|
<link rel="stylesheet" href="../assets/css/extra.css">
|
||||||
|
<!-- Translating -->
|
||||||
|
<script>window.i18n = new (require('../translations/i18n'));</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<a id="back">Homepage</a>
|
<a id="back">Homepage</a>
|
||||||
<h1>Preferences</h1>
|
<h1 id="preferences">Preferences</h1>
|
||||||
<strong>Download location</strong>
|
<br><br>
|
||||||
<p>Default location: <span id="path"></span></p>
|
<strong id="dlText">Download location</strong>
|
||||||
|
<br><br>
|
||||||
|
<span id="clText">Current download location - </span><span id="path"></span>
|
||||||
|
<br><br>
|
||||||
<button id="selectLocation">Select Download Location</button>
|
<button id="selectLocation">Select Download Location</button>
|
||||||
|
|
||||||
<p id="msg"></pid>
|
<p id="msg">
|
||||||
|
</pid>
|
||||||
|
|
||||||
|
|
||||||
<p>Enable transparent dark (only Linux, needs restart)<input type="checkbox" id="enableTransparent"></p>
|
<span id="transparentText">Enable transparent dark mode(only Linux, needs restart)</span><input type="checkbox"
|
||||||
|
id="enableTransparent">
|
||||||
|
|
||||||
<script>
|
<br><br>
|
||||||
let downloadPath = localStorage.getItem("downloadPath")
|
|
||||||
getId("path").textContent = downloadPath
|
|
||||||
|
|
||||||
|
<label>Select Language</label>
|
||||||
|
<select id="select" onchange="changeLanguage()">
|
||||||
|
<option value="en">English</option>
|
||||||
|
<option value="ru">Русский</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
const { ipcRenderer, dialog } = require("electron")
|
<script>
|
||||||
function getId(id){
|
let downloadPath = localStorage.getItem("downloadPath")
|
||||||
return document.getElementById(id)
|
getId("path").textContent = downloadPath
|
||||||
}
|
|
||||||
|
|
||||||
getId("back").addEventListener("click", ()=>{
|
const { ipcRenderer, dialog } = require("electron")
|
||||||
ipcRenderer.send("close-secondary")
|
function getId(id) {
|
||||||
})
|
return document.getElementById(id)
|
||||||
|
}
|
||||||
|
|
||||||
getId("selectLocation").addEventListener("click", ()=>{
|
getId("back").addEventListener("click", () => {
|
||||||
ipcRenderer.send("select-location", "")
|
ipcRenderer.send("close-secondary")
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcRenderer.on("downloadPath", (event, downloadPath)=>{
|
getId("selectLocation").addEventListener("click", () => {
|
||||||
console.log(downloadPath);
|
ipcRenderer.send("select-location", "")
|
||||||
localStorage.setItem("downloadPath", downloadPath)
|
})
|
||||||
getId("path").textContent = downloadPath
|
|
||||||
})
|
|
||||||
|
|
||||||
const enabledTransparent = getId("enableTransparent")
|
ipcRenderer.on("downloadPath", (event, downloadPath) => {
|
||||||
enabledTransparent.addEventListener("change", (event)=>{
|
console.log(downloadPath);
|
||||||
if (enabledTransparent.checked){
|
localStorage.setItem("downloadPath", downloadPath)
|
||||||
localStorage.setItem("enabledTransparent", "true")
|
getId("path").textContent = downloadPath
|
||||||
|
})
|
||||||
|
|
||||||
|
const enabledTransparent = getId("enableTransparent")
|
||||||
|
enabledTransparent.addEventListener("change", (event) => {
|
||||||
|
if (enabledTransparent.checked) {
|
||||||
|
localStorage.setItem("enabledTransparent", "true")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
localStorage.setItem("enabledTransparent", "false")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const localEnabledTransparent = localStorage.getItem("enabledTransparent")
|
||||||
|
if (localEnabledTransparent == "true") {
|
||||||
|
enabledTransparent.checked = true
|
||||||
}
|
}
|
||||||
else{
|
const language = localStorage.getItem("language")
|
||||||
localStorage.setItem("enabledTransparent", "false")
|
|
||||||
|
if (language) {
|
||||||
|
getId("select").value = language
|
||||||
|
}
|
||||||
|
function changeLanguage() {
|
||||||
|
const language = getId("select").value
|
||||||
|
localStorage.setItem("language", language)
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
const localEnabledTransparent = localStorage.getItem("enabledTransparent")
|
require("../src/translate_preferences")
|
||||||
if (localEnabledTransparent == "true"){
|
</script>
|
||||||
enabledTransparent.checked = true
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
Can't render this file because it contains an unexpected character in line 1 and column 43.
|
@ -0,0 +1,9 @@
|
|||||||
|
// Converts translate.json file to translate.csv file
|
||||||
|
|
||||||
|
const fs = require("fs")
|
||||||
|
let inputFile = JSON.parse(fs.readFileSync('translations/translate.json', 'utf8'))
|
||||||
|
|
||||||
|
fs.writeFileSync("translate.csv", "")
|
||||||
|
for (const [key, value] of Object.entries(inputFile)){
|
||||||
|
fs.appendFileSync("translate.csv", key + "\n")
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
Click to paste video URL or ID [Ctrl + V]
|
||||||
|
Preferences
|
||||||
|
About
|
||||||
|
Download location
|
||||||
|
Current download location -
|
||||||
|
Enable transparent dark mode(only Linux, needs restart)
|
||||||
|
Please wait, yt-dlp is being downloaded
|
||||||
|
Video
|
||||||
|
Audio
|
||||||
|
Title
|
||||||
|
Select Format
|
||||||
|
Download
|
||||||
|
Select Download Location
|
||||||
|
More options
|
||||||
|
Start
|
||||||
|
Select Language
|
||||||
|
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
|
||||||
|
@ -1,34 +1,39 @@
|
|||||||
const path = require("path")
|
const path = require("path");
|
||||||
const electron = require('electron')
|
const electron = require("electron");
|
||||||
const fs = require('fs');
|
const fs = require("fs");
|
||||||
const { ipcRenderer } = require("electron");
|
|
||||||
let loadedLanguage;
|
let loadedLanguage;
|
||||||
|
let userSelectedLanguage = false;
|
||||||
let locale;
|
let locale;
|
||||||
if(electron.app){
|
if (electron.app) {
|
||||||
locale = app.getLocale()
|
locale = electron.app.getLocale();
|
||||||
|
} else {
|
||||||
|
locale = navigator.language
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
ipcRenderer.send("get-locale")
|
// Check localstorage for language
|
||||||
ipcRenderer.once("locale", (event, locale)=>{
|
if (localStorage.getItem("language")){
|
||||||
locale = locale
|
locale = localStorage.getItem("language")
|
||||||
})
|
userSelectedLanguage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = i18n;
|
module.exports = i18n;
|
||||||
|
|
||||||
function i18n() {
|
function i18n() {
|
||||||
if(fs.existsSync(path.join(__dirname, locale + '.json'))) {
|
if (fs.existsSync(path.join(__dirname, locale + ".json"))) {
|
||||||
loadedLanguage = JSON.parse(fs.readFileSync(path.join(__dirname, locale + '.json'), 'utf8'))
|
loadedLanguage = JSON.parse(
|
||||||
}
|
fs.readFileSync(path.join(__dirname, locale + ".json"), "utf8")
|
||||||
else {
|
);
|
||||||
loadedLanguage = JSON.parse(fs.readFileSync(path.join(__dirname, 'en.json'), 'utf8'))
|
} else {
|
||||||
}
|
loadedLanguage = JSON.parse(
|
||||||
|
fs.readFileSync(path.join(__dirname, "main.json"), "utf8")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i18n.prototype.__ = function(phrase) {
|
i18n.prototype.__ = function (phrase) {
|
||||||
let translation = loadedLanguage[phrase]
|
let translation = loadedLanguage[phrase];
|
||||||
if(translation === undefined) {
|
if (translation === undefined) {
|
||||||
translation = phrase
|
translation = phrase;
|
||||||
}
|
}
|
||||||
return translation
|
return translation;
|
||||||
}
|
};
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
Loading…
Reference in New Issue