Browse Source

internalization

websocket
loicbersier 1 year ago
parent
commit
a00d9eec8b
7 changed files with 99 additions and 25 deletions
  1. +9
    -5
      app/Controllers/Http/DownloadController.js
  2. +8
    -0
      resources/locales/en/announcement.json
  3. +27
    -0
      resources/locales/en/messages.json
  4. +8
    -0
      resources/locales/fr/announcement.json
  5. +27
    -0
      resources/locales/fr/messages.json
  6. +19
    -20
      resources/views/index.edge
  7. +1
    -0
      start/app.js

+ 9
- 5
app/Controllers/Http/DownloadController.js View File

@ -3,14 +3,15 @@ const youtubedl = require('youtube-dl')
const fs = require('fs')
const ffmpeg = require('fluent-ffmpeg')
const { version } = require('../../../package.json');
const Antl = use('Antl')
let viewCounter = 0;
let files = [];
let day;
let month;
let announcementArray = ['Twitter download seems to work fine now!', 'u lookin hot today vro', 'I am not responsible for what you download', 'If you want to support me you can donate through my paypal at the bottom of the page', 'Did you know this website is open source?', 'Did you know this website can download from other website than youtube?', 'You can mouse hover a video to see a preview of it!']
let announcement
let title = `le epic downloader v${version}`;
let announcementArray;
let announcement
function formatBytes(bytes, decimals = 2) { // https://stackoverflow.com/a/18650828
@ -27,16 +28,19 @@ function formatBytes(bytes, decimals = 2) { // https://stackoverflow.com/a/18650
class DownloadController {
async index ({ view, response }) {
async index ({ view, request, locale }) {
viewCounter++;
// Coudln't find a cleaner way to make it change with the browser locale
announcementArray = [Antl.forLocale(locale).formatMessage('announcement.1'), Antl.forLocale(locale).formatMessage('announcement.2'), Antl.forLocale(locale).formatMessage('announcement.3'), Antl.forLocale(locale).formatMessage('announcement.4'), Antl.forLocale(locale).formatMessage('announcement.5'), Antl.forLocale(locale).formatMessage('announcement.6')];
// Get random announcement
announcement = announcementArray[Math.floor(Math.random() * announcementArray.length)];
// Get date for some event
let today = new Date();
day = today.getDay();
month = today.getMonth();
// If legacy link return
if (response.request.url == '/legacy') return view.render('legacy', { title: title, viewCounter: viewCounter, day: day, month: month, announcement: announcement});
if (request.url == '/legacy') return view.render('legacy', { title: title, viewCounter: viewCounter, day: day, month: month, announcement: announcement});
files = [];
let file = [];
@ -70,7 +74,7 @@ class DownloadController {
files.push({ name: f.split('.').slice(0, -1).join('.'), size: formatBytes(fs.statSync(`./public/uploads/${f}`).size), location: `uploads/${f}`, ext: f.split('.').pop(), img: `/asset/music.png` });
}
}
return view.render('index', { title: title, viewCounter: viewCounter, file: files, day: day, month: month, announcement: announcement });
return view.render('index', { title: title, viewCounter: viewCounter, file: files, day: day, month: month, announcement: announcement});
}
async download({ view, request, response }) {

+ 8
- 0
resources/locales/en/announcement.json View File

@ -0,0 +1,8 @@
{
"1": "u lookin hot today vro 😳😳",
"2": "I am not responsible for what you download.",
"3": "If you want to support me you can donate through my paypal at the bottom of the page",
"4": "Did you know this website is open source?",
"5": "Did you know this website can download from other website than youtube?",
"6": "You can mouse hover a video to see a preview of it!"
}

+ 27
- 0
resources/locales/en/messages.json View File

@ -0,0 +1,27 @@
{
"announcement": "Announcement",
"LQ": "Low quality",
"HQ": "High quality",
"altDL": "Alternate download",
"feed": "Hide from feed",
"download": "Download that mf video",
"dlStart": "Download started!",
"errorCopy": "An error has occured while copying the link to your clipboard.",
"successCopy": "Successfully copied link to your clipboard!",
"recentFeed": "Recently downloaded videos",
"recentDownload": "Download",
"recentCopy": "Copy to clipboard",
"recentFormat": "File format",
"recentSize": "File size",
"footer": "I decline any responsabilities for download made using this website.",
"footer2p1": "Credit to",
"footer2p2": "My other projects",
"footer2p3": "Numbers of visits",
"footer2p4": "Contact",
"footer2p5": "on Discord if you have any issues",
"footer3p1": "You can also support me either on",
"footer3p2": "or by tipping",
"footer3p3": "on this website! or using my referal link for",
"footer4": "Legacy version",
"eggXmas": "Happy Christmas!"
}

+ 8
- 0
resources/locales/fr/announcement.json View File

@ -0,0 +1,8 @@
{
"1": "salut bg 😳😳",
"2": "Je ne suis pas résponsable pour ce que vous télécharger.",
"3": "Si vous voulez me supporter vous pouvez me faire une donation avec paypal en bas de la page.",
"4": "Le saviez-vous? Le site est open source!",
"5": "Le saviez-vous? Vous pouvez télécharger des vidéos sur d'autre site que youtube.",
"6": "Vous pouvez passer la souris sur une vidéo pour en voir un aperçu!"
}

+ 27
- 0
resources/locales/fr/messages.json View File

@ -0,0 +1,27 @@
{
"announcement": "Annoncement",
"LQ": "Basse qualité",
"HQ": "Haute qualité",
"altDL": "Téléchargement alternatif",
"feed": "Masquer du flux",
"download": "Télécharge cette vidéo",
"dlStart": "Téléchargement lancée!",
"errorCopy": "Une erreur est survenue en essayant de copier le lien dans votre presse-papier",
"successCopy": "Lien copié avec succès vers votre presse-papiers!",
"recentFeed": "Vidéos récemment télécharger",
"recentDownload": "Télécharge",
"recentCopy": "Copier au press-papier",
"recentFormat": "Format du fichier",
"recentSize": "Taille du fichier",
"footer": "Je décline toute résponsabilité pour les téléchargement fait avec ce site",
"footer2p1": "Merci à",
"footer2p2": "Mes autres projets",
"footer2p3": "Nombre de visite",
"footer2p4": "Contactée",
"footer2p5": "sur Discord si vous avez des problèmes",
"footer3p1": "Vous pouvez me supporter sur",
"footer3p2": "ou en fesent une donation avec",
"footer3p3": "sur ce site! Ou en utilisent mon lien de parrainage pour",
"footer4": "Legacy version",
"eggXmas": "Joyeu noël!"
}

+ 19
- 20
resources/views/index.edge View File

@ -24,12 +24,12 @@
@if(announcement || (day == '24' || day == '25') && month == '11')
<div class="message is-info">
<div class="message-header">
Announcement
{{ antl.formatMessage('messages.announcement') }}
<button class="delete" onclick="fadeout('announcement')"></button>
</div>
<div class="message-body">
@if((day == '24' || day == '25') && month == '11')
<p class="title">Happy Christmas!</p>
<p class="title">{{ antl.formatMessage('messages.eggXmas') }}</p>
@endif
<p class="subtitle">{{ announcement }}</p>
</div>
@ -52,22 +52,22 @@
<div class="control">
<label class="radio" for="small">
<input class="radio" type="radio" name="quality" id="small" value="small">
Low quality
{{ antl.formatMessage('messages.LQ') }}
</label>
<label class="radio" for="high">
<input class="radio" type="radio" name="quality" id="high" value="high" checked>
High quality
{{ antl.formatMessage('messages.HQ') }}
</label>
<label class="checkbox" for="alt">
<input class="checkbox" type="checkbox" name="alt" id="alt" title="Use this if download dosen't work">
Alternate download?
{{ antl.formatMessage('messages.altDL') }}
</label>
<label class="checkbox" for="feed">
<input class="checkbox" type="checkbox" name="feed" id="feed" title="Use this if you don't want the video you are downloading to be public">
Hide from feed?
{{ antl.formatMessage('messages.feed') }}
</label>
</div>
</div>
@ -81,7 +81,7 @@
<input type="text" id="URL" name="URL" class="downloadurl input is-rounded" placeholder="Link">
</p>
<p class="control">
<button type="button" class="downloadbtn button is-primary is-rounded" id="button" onclick="submitDownload()">Download that mf video</button>
<button type="button" class="downloadbtn button is-primary is-rounded" id="button" onclick="submitDownload()">{{ antl.formatMessage('messages.download') }}</button>
</p>
</div>
</div>
@ -133,7 +133,7 @@
</section>
@if(file != "")
<p class="title has-text-light has-text-centered">Recently downloaded videos</p>
<p class="title has-text-light has-text-centered">{{ antl.formatMessage('messages.recentFeed') }}</p>
<section class="section">
<div class="columns is-vcentered is-multiline fadein">
@each(file in file)
@ -150,23 +150,23 @@
<div class="content">
<div class="field has-addons is-centered">
<p class="control">
<a class="button is-link is-rounded" href="{{ file.location }}" download>Download<i class="fas fa-fw fa-file-download" aria-hidden="true"></i></a>
<a class="button is-link is-rounded" href="{{ file.location }}" download>{{ antl.formatMessage('messages.recentDownload') }}<i class="fas fa-fw fa-file-download" aria-hidden="true"></i></a>
</p>
<p class="control">
<button class="button is-link is-rounded" onclick="toClipboard('https:\/\/namejeff.xyz\/{{ file.location }}')">Add to clipboard<i class="fas fa-fw fa-clipboard" aria-hidden="true"></i></button>
<button class="button is-link is-rounded" onclick="toClipboard('https:\/\/namejeff.xyz\/{{ file.location }}')">{{ antl.formatMessage('messages.recentCopy') }}<i class="fas fa-fw fa-clipboard" aria-hidden="true"></i></button>
</p>
</div>
</div>
<div class="field is-grouped">
<div class="control">
<div class="tags has-addons">
<span class="tag">File format</span>
<span class="tag">{{ antl.formatMessage('messages.recentFormat') }}</span>
<span class="tag is-primary">{{ file.ext }}</span>
</div>
</div>
<div class="control">
<div class="tags has-addons">
<span class="tag">File size</span>
<span class="tag">{{ antl.formatMessage('messages.recentSize') }}</span>
<span class="tag is-primary">{{ file.size }}</span>
</div>
</div>
@ -177,12 +177,11 @@
</div>
</section>
@endif
<footer class="footer has-background-grey-dark has-text-light has-text-centered">
<p>I decline any responsabilities for download made using this website.</p>
<p>Credit to <a href="https://github.com/rg3/youtube-dl/">youtube-dl</a> - My other project <a href="https://discordapp.com/oauth2/authorize?client_id=377563711927484418&scope=bot&permissions=0">Haha yes</a> & <a href="https://twitter.com/ExplosmR">ExplosmRCG twitter bot</a> - Numbers of visits: {{ viewCounter }} - Contact Supositware#1616 on Discord if you have any issues</p>
<p>You can also support me either on <a href="https://www.paypal.me/supositware">Paypal</a> or by tipping <a href="https://basicattentiontoken.org/">BAT</a> on this website! or using my referal link for <a href="https://brave.com/nam120">Brave Browser </a>
<p><a href="legacy">Legacy version</a></p>
<p>{{ antl.formatMessage('messages.footer') }}</p>
<p>{{ antl.formatMessage('messages.footer2p1') }} <a href="https://github.com/rg3/youtube-dl/">youtube-dl</a> - {{ antl.formatMessage('messages.footer2p2') }} <a href="https://discordapp.com/oauth2/authorize?client_id=377563711927484418&scope=bot&permissions=0">Haha yes</a> & <a href="https://twitter.com/ExplosmR">ExplosmRCG twitter bot</a> - {{ antl.formatMessage('messages.footer2p3') }}: {{ viewCounter }} - {{ antl.formatMessage('messages.footer2p4') }} <a href="https://discord.gg/cNRh5JQ">Supositware#1616</a> {{ antl.formatMessage('messages.footer2p5') }}</p>
<p>{{ antl.formatMessage('messages.footer3p1') }} <a href="https://www.paypal.me/supositware">Paypal</a> {{ antl.formatMessage('messages.footer3p2') }} <a href="https://basicattentiontoken.org/">BAT</a> {{ antl.formatMessage('messages.footer3p3') }} <a href="https://brave.com/nam120">Brave Browser </a>
<p><a href="legacy">{{ antl.formatMessage('messages.footer4') }}</a></p>
</footer>
@if(month == '11')
<script src="JS/snow.js"></script>
@ -192,7 +191,7 @@
function submitDownload() {
let frm = document.getElementsByName('download-form')[0];
frm.submit();
document.getElementById('msg').innerHTML = '<div class="notification is-success fadein" id="notif"></button>Download started!</div>';
document.getElementById('msg').innerHTML = '<div class="notification is-success fadein" id="notif"></button>{{ antl.formatMessage('messages.dlStart') }}</div>';
setTimeout(() => {
fadeout('notif')
}, 2000);
@ -212,12 +211,12 @@
navigator.clipboard.writeText(text)
.catch(err => {
console.error(err);
document.getElementById('msg').innerHTML = '<div class="notification is-error fadein" id="notif">An error has occured while copying the link to your clipboard.</div>';
document.getElementById('msg').innerHTML = '<div class="notification is-error fadein" id="notif">{{ antl.formatMessage('messages.errorCopy') }}</div>';
setTimeout(() => {
fadeout('notif')
}, 2000);
});
document.getElementById('msg').innerHTML = '<div class="notification is-success fadein" id="notif">Success fully copied link to your clipboard!</div>';
document.getElementById('msg').innerHTML = '<div class="notification is-success fadein" id="notif">{{ antl.formatMessage('messages.successCopy') }}</div>';
setTimeout(() => {
fadeout('notif')
}, 2000);

+ 1
- 0
start/app.js View File

@ -20,6 +20,7 @@ const providers = [
'@adonisjs/session/providers/SessionProvider',
'@adonisjs/auth/providers/AuthProvider',
'@adonisjs/validator/providers/ValidatorProvider',
'@adonisjs/antl/providers/AntlProvider',
]
/*

Loading…
Cancel
Save