From cb326823cbce073613065bd3ac29e56e419685a2 Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Sat, 21 Jan 2023 13:20:37 +1100 Subject: [PATCH] A bunch more translations, and change a log to alert() in ptchina-playlist --- gulp/res/js/captcha.js | 8 ++--- gulp/res/js/ptchina-playlist.js | 3 +- locales/en.json | 33 ++++++++++++++++++++ locales/pt.json | 33 ++++++++++++++++++++ views/includes/actionfooter.pug | 6 ++-- views/includes/actionfooter_globalmanage.pug | 6 ++-- views/includes/actionfooter_manage.pug | 6 ++-- views/includes/boardpages.pug | 2 +- views/includes/captcha.pug | 6 ++-- views/includes/pages.pug | 2 +- views/includes/postform.pug | 2 +- views/mixins/catalogtile.pug | 17 +++++----- views/mixins/post.pug | 18 +++++------ views/mixins/threadwatcher.pug | 2 +- views/pages/catalog.pug | 12 +++---- views/pages/overboardcatalog.pug | 10 +++--- 16 files changed, 118 insertions(+), 48 deletions(-) diff --git a/gulp/res/js/captcha.js b/gulp/res/js/captcha.js index 04c78c00..702357b4 100644 --- a/gulp/res/js/captcha.js +++ b/gulp/res/js/captcha.js @@ -1,4 +1,4 @@ -/* globals captchaOptions captchaformsection */ +/* globals __ captchaOptions captchaformsection */ const captchaCookieRegex = /captchaid=(.[^;]*)/ig; class CaptchaController { @@ -46,7 +46,7 @@ class CaptchaController { //captcha.parentElement.previousSibling.previousSibling.tagName === 'SUMMARY' ? captcha.parentElement.previousSibling.previousSibling : captcha.parentElement; hoverListener.addEventListener('mouseover', () => this.loadCaptcha(captcha), { once: true }); } else { //captchaOptions.type === 'text' - captcha.placeholder = 'focus to load captcha'; + captcha.placeholder = __('focus to load captcha'); captcha.addEventListener('focus', () => this.loadCaptcha(captcha), { once: true }); } } @@ -117,12 +117,12 @@ class CaptchaController { refreshDiv.addEventListener('click', (e) => this.refreshCaptchas(e), true); refreshDiv.textContent = '↻'; if (captchaOptions.type === 'text') { - field.placeholder = 'loading'; + field.placeholder = __('loading'); } captchaImg.src = imgSrc; captchaImg.onload = () => { if (captchaOptions.type === 'text') { - field.placeholder = 'Captcha text'; + field.placeholder = __('Captcha text'); } captchaDiv.appendChild(captchaImg); captchaDiv.appendChild(refreshDiv); diff --git a/gulp/res/js/ptchina-playlist.js b/gulp/res/js/ptchina-playlist.js index 00cfa255..6446a9fc 100644 --- a/gulp/res/js/ptchina-playlist.js +++ b/gulp/res/js/ptchina-playlist.js @@ -1,3 +1,4 @@ +/* globals __ */ //https://github.com/ussaohelcim/ptchina-playlist/tree/bookmarklet-let async function threadToPlaylist(board, postId) { async function getThread() { @@ -56,7 +57,7 @@ async function threadToPlaylist(board, postId) { if (playlist.split('\n').length > 1) { downloadPlaylist(`${thread.board}-${thread.postId}.m3u`, playlist); } else { - console.log('No video/audio files in this thread.'); + alert(__('No video/audio files in this thread.')); } } catch (error) { console.log(error); diff --git a/locales/en.json b/locales/en.json index 9bef07e2..45fc27c2 100644 --- a/locales/en.json +++ b/locales/en.json @@ -25,6 +25,39 @@ "one": "File", "other": "Files" }, + "Replies": { + "one": "Reply", + "other": "Replies" + }, + "Thread Watcher": "Thread Watcher", + "Captcha text": "Captcha text", + "Please enable JavaScript to solve the captcha.": "Please enable JavaScript to solve the captcha.", + "%s characters": { + "one": "%s character", + "other": "%s characters" + }, + "No video/audio files in this thread.": "No video/audio files in this thread.", + "focus to load captcha": "focus to load captcha", + "loading": "loading", + "Page": "Page", + "Hide": "Hide", + "Filter Name": "Filter Name", + "Filter Subject": "Filter Subject", + "Filter ID": "Filter ID", + "Filter Tripcode": "Filter Tripcode", + "Moderate": "Moderate", + "Edit": "Edit", + "Watch": "Watch", + "Playlist": "Playlist", + "Filter": "Filter", + "Sort By": "Sort By", + "Bump Order": "Bump Order", + "Creation Date": "Creation Date", + "Reply Count": "Reply Count", + "No posts.": "Sem publicações.", + "Show Post Actions": "Show Post Actions", + "Actions": "Actions", + "Submit": "Submit", "Max %s files": { "one": "Max %s file", "other": "Max %s files" diff --git a/locales/pt.json b/locales/pt.json index b85e6077..bef42c81 100644 --- a/locales/pt.json +++ b/locales/pt.json @@ -25,6 +25,39 @@ "one": "Ficheiro", "other": "Ficheiros" }, + "Replies": { + "one": "Reposta", + "other": "Repostas" + }, + "Captcha text": "Código captcha", + "Please enable JavaScript to solve the captcha.": "Necessita JavaScript.", + "%s characters": { + "one": "%s caracter", + "other": "%s caracteres" + }, + "No video/audio files in this thread.": "No video/audio files in this thread.", + "focus to load captcha": "Seleciona para carregar captcha", + "loading": "loading", + "Page": "Página", + "Hide": "Esconder", + "Filter Name": "Filtrar Nome", + "Filter Subject": "Filtrar Assunto", + "Filter ID": "Filtrar ID", + "Filter Tripcode": "Filtrar Tripcode", + "Moderate": "Filtrar Nome", + "Edit": "Editar", + "Watch": "+Favorito", + "Thread Watcher": "Favoritos", + "Playlist": "Playlist", + "Filter": "Filtrar", + "Sort By": "Ordenar", + "Bump Order": "Bump", + "Creation Date": "Criação", + "Reply Count": "Respostas", + "No posts.": "No Posts.", + "Show Post Actions": "Denunciar/Moderar", + "Actions": "Ações", + "Submit": "Enviar", "Max %s files": { "one": "Máx %s", "other": "Máx %s" diff --git a/views/includes/actionfooter.pug b/views/includes/actionfooter.pug index 359b128b..ef1a42ac 100644 --- a/views/includes/actionfooter.pug +++ b/views/includes/actionfooter.pug @@ -1,8 +1,8 @@ details.toggle-label#actionform - summary.collapse#action-menu Show Post Actions + summary.collapse#action-menu #{__('Show Post Actions')} .actions input(type='hidden' name='hide_name' value='1') - h4.no-m-p Actions: + h4.no-m-p #{__('Actions')}: if board.settings.userPostDelete label input.post-check(type='checkbox', name='delete' value='1') @@ -29,4 +29,4 @@ details.toggle-label#actionform .actions h4.no-m-p Captcha: include ./captcha.pug - input(type='submit', value='Submit') + input(type='submit', value=__('Submit')) diff --git a/views/includes/actionfooter_globalmanage.pug b/views/includes/actionfooter_globalmanage.pug index 2e4023de..640ac8e8 100644 --- a/views/includes/actionfooter_globalmanage.pug +++ b/views/includes/actionfooter_globalmanage.pug @@ -1,7 +1,7 @@ details.toggle-label#actionform - summary.collapse#action-menu Show Post Actions + summary.collapse#action-menu #{__('Show Post Actions')} .actions - h4.no-m-p Actions: + h4.no-m-p #{__('Actions')}: label input.post-check(type='checkbox', name='delete' value='1') | Delete Posts @@ -50,4 +50,4 @@ details.toggle-label#actionform input(type='text', name='ban_duration', placeholder='Ban duration e.g. 7d' autocomplete='off') label input(type='text', name='log_message', placeholder='Modlog message' autocomplete='off') - input(type='submit', value='Submit') + input(type='submit', value=__('Submit')) diff --git a/views/includes/actionfooter_manage.pug b/views/includes/actionfooter_manage.pug index 79c7b697..90d10569 100644 --- a/views/includes/actionfooter_manage.pug +++ b/views/includes/actionfooter_manage.pug @@ -1,7 +1,7 @@ details.toggle-label#actionform - summary.collapse#action-menu Show Post Actions + summary.collapse#action-menu #{__('Show Post Actions')} .actions - h4.no-m-p Actions: + h4.no-m-p #{__('Actions')}: .row.wrap .col.mr-5 label @@ -87,4 +87,4 @@ details.toggle-label#actionform label input.post-check(type='checkbox', name='cyclic' value='1') | Toggle Cycle - input(type='submit', value='Submit') + input(type='submit', value=__('Submit')) diff --git a/views/includes/boardpages.pug b/views/includes/boardpages.pug index a27e47c1..66aa2957 100644 --- a/views/includes/boardpages.pug +++ b/views/includes/boardpages.pug @@ -1,4 +1,4 @@ -| Page: +| #{__('Page')}: if maxPage === 0 a.bold(href=`index.html`) [1] - for(let i = 1; i <= maxPage; i++) diff --git a/views/includes/captcha.pug b/views/includes/captcha.pug index 27a9f4a8..57c5d647 100644 --- a/views/includes/captcha.pug +++ b/views/includes/captcha.pug @@ -1,15 +1,15 @@ case captchaOptions.type when 'google' div(class='g-recaptcha' data-sitekey=`${googleRecaptchaSiteKey}` data-theme='dark' data-size='compact' data-callback='recaptchaCallback') - noscript Please enable JavaScript to solve the captcha. + noscript #{__('Please enable JavaScript to solve the captcha.')} when 'hcaptcha' div(class='h-captcha' data-sitekey=`${hcaptchaSiteKey}` data-theme='dark' data-size='compact' data-callback='recaptchaCallback') - noscript Please enable JavaScript to solve the captcha. + noscript #{__('Please enable JavaScript to solve the captcha.')} when 'text' noscript.no-m-p iframe.captcha(src='/captcha.html' 'width=210' height='80' scrolling='no' loading='lazy') .jsonly.captcha(style='display:none;') - input.captchafield(type='text' name='captcha' autocomplete='off' placeholder='Captcha text' pattern='.{6}' required title='6 characters') + input.captchafield(type='text' name='captcha' autocomplete='off' placeholder=__('Captcha text') pattern='.{6}' required title=__n('%s characters', 6)) when 'grid' when 'grid2' span.text-center #{captchaOptions.grid.question} diff --git a/views/includes/pages.pug b/views/includes/pages.pug index b368a439..a4204a7b 100644 --- a/views/includes/pages.pug +++ b/views/includes/pages.pug @@ -1,4 +1,4 @@ -| Page: +| #{__('Page')}: - const qs = queryString ? queryString+'&' : '' if maxPage === 0 a.bold(href=`?${qs}page=1`) [1] diff --git a/views/includes/postform.pug b/views/includes/postform.pug index 33b26cf8..1136344f 100644 --- a/views/includes/postform.pug +++ b/views/includes/postform.pug @@ -88,5 +88,5 @@ section.form-wrapper.flex-center include ./captchasidelabel.pug else include ./captchaexpand.pug - input#submitpost(type='submit', value=`New ${isThread ? 'Reply' : 'Thread'}`) + input#submitpost(type='submit', value=(isThread ? __('New Reply') : __('New Thread'))) a.collapse.no-decoration.post-button(href='#postform') [#{isThread ? __('New Reply') : __('New Reply')}] diff --git a/views/mixins/catalogtile.pug b/views/mixins/catalogtile.pug index f31fffc6..eb168c2c 100644 --- a/views/mixins/catalogtile.pug +++ b/views/mixins/catalogtile.pug @@ -39,19 +39,22 @@ mixin catalogtile(post, index, overboard=false) a.no-decoration.post-subject(href=postURL) #{post.subject || `#${post.postId}`} | select.jsonly.postmenu - option(value='single') Hide + option(value='single') #{__('Hide')} if post.subject - option(value='fsub') Filter Subject + option(value='fsub') #{__('Filter Subject')} + if (modview || manage || globalmanage) + option(value='edit') #{__('Edit')} if !overboard - option(value='moderate') Moderate - option(value='watch') Watch + option(value='moderate') #{__('Moderate')} + option(value='watch') #{__('Watch')} + option(value='playlist') #{__('Playlist')} br - span(title='Replies') R: #{post.replyposts} + span(title=__n('Replies', 2)) R: #{post.replyposts} | / - span(title='Files') F: #{post.replyfiles + post.files.length} + span(title=__n('Files', 2)) F: #{post.replyfiles + post.files.length} if !overboard | / - span(title='Page') P: #{Math.ceil(index/10)} + span(title=__('Page')) P: #{Math.ceil(index/10)} if post.files.length > 0 .col .row.ct-r1 diff --git a/views/mixins/post.pug b/views/mixins/post.pug index a1941c5d..7a27f7c7 100644 --- a/views/mixins/post.pug +++ b/views/mixins/post.pug @@ -67,22 +67,22 @@ mixin post(post, truncate, manage=false, globalmanage=false, ban=false, overboar | span.noselect: a(href=`${postURL}`) [Open] select.jsonly.postmenu - option(value='single') Hide + option(value='single') #{__('Hide')} if post.userId - option(value='fid') Filter ID + option(value='fid') #{__('Filter ID')} if post.name - option(value='fname') Filter Name + option(value='fname') #{__('Filter Name')} if post.subject - option(value='fsub') Filter Subject + option(value='fsub') #{__('Filter Subject')} if post.tripcode - option(value='ftrip') Filter Tripcode + option(value='ftrip') #{__('Filter Tripcode')} if !overboard && !ban - option(value='moderate') Moderate + option(value='moderate') #{__('Moderate')} if !ban && (modview || manage || globalmanage) - option(value='edit') Edit + option(value='edit') #{__('Edit')} if !post.thread - option(value='watch') Watch - option(value='playlist') Playlist + option(value='watch') #{__('Watch')} + option(value='playlist') #{__('Playlist')} .post-data if post.files.length > 0 .post-files(class=(post.files.length > 1 ? 'fn' : '')) diff --git a/views/mixins/threadwatcher.pug b/views/mixins/threadwatcher.pug index c8e92078..0bfd0299 100644 --- a/views/mixins/threadwatcher.pug +++ b/views/mixins/threadwatcher.pug @@ -1,5 +1,5 @@ mixin threadwatcher(minimised) .flex-center#threadwatcher(class=(minimised ? 'minimised' : '')) .row.noselect#threadwatcher-dragHandle - span.fw.text-center Thread Watcher + span.fw.text-center #{__('Thread Watcher')} span.mr-0.close #{minimised ? '[+]' : '[−]'} diff --git a/views/pages/catalog.pug b/views/pages/catalog.pug index aaf39632..a80b4310 100644 --- a/views/pages/catalog.pug +++ b/views/pages/catalog.pug @@ -22,18 +22,18 @@ block content .pages +boardnav('catalog', true, false) .pages.jsonly - input#catalogfilter(type='text' placeholder='Filter') + input#catalogfilter(type='text' placeholder=__('Filter')) select.ml-5.right#catalogsort - option(value="" disabled selected hidden) Sort by - option(value="bump") Bump order - option(value="date") Creation date - option(value="replies") Reply count + option(value="" disabled selected hidden) #{__('Sort By')} + option(value="bump") #{__('Bump Order')} + option(value="date") #{__('Creation Date')} + option(value="replies") #{__('Reply Count')} form(action=`/forms/board/${board._id}/${modview ? 'mod' : ''}actions` method='POST' enctype='application/x-www-form-urlencoded') if modview input(type='hidden' name='_csrf' value=csrf) hr(size=1) if threads.length === 0 - p No posts. + p #{__('No posts')} else .catalog for thread, i in threads diff --git a/views/pages/overboardcatalog.pug b/views/pages/overboardcatalog.pug index 97ab50f5..d6555dc2 100644 --- a/views/pages/overboardcatalog.pug +++ b/views/pages/overboardcatalog.pug @@ -20,12 +20,12 @@ block content include ../includes/stickynav.pug .wrapbar .pages.jsonly - input#catalogfilter(type='text' placeholder='Filter') + input#catalogfilter(type='text' placeholder=__('Filter')) select.ml-5.right#catalogsort - option(value="" disabled selected hidden) Sort by - option(value="bump") Bump order - option(value="date") Creation date - option(value="replies") Reply count + option(value="" disabled selected hidden) #{__('Sort By')} + option(value="bump") #{__('Bump Order')} + option(value="date") #{__('Creation Date')} + option(value="replies") #{__('Reply Count')} hr(size=1) if threads.length === 0 p No posts.