From 878499681eb658dfde8e81e80fdc89370dcfe4e9 Mon Sep 17 00:00:00 2001 From: tposejank <81495861+tposejank@users.noreply.github.com> Date: Wed, 4 Sep 2024 23:47:47 -0400 Subject: [PATCH] translate a bunch of stuff --- encore/index.html | 8 +- encore/js/songs.js | 6 +- encore/search/index.html | 4 + encore/search/js/find.js | 22 +-- encore/view/index.html | 4 + encore/view/js/song.js | 43 +++-- items/shop/index.html | 10 +- items/shop/js/item-shop.js | 2 +- items/view/index.html | 4 + items/view/js/item.js | 140 ++++++++------ js/script.js | 381 +++++++++++++++++++++++++++---------- 11 files changed, 419 insertions(+), 205 deletions(-) diff --git a/encore/index.html b/encore/index.html index dc63bf1..05c74cd 100644 --- a/encore/index.html +++ b/encore/index.html @@ -30,22 +30,24 @@ Encore
-

Search Tracks

+

Search Tracks

- +

-

All Charts

+

All Charts

diff --git a/encore/js/songs.js b/encore/js/songs.js index fc6eb94..f7871bf 100644 --- a/encore/js/songs.js +++ b/encore/js/songs.js @@ -27,7 +27,7 @@ async function extractFilesFromZip(data, rurl) { songAlbum.innerText = `${data.album != undefined ? data.album + ' - ' : ''}${toTimeStr(data.secs)}` let songCharters = document.createElement('h3') - songCharters.innerText = `Charters: ${data.charters.length > 0 ? data.charters.join(', ') : 'Unknown'}` + songCharters.innerText = `${getTranslationKey('encore-card:charters')}: ${data.charters.length > 0 ? data.charters.join(', ') : getTranslationKey('encore-card:charters-unknown')}` //console.log(piss) @@ -96,12 +96,12 @@ async function extractFilesFromZip(data, rurl) { let songDiffsView = document.createElement('a'); songDiffsView.classList.add('fortnite-button', 'fortnite-button-border', 'no-link', 'encore-override-fortnite-button', 'diffs-view', 'track-btn') - songDiffsView.innerText = 'View more' + songDiffsView.innerText = getTranslationKey('encore-card:view-more') songDiffsView.href = 'view/?' + data.id let downloadSong = document.createElement('a'); downloadSong.classList.add('fortnite-button', 'fortnite-button-border', 'no-link', 'encore-override-fortnite-button', 'track-btn') - downloadSong.innerText = 'Download' + downloadSong.innerText = getTranslationKey('encore-card:download') downloadSong.href = rurl + data.zip leftSection.append(document.createElement('hr'), songDiffs); diff --git a/encore/search/index.html b/encore/search/index.html index 6491f0d..637dccd 100644 --- a/encore/search/index.html +++ b/encore/search/index.html @@ -38,5 +38,9 @@

Results for

loadSongs() + + \ No newline at end of file diff --git a/encore/search/js/find.js b/encore/search/js/find.js index 1b82f9e..247a377 100644 --- a/encore/search/js/find.js +++ b/encore/search/js/find.js @@ -5,10 +5,6 @@ function toTimeStr(secs) { async function extractFilesFromZip(data, rurl) { //let zipUrl = data.zip; - let loading = document.createElement('p') - loading.innerText = 'Downloading ' + data.id + ', please wait...' - document.getElementById('songs').append(loading) - let imageUrl = 'https://raw.githubusercontent.com/FNLookup/encore/main/covers/'+data.id +'/'+data.art; let encoreTrack = document.createElement('a') encoreTrack.classList.add('encore-track', 'flex-media') @@ -27,7 +23,7 @@ async function extractFilesFromZip(data, rurl) { songAlbum.innerText = `${data.album != undefined ? data.album + ' - ' : ''}${toTimeStr(data.secs)}` let songCharters = document.createElement('h3') - songCharters.innerText = `Charters: ${data.charters.length > 0 ? data.charters.join(', ') : 'Unknown'}` + songCharters.innerText = `${getTranslationKey('encore-card:charters')}: ${data.charters.length > 0 ? data.charters.join(', ') : getTranslationKey('encore-card:charters-unknown')}` //console.log(piss) @@ -44,10 +40,10 @@ async function extractFilesFromZip(data, rurl) { if (diff == 'ba' || diff == 'bass') icon = 'bass.webp' if (diff == 'vl' || diff == 'vocals') icon = 'voices.webp' if (diff == 'gr' || diff == 'guitar') icon = 'guitar.webp' - if (diff == 'plastic_drums') icon = 'pro-drums.png' - if (diff == 'plastic_bass') icon = 'pro-bass.png' - if (diff == 'plastic_guitar') icon = 'pro-guitar.png' - if (diff == 'plastic_vocals' || diff=='pitched_vocals') icon = 'THEvoicesARELOUDER.png' + if (diff == 'plastic_drums') icon = 'encore/pdrums.webp' + if (diff == 'plastic_bass') icon = 'encore/pbass.webp' + if (diff == 'plastic_guitar') icon = 'encore/ptar.webp' + if (diff == 'plastic_vocals' || diff=='pitched_vocals') icon = 'encore/pvox.webp' let imageIcon = document.createElement('img') imageIcon.classList.add('instrument-icon-encore') @@ -96,12 +92,12 @@ async function extractFilesFromZip(data, rurl) { let songDiffsView = document.createElement('a'); songDiffsView.classList.add('fortnite-button', 'fortnite-button-border', 'no-link', 'encore-override-fortnite-button', 'diffs-view', 'track-btn') - songDiffsView.innerText = 'View more' + songDiffsView.innerText = getTranslationKey('encore-card:view-more') songDiffsView.href = '/encore/view/?' + data.id let downloadSong = document.createElement('a'); downloadSong.classList.add('fortnite-button', 'fortnite-button-border', 'no-link', 'encore-override-fortnite-button', 'track-btn') - downloadSong.innerText = 'Download' + downloadSong.innerText = getTranslationKey('encore-card:download') downloadSong.href = rurl + data.zip leftSection.append(document.createElement('hr'), songDiffs); @@ -111,8 +107,6 @@ async function extractFilesFromZip(data, rurl) { //encoreTrack.append(rightSection, imgElement2); document.getElementById('songs').appendChild(encoreTrack); - - loading.remove() } function loadSongs() { @@ -131,7 +125,7 @@ function loadSongs() { } } - if (totalresults < 1) document.getElementById('resultsfor').innerText = 'Your search did not have any results.' + if (totalresults < 1) document.getElementById('resultsfor').innerText = getTranslationKey('encore:search-no-results') }).catch(err => { console.error(err) }) diff --git a/encore/view/index.html b/encore/view/index.html index 209a09e..c49b185 100644 --- a/encore/view/index.html +++ b/encore/view/index.html @@ -38,6 +38,10 @@ loadSong() + + \ No newline at end of file diff --git a/encore/view/js/song.js b/encore/view/js/song.js index 0b06df0..d7756c5 100644 --- a/encore/view/js/song.js +++ b/encore/view/js/song.js @@ -8,7 +8,7 @@ function loadSong() { async function extractFilesFromZip(data) { let loading = document.createElement('p') - loading.innerText = 'Downloading ' + data.song.zip + ', please wait...' + loading.innerText = getTranslationKey('encore-chart:downloading').replace('[x0]', data.song.zip) document.getElementById('song').append(loading) let zipUrl = data.song.zip; @@ -56,18 +56,21 @@ function loadSong() { songAlbum.innerText = `${data.song.album != undefined ? data.song.album + ' - ' : ''}${toTimeStr(data.song.secs)}` let songCharter = document.createElement('h3') - songCharter.innerText = `Charters: ${data.song.charters.length > 0 ? data.song.charters.join(', ') : 'Unknown'}` + songCharter.innerText = `${getTranslationKey('encore-chart:charters')}: ${data.song.charters.length > 0 ? data.song.charters.join(', ') : getTranslationKey('encore-chart:charters-unknown')}` document.title = info.title + ' (Encore) - FNLookup' let songGenre = document.createElement('h3') - let genrestr = 'Genres: Unknown' + let genrestr = getTranslationKey('encore-chart:genres') + ': ' + getTranslationKey('encore-chart:genres-unknown') if (info.genres != undefined) { - genrestr = 'Genres: ' + info.genres.join(', ') + ' - ' + info.release_year + genrestr = getTranslationKey('encore-chart:genres') + ': ' + info.genres.join(', ') } songGenre.innerText = genrestr + let songYear = document.createElement('h3') + songYear.innerText = getTranslationKey('encore-chart:release-year') + ': ' + info.release_year + let songDiffs = document.createElement('a') songDiffs.classList.add('song-diffs'); for (let diff of Object.keys(data.song.diffs)) @@ -81,10 +84,10 @@ function loadSong() { if (diff == 'ba' || diff == 'bass') icon = 'bass.webp' if (diff == 'vl' || diff == 'vocals') icon = 'voices.webp' if (diff == 'gr' || diff == 'guitar') icon = 'guitar.webp' - if (diff == 'plastic_drums') icon = 'pro-drums.png' - if (diff == 'plastic_bass') icon = 'pro-bass.png' - if (diff == 'plastic_guitar') icon = 'pro-guitar.png' - if (diff == 'plastic_vocals' || diff=='pitched_vocals') icon = 'THEvoicesARELOUDER.png' + if (diff == 'plastic_drums') icon = 'encore/pdrums.webp' + if (diff == 'plastic_bass') icon = 'encore/pbass.webp' + if (diff == 'plastic_guitar') icon = 'encore/ptar.webp' + if (diff == 'plastic_vocals' || diff=='pitched_vocals') icon = 'encore/pvox.webp' let imageIcon = document.createElement('img') imageIcon.classList.add('instrument-icon-encore') @@ -114,7 +117,7 @@ function loadSong() { songDiffs.append(diffContainer) } - trackDetails.append(songTitle, songArtist, songAlbum, songCharter, songGenre, document.createElement('hr'), songDiffs) + trackDetails.append(songTitle, songArtist, songAlbum, songCharter, songGenre, songYear, document.createElement('hr'), songDiffs) encoreTrack.append(trackDetails) document.getElementById('song').appendChild(encoreTrack); @@ -139,13 +142,13 @@ function loadSong() { } let tracks = { - 'Drums': 'PART DRUMS', - 'Bass': 'PART BASS', - 'Guitar': 'PART GUITAR', - 'Vocals': 'PART VOCALS', - 'Pro Drums': 'PLASTIC DRUMS', - 'Pro Bass': 'PLASTIC BASS', - 'Pro Guitar': 'PLASTIC GUITAR' + 'instruments:drums': 'PART DRUMS', + 'instruments:bass': 'PART BASS', + 'instruments:guitar': 'PART GUITAR', + 'instruments:vocals': 'PART VOCALS', + 'instruments:prodrums': 'PLASTIC DRUMS', + 'instruments:probass': 'PLASTIC BASS', + 'instruments:proguitar': 'PLASTIC GUITAR' } let difficulties = { @@ -158,7 +161,7 @@ function loadSong() { let trackAnalysisTable = document.createElement('track-midi-notes') tablefullhtml = ` - + @@ -170,7 +173,7 @@ function loadSong() { // trackAnalysisName.innerText = track let tablehtml = ` - ` + ` let trackNotes = document.createElement('div') @@ -199,12 +202,12 @@ function loadSong() { let downloadButton = document.createElement('a') downloadButton.classList.add('fortnite-button', 'fortnite-button-border', 'no-link', 'encore-download') - downloadButton.innerText = 'Download Chart' + downloadButton.innerText = getTranslationKey('encore-chart:download-chart') let mbsize = size / 1024 / 1024 let mbs = mbsize.toFixed(2) - downloadButton.title = 'Size: ' + mbs + ' MB' + downloadButton.title = getTranslationKey('encore-chart:size').replace('[x0]', mbs + ' MB') downloadButton.href = data.raw + zipUrl diff --git a/items/shop/index.html b/items/shop/index.html index d1c61dd..93061db 100644 --- a/items/shop/index.html +++ b/items/shop/index.html @@ -34,7 +34,7 @@
-

ITEM SHOP

+

ITEM SHOP

@@ -63,7 +63,11 @@

ITEM SHOP

} - BACK TO TOP + BACK TO TOP + +
diff --git a/items/shop/js/item-shop.js b/items/shop/js/item-shop.js index af9c5f4..ea3d21d 100644 --- a/items/shop/js/item-shop.js +++ b/items/shop/js/item-shop.js @@ -494,7 +494,7 @@ function makeShopCard(item) { } img_obj.src = img_src; - img_obj.setAttribute("title", item.displayName + ' for ' + item.price.finalPrice + ' V-Bucks'); + img_obj.setAttribute("title", getTranslationKey('shop:tooltip').replace('[x0]', item.displayName).replace('[x1]', item.price.finalPrice)); img_obj.setAttribute('otype', item.mainType); img_obj.classList.add("shop-picture"); diff --git a/items/view/index.html b/items/view/index.html index f2bca76..8de72bc 100644 --- a/items/view/index.html +++ b/items/view/index.html @@ -32,6 +32,10 @@ init()
+ + \ No newline at end of file diff --git a/items/view/js/item.js b/items/view/js/item.js index d2976c6..e14c176 100644 --- a/items/view/js/item.js +++ b/items/view/js/item.js @@ -11,7 +11,7 @@ function init() { } let loading = document.getElementById('loading') - loading.innerHTML = '

Please wait...

Searching for ' + itemID + '

'; + loading.innerHTML = `

${getTranslationKey('item:please-wait')}

${getTranslationKey('item:searching-for').replace('[x0]', itemID)}

`; let requestData = getRequestData('item&id=' + itemID); fetch(requestData.url, requestData.data).then(data => data.json()).then(data => { @@ -21,6 +21,14 @@ function init() { let item = data.item; + if (item == null) { + let eText = document.createElement('h1'); + eText.classList.add('header-text-bold') + eText.innerText = getTranslationKey('item:not-found'); + content.append(eText); + return; + } + if (item.type.id == 'sparks_song') { console.log('this is a jamtrack. redirecting you'); window.location.href = '/festival/view/?' + item.id; @@ -125,33 +133,6 @@ function init() { //we need the english name tho FNAPICOMDATA = undefined - fetch('https://fortnite-api.com/v2/cosmetics/br/' + item.id).then(data => data.json()).then(data => { - // console.log(data); - FNAPICOMDATA = data - const hasFNGG = Items.some(item => item.name === data.data.name); - // console.log(hasFNGG) - if (hasFNGG) { - fnggItem = Items.find(item => item.name === data.data.name); - // console.log(fnggItem) - let vidURL = 'https://fnggcdn.com/items-download/' + fnggItem.id + '/video.mp4?2' // apparently built in transform emote videos with ?2 make them both sides - if (item.type.id == 'music') { - vidURL = 'https://fortnite.gg/img/items/' + fnggItem.id + '/audio.mp3?1' - } - - imageSources.splice(1, 0, vidURL) - - // demoVideo.onerror = function() { - // //demoVideo.remove(); - // //videoContainer.remove(); - // console.log("VIDEO ERROR!") - // }; - } - - fortNut() - }).catch(e => { //Even if the fortnite-api.com doesnt have it - fortNut() - }) - function fortNut() { for (let img of imageSources) { if (img.includes('video.mp4')) { @@ -219,6 +200,33 @@ function init() { } } + fetch('https://fortnite-api.com/v2/cosmetics/br/' + item.id).then(data => data.json()).then(data => { + // console.log(data); + FNAPICOMDATA = data + const hasFNGG = Items.some(item => item.name === data.data.name); + // console.log(hasFNGG) + if (hasFNGG) { + fnggItem = Items.find(item => item.name === data.data.name); + // console.log(fnggItem) + let vidURL = 'https://fnggcdn.com/items-download/' + fnggItem.id + '/video.mp4?2' // apparently built in transform emote videos with ?2 make them both sides + if (item.type.id == 'music') { + vidURL = 'https://fortnite.gg/img/items/' + fnggItem.id + '/audio.mp3?1' + } + + imageSources.splice(1, 0, vidURL) + + // demoVideo.onerror = function() { + // //demoVideo.remove(); + // //videoContainer.remove(); + // console.log("VIDEO ERROR!") + // }; + } + + fortNut() + }).catch(e => { //Even if the fortnite-api.com doesnt have it + fortNut() + }) + left.append(carrousel) // end of image part @@ -239,7 +247,7 @@ function init() { if (item.type != null) { let item_type = document.createElement('a'); item_type.classList.add('item-type-label'); - item_type.innerHTML = item.type.name; + item_type.innerText = item.type.name; tags.appendChild(item_type); } @@ -247,14 +255,14 @@ function init() { let rarity = document.createElement('a'); rarity.classList.add('rarity-label'); rarity.setAttribute('data-rarity', item.rarity.id.toLowerCase()); - rarity.innerHTML = item.rarity.name; + rarity.innerText = item.rarity.name; tags.appendChild(rarity); if (item.series != null) { let series = document.createElement('a'); series.classList.add('rarity-label'); series.setAttribute('data-rarity', item.series.id.toLowerCase()); - series.innerHTML = item.series.name; + series.innerText = item.series.name; tags.appendChild(series); } } @@ -262,14 +270,14 @@ function init() { if (item.copyrightedAudio) { let caudio = document.createElement('a'); caudio.classList.add('item-type-label', 'copyrighted-audio-warning'); - caudio.innerHTML = 'Copyrighted Audio'; + caudio.innerText = getTranslationKey('item:copyright'); tags.appendChild(caudio); } if (item.reactive) { let remodal = document.createElement('a'); remodal.classList.add('item-type-label'); - remodal.innerHTML = 'Reactive'; + remodal.innerText = getTranslationKey('item:reactive'); tags.appendChild(remodal); } @@ -286,7 +294,7 @@ function init() { if (item.upcoming) { let item_type = document.createElement('a'); item_type.classList.add('item-type-label', 'upcoming-notice'); - item_type.innerHTML = 'Upcoming'; + item_type.innerText = getTranslationKey('item:upcoming'); tags.appendChild(item_type); } @@ -294,21 +302,20 @@ function init() { if (item.description !== null) { let description = document.createElement('h2'); - description.innerHTML = item.description; + description.innerText = item.description; right.append(description); } if (item.battlepass != null) { let pass = document.createElement('a'); let bp = item.battlepass; - pass.innerHTML = bp.displayText.chapterSeason + ': ' + bp.battlePassName + (bp.page !== null ? ' - ' + bp.page : '') + ' (' + bp.type + ')'; + pass.innerText = bp.displayText.chapterSeason + ': ' + bp.battlePassName + (bp.page !== null ? ' - ' + bp.page : '') + ' (' + bp.type + ')'; right.appendChild(pass); } if (item.introduction !== null) { let introduction = document.createElement('h3'); - introduction.innerHTML = item.introduction.text; - introduction.title = 'Introduced in Season ' + item.introduction.backendValue; + introduction.innerText = item.introduction.text; right.append(introduction); } @@ -321,19 +328,19 @@ function init() { if (item.releaseDate != null) { let release = document.createElement('p'); - release.innerHTML = 'Released ' + getFormatDate(new Date(item.releaseDate), true); + release.innerText = getTranslationKey('item:released').replace('[x0]', getFormatDate(new Date(item.releaseDate), true)); right.appendChild(release); } if (item.lastAppearance != null) { let lastSeen = document.createElement('p'); - lastSeen.innerHTML = 'Last time seen ' + getFormatDate(new Date(item.lastAppearance), true, true).toLowerCase(); + lastSeen.innerHTML = getTranslationKey('item:last-time-seen').replace('[x0]', getFormatDate(new Date(item.lastAppearance), true, true).toLowerCase()) right.appendChild(lastSeen); } if (item.shopHistory !== null) { let ocurrences = document.createElement('p'); - ocurrences.innerHTML = 'Seen ' + item.shopHistory.length + ' times'; + ocurrences.innerHTML = getTranslationKey('item:seen').replace('[x0]', item.shopHistory.length) right.appendChild(ocurrences); let hlist = document.createElement('div'); @@ -345,8 +352,8 @@ function init() { tableHeader.classList.add('flex'); leftRow.classList.add('d-70'); rightRow.classList.add('d-30', 'flex', 'flex-center', 'flex-hcenter'); - leftRow.innerHTML = '

Date

'; - rightRow.innerHTML = '

Days Since

'; + leftRow.innerHTML = `

${getTranslationKey('item:table-date')}

`; + rightRow.innerHTML = `

${getTranslationKey('item:table-days-since')}

`; tableHeader.append(leftRow, rightRow); hlist.append(tableHeader); @@ -378,7 +385,7 @@ function init() { let ds = gne('a'); ds.innerText = rSince; - if (dsince == 0) ds.innerHTML = 'Today'; + if (dsince == 0) ds.innerHTML = `${getTranslationKey('common:today')}`; right.append(ds); @@ -399,7 +406,7 @@ function init() { if (item.shopHistory.length > 1) { let avgWaitPerA = document.createElement('p'); - avgWaitPerA.innerHTML = 'Mean wait: ' + avg + 'd'; + avgWaitPerA.innerHTML = getTranslationKey('item:wait').replace('[x0]', avg.toFixed(2)) ; right.append(avgWaitPerA); } } @@ -416,7 +423,7 @@ function init() { if (item.gameplayTags.length > 0) { let gt = document.createElement('p'); - gt.innerHTML = 'Gameplay Tags'; + gt.innerText = getTranslationKey('item:gameplay-tags'); right.append(gt); let gtcode = document.createElement('div'); @@ -431,7 +438,7 @@ function init() { } if (item.audio !== null) { - right.innerHTML += '

Listen

'; + right.innerHTML += `

${getTranslationKey('item:listen')}

`; let audio = gne('audio'); audio.controls = true; @@ -463,7 +470,7 @@ function init() { bottom.append(styleContainer); let parttitle = document.createElement('h1'); - parttitle.innerHTML = 'Styles'; + parttitle.innerText = getTranslationKey('item:styles'); styleContainer.append(parttitle); let rStyleTabs = []; @@ -585,7 +592,7 @@ function init() { if (item.grants.length > 0) { let title = gne('h1'); - title.innerHTML = 'This item includes'; + title.innerText = getTranslationKey('item:includes') bottom1.append(title); let grantModal = document.createElement('div'); @@ -615,7 +622,7 @@ function init() { if (item.grantedBy.length > 0) { let title = gne('h1'); - title.innerHTML = 'Granted by'; + title.innerText = getTranslationKey('item:granted'); bottom2.append(title); let grantModal = document.createElement('div'); @@ -631,7 +638,7 @@ function init() { let image = document.createElement('img'); image.src = granted.images.icon + '?width=100'; image.title = granted.name; - parent.innerHTML = granted.name; + parent.innerText = granted.name; parent.append(image); parent.href = getItemLinkByID(granted.id) @@ -644,7 +651,7 @@ function init() { let emote = item.builtInEmote; let title = gne('h1'); - title.innerHTML = 'Built-In Emote'; + title.innerText = getTranslationKey('item:builtin'); bottom2.append(title); let grantModal = document.createElement('div'); @@ -659,7 +666,7 @@ function init() { let image = document.createElement('img'); image.src = emote.images.icon + '?width=100'; image.title = emote.name; - parent.innerHTML = emote.name; + parent.innerText = emote.name; parent.append(image); parent.href = getItemLinkByID(emote.id) grantModal.append(parent); @@ -667,7 +674,7 @@ function init() { if (setItems.length > 0) { let title = gne('h1'); - title.innerHTML = item.set.partOf; + title.innerText = item.set.partOf; bottom2.append(title); let grantModal = document.createElement('div'); @@ -683,7 +690,7 @@ function init() { let image = document.createElement('img'); image.src = setItem.images.icon + '?width=100'; image.title = setItem.name; - parent.innerHTML = setItem.name; + parent.innerText = setItem.name; parent.append(image); parent.href = getItemLinkByID(setItem.id) @@ -763,8 +770,16 @@ function init() { clearChildren(content); let eText = document.createElement('h1'); - eText.innerHTML = 'No cosmetics were found, or an error has occurred.
' + err; + eText.classList.add('header-text-bold') + + let eText2 = document.createElement('h2'); + eText2.classList.add('header-text-light') + + eText2.innerText = err + eText.innerText = getTranslationKey('item:not-found-or-error'); + let tipText = document.createElement('h3'); + tipText.classList.add('header-text-bold') let value = '' if (params.has('q')) value = params.get('q'); @@ -772,16 +787,17 @@ function init() { console.error(err) - - tipText.innerHTML = 'Are you looking for a cosmetic you don\'t know the name of? Go to cosmetic search and try again.'; - content.append(eText, tipText); + tipText.innerHTML = getTranslationKey('item:help-search').replace('[x0]', '' + getTranslationKey('item:search-page') + ''); + content.append(eText, eText2, tipText); }) } else { let eText = document.createElement('h1'); - eText.innerHTML = 'Looks like you specified no parameters!'; + eText.classList.add('header-text-bold') + eText.innerText = getTranslationKey('item:no-params'); let tipText = document.createElement('h3'); - tipText.innerHTML = 'It looks like you\'re looking for no items. Use the search bar to view one, or click on one somewhere else.'; + tipText.innerText = getTranslationKey('item:no-params-help'); + tipText.classList.add('header-text-bold') document.getElementById('page-content').append(eText, tipText); - document.getElementById('page-content').innerHTML += 'Take me home ' + document.getElementById('page-content').innerHTML += '' + getTranslationKey('item:take-me-home') + ' ' } } \ No newline at end of file diff --git a/js/script.js b/js/script.js index c90595e..6c5918a 100644 --- a/js/script.js +++ b/js/script.js @@ -139,102 +139,267 @@ function initializeNav() { ]; window.uiLangList = languages; } +translations = { + "en": { + "home:welcome_back": "Welcome Back", + "home:your_ranked_stats": "Your Ranked Stats", + "home:br": "Battle Royale", + "home:zb": "Zero Build", + "home:rr": "Ranked Racing", + + "home:not_linked": "You haven't linked an account yet.", + "home:link_account": "Link your account", + + "nav:account": "ACCOUNT", + "nav:items": "ITEMS", + "nav:item-shop": "SHOP", + "nav:battle-pass": "BATTLE PASS", + "nav:quests": "QUESTS", + "nav:compete": "COMPETE", + "nav:stats": "STATS", + + "navigation:home": "HOME", + "navigation:back": "BACK", + "navigation:broadcast": "BROADCAST", + "navigation:notifications": "NOTIFICATIONS", + + "account:navigation_bar": "ACCOUNT", + "account:page_name": "Account", + "account:page": "Link or view your accounts", + "account:current_account": "Current Account", + "account:link_button": "LINK", + "account:switch_button": "SWITCH ACCOUNT", + "account:language": "Language", + "account:change_language": "CHANGE LANGUAGE", + "account:about_fnlookup": "About FNLookup", + "account:about": "VIEW", + "account:not_linked": "You haven't linked an account yet.", + + "account_change:your_accounts": "Your accounts", + "account_change:add_another": "Add new account", + "account_change:search": "Search", + "account_change:reset_your_accounts": "Reset your accounts", + "account_change:link_new": "Link your account", + + "language:language": "Language", + "language:desc": "Change the display language.", + + "common:today": "today", + "common:today-upper": "Today", + "common:date-format": "[x0], [x1] [x2], [x3]", + "common:date-format-no-year": "[x0], [x1] [x2]", + "common:monday": "Monday", + "common:tuesday": "Tuesday", + "common:wednesday": "Wednesday", + "common:thursday": "Thursday", + "common:friday": "Friday", + "common:saturday": "Saturday", + "common:sunday": "Sunday", + "common:january": "jan", + "common:february": "feb", + "common:march": "mar", + "common:april": "apr", + "common:may": "may", + "common:june": "jun", + "common:july": "jul", + "common:august": "aug", + "common:september": "sep", + "common:october": "oct", + "common:november": "nov", + "common:december": "dec", + + "item:please-wait": "Please wait...", + "item:searching-for": "Searching for [x0]", + "item:released": "Released [x0]", + "item:last-time-seen": "Last time seen [x0]", + "item:seen": "Seen [x0] times", + "item:wait": "Mean wait: [x0]d", + "item:table-date": "Date", + "item:table-days-since": "Days Since", + "item:styles": "Styles", + "item:gameplay-tags": "Gameplay Tags", + "item:upcoming": "Upcoming", + "item:copyright": "Copyrighted Audio", + "item:reactive": "Reactive", + "item:includes": "This item includes", + "item:listen": "Listen", + "item:granted": "Granted by", + "item:builtin": "Built-In Emote", + "item:not-found": "No items were found.", + "item:not-found-or-error": "No items were found, or there was an error.", + "item:help-search": "Are you looking for a cosmetic you don't know the name of? Go to [x0] and try again.", + "item:search-page": "items", + "item:no-params": "Looks like you specified no parameters!", + "item:no-params-help": "It looks like you're looking for no items. Use search to view one, or click on one somewhere else.", + "item:take-me-home": "Take me home", + + "shop:item-shop": "ITEM SHOP", + "shop:jump": "JUMP TO CATEGORY", + "shop:back": "BACK TO TOP", + "shop:tooltip": "[x0] for [x1] V-Bucks", + + "instruments:drums": "Drums", + "instruments:vocals": "Vocals", + "instruments:guitar": "Guitar", + "instruments:bass": "Bass", + "instruments:probass": "Pro Bass", + "instruments:proguitar": "Pro Guitar", + "instruments:prodrums": "Pro Drums", + + "encore:all-charts": "All Charts", + "encore:search-charts": "Search Charts", + "encore:search": "Search", + "encore-card:view-more": "View more", + "encore-card:download": "Download", + "encore-card:charters": "Charters", + "encore-card:charters-unknown": "Unknown", + "encore:search-no-results": "Your search did not have any results.", + + "encore-chart:downloading": "Downloading [x0], please wait...", + "encore-chart:download-chart": "Download Chart", + "encore-chart:charters": "Charters", + "encore-chart:charters-unknown": "Unknown", + "encore-chart:size": "Size: [x0]", + "encore-chart:genres": "Genres", + "encore-chart:genres-unknown": "Unknown", + "encore-chart:release-year": "Year", + "encore-chart:instrument": "Instrument" + }, + "es-419": { + "home:welcome_back": "Bienvenido de vuelta", + "home:your_ranked_stats": "Tus estadísticas en Ranked", + "home:br": "Battle Royale", + "home:zb": "Sin construcción", + "home:rr": "Ranked Racing", + + "home:not_linked": "Aún no has vinculado una cuenta.", + "home:link_account": "Vincula tu cuenta", + + "nav:account": "CUENTA", + "nav:items": "OBJETOS", + "nav:item-shop": "TIENDA", + "nav:battle-pass": "PASE DE BATALLA", + "nav:quests": "MISIONES", + "nav:compete": "COMPETIR", + "nav:stats": "ESTADISTICAS", + + "navigation:home": "INICIO", + "navigation:back": "ATRAS", + "navigation:broadcast": "BROADCAST", + "navigation:notifications": "NOTIFICACIONES", + + "account:navigation_bar": "CUENTA", + "account:page_name": "Cuenta", + "account:page": "Vincular o ver tus cuentas", + "account:current_account": "CUENTA PRINCIPAL", + "account:link_button": "VINCULAR", + "account:switch_button": "CAMBIAR CUENTA", + "account:language": "Idioma", + "account:change_language": "CAMBIAR IDIOMA", + "account:about_fnlookup": "Sobre FNLookup", + "account:about": "VER", + "account:not_linked": "Aún no has vinculado una cuenta.", + + "account_change:link_new": "Vincula tu cuenta", + "account_change:your_accounts": "Tus cuentas", + "account_change:add_another": "Añadir nueva cuenta", + "account_change:search": "Buscar", + "account_change:reset_your_accounts": "Restablecer tus cuentas", + + "language:language": "Idioma", + "language:desc": "Cambia el idioma de visualización.", + + "common:today": "hoy", + "common:today-upper": "Hoy", + "common:date-format": "[x0], [x2] de [x1] del [x3]", + "common:date-format-no-year": "[x0], [x2] de [x1]", + "common:monday": "Lunes", + "common:tuesday": "Martes", + "common:wednesday": "Miércoles", + "common:thursday": "Jueves", + "common:friday": "Viernes", + "common:saturday": "Sábado", + "common:sunday": "Domingo", + "common:january": "ene", + "common:february": "feb", + "common:march": "mar", + "common:april": "abr", + "common:may": "may", + "common:june": "jun", + "common:july": "jul", + "common:august": "ago", + "common:september": "sep", + "common:october": "oct", + "common:november": "nov", + "common:december": "dec", + + "item:please-wait": "Por favor espere...", + "item:searching-for": "Buscando [x0]", + "item:released": "Lanzamiento: [x0]", + "item:last-time-seen": "Última vez visto [x0]", + "item:seen": "Visto [x0] veces", + "item:wait": "Espera promedio: [x0]d", + "item:table-date": "Fecha", + "item:table-days-since": "Tiempo", + "item:styles": "Estilos", + "item:gameplay-tags": "Etiquétas", + "item:upcoming": "Proximamente", + "item:copyright": "Audio con derechos de autor", + "item:reactive": "Reactivo", + "item:includes": "Este objeto incluye", + "item:listen": "Escuchar", + "item:granted": "Dado por", + "item:builtin": "Gesto Integrado", + "item:not-found": "No se encontraron objetos.", + "item:not-found-or-error": "No se encontraron objetos, o hubo un error.", + "item:help-search": "¿Estás buscando el nombre de un objeto del cuál no conoces su nombre? Ve a [x0] e intenta denuevo.", + "item:search-page": "objetos", + "item:no-params": "¡Parece que aquí no hay parametros!", + "item:no-params-help": "Parece que no estas buscando ningún objeto. Usa objetos para ver uno, o haz clic en uno en otro lugar.", + "item:take-me-home": "Llévame al inicio", + + "shop:item-shop": "TIENDA DE OBJETOS", + "shop:jump": "SALTAR A CATEGORÍA", + "shop:back": "VOLVER AL INÍCIO", + "shop:tooltip": "[x0] por [x1] monedas V", // es = pavos + + "instruments:drums": "Percusión", + "instruments:vocals": "Voz", + "instruments:guitar": "Guitarra", + "instruments:bass": "Bajo", + "instruments:probass": "Bajo Pro", + "instruments:proguitar": "Guitarra Pro", + "instruments:prodrums": "Percusión Pro", + + "encore:all-charts": "Charts de Encore", + "encore:search-charts": "Buscar Charts", + "encore:search": "Buscar", + "encore-card:view-more": "Ver más", + "encore-card:download": "Descargar", + "encore-card:charters": "Autores", + "encore-card:charters-unknown": "Desconocidos", + + "encore:search-no-results": "Tu búsqueda no dió resultados.", + "encore-chart:downloading": "Descargando [x0], por favor espere...", + "encore-chart:download-chart": "Descargar Chart", + "encore-chart:charters": "Autores", + "encore-chart:charters-unknown": "Desconocidos", + "encore-chart:size": "Tamaño: [x0]", + "encore-chart:genres": "Géneros", + "encore-chart:genres-unknown": "Desconocidos", + "encore-chart:release-year": "Año", + "encore-chart:instrument": "Instrumento" + }, +} function getTranslationKey(key) { - let translations = { - "en": { - "home:welcome_back": "Welcome Back", - "home:your_ranked_stats": "Your Ranked Stats", - "home:br": "Battle Royale", - "home:zb": "Zero Build", - "home:rr": "Ranked Racing", - - "home:not_linked": "You haven't linked an account yet.", - "home:link_account": "Link your account", - - "nav:account": "ACCOUNT", - "nav:items": "ITEMS", - "nav:item-shop": "SHOP", - "nav:battle-pass": "BATTLE PASS", - "nav:quests": "QUESTS", - "nav:compete": "COMPETE", - "nav:stats": "STATS", - - "navigation:home": "HOME", - "navigation:back": "BACK", - "navigation:broadcast": "BROADCAST", - "navigation:notifications": "NOTIFICATIONS", - - "account:navigation_bar": "ACCOUNT", - "account:page_name": "Account", - "account:page": "Link or view your accounts", - "account:current_account": "Current Account", - "account:link_button": "LINK", - "account:switch_button": "SWITCH ACCOUNT", - "account:language": "Language", - "account:change_language": "CHANGE LANGUAGE", - "account:about_fnlookup": "About FNLookup", - "account:about": "VIEW", - "account:not_linked": "You haven't linked an account yet.", - - "account_change:your_accounts": "Your accounts", - "account_change:add_another": "Add new account", - "account_change:search": "Search", - "account_change:reset_your_accounts": "Reset your accounts", - "account_change:link_new": "Link your account", - - "language:language": "Language", - "language:desc": "Change the display language." - }, - "es-419": { - "home:welcome_back": "Bienvenido de vuelta", - "home:your_ranked_stats": "Tus estadísticas en Ranked", - "home:br": "Battle Royale", - "home:zb": "Sin construcción", - "home:rr": "Ranked Racing", - - "home:not_linked": "Aún no has vinculado una cuenta.", - "home:link_account": "Vincula tu cuenta", - - "nav:account": "CUENTA", - "nav:items": "OBJETOS", - "nav:item-shop": "TIENDA", - "nav:battle-pass": "PASE DE BATALLA", - "nav:quests": "MISIONES", - "nav:compete": "COMPETIR", - "nav:stats": "ESTADISTICAS", - - "navigation:home": "INICIO", - "navigation:back": "ATRAS", - "navigation:broadcast": "BROADCAST", - "navigation:notifications": "NOTIFICACIONES", - - "account:navigation_bar": "CUENTA", - "account:page_name": "Cuenta", - "account:page": "Vincular o ver tus cuentas", - "account:current_account": "CUENTA PRINCIPAL", - "account:link_button": "VINCULAR", - "account:switch_button": "CAMBIAR CUENTA", - "account:language": "Idioma", - "account:change_language": "CAMBIAR IDIOMA", - "account:about_fnlookup": "Sobre FNLookup", - "account:about": "VER", - "account:not_linked": "Aún no has vinculado una cuenta.", - - "account_change:link_new": "Vincula tu cuenta", - "account_change:your_accounts": "Tus cuentas", - "account_change:add_another": "Añadir nueva cuenta", - "account_change:search": "Buscar", - "account_change:reset_your_accounts": "Restablecer tus cuentas", - - "language:language": "Idioma", - "language:desc": "Cambia el idioma de visualización." - }, - } - let lang = localStorage.requestLanguage if (lang === 'es') lang = 'es-419' // Perdon espanioles oleEEEE - return translations[lang][key] + if (Object.keys(translations).includes(lang)) { + return translations[lang][key] + } else { + return translations['en'][key] + } } function callTranslate() { @@ -288,19 +453,34 @@ function sameDayUTC(day, now) { function getFormatDate(date, relative = false, justToday = false) { if (!relative) { - var weekDays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; - var months = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]; + var weekDaysIDs = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']; + var monthsIDs = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"]; + let weekDays = [] + let months = [] + for (let day of weekDaysIDs) { + weekDays.push(getTranslationKey('common:' + day)) + } + for (let month of monthsIDs) { + months.push(getTranslationKey('common:' + month)) + } var currentDate = new Date(); var currentYear = currentDate.getUTCFullYear(); var currentMonth = currentDate.getUTCMonth(); var currentDay = currentDate.getUTCDate(); if (date.getUTCFullYear() === currentYear && date.getUTCMonth() === currentMonth && date.getUTCDate() === currentDay && justToday) { - return "Today"; + return getTranslationKey('common:today'); } else if (date.getUTCFullYear() === currentYear) { - return weekDays[date.getUTCDay()] + ', ' + months[date.getUTCMonth()] + ' ' + date.getUTCDate(); + return getTranslationKey('common:date-format-no-year') + .replace('[x0]', weekDays[date.getUTCDay()]) + .replace('[x1]', months[date.getUTCMonth()]) + .replace('[x2]', date.getUTCDate()) } else { - return weekDays[date.getUTCDay()] + ', ' + months[date.getUTCMonth()] + ' ' + date.getUTCDate() + ', ' + date.getUTCFullYear(); + return getTranslationKey('common:date-format') + .replace('[x0]', weekDays[date.getUTCDay()]) + .replace('[x1]', months[date.getUTCMonth()]) + .replace('[x2]', date.getUTCDate()) + .replace('[x3]', date.getUTCFullYear()) } } else { var currentDate = new Date(); @@ -308,7 +488,7 @@ function getFormatDate(date, relative = false, justToday = false) { var currentMonth = currentDate.getUTCMonth(); var currentDay = currentDate.getUTCDate(); if (date.getUTCFullYear() === currentYear && date.getUTCMonth() === currentMonth && date.getUTCDate() === currentDay && justToday) { - return "Today"; + return getTranslationKey('common:today'); } var units = { @@ -320,7 +500,10 @@ function getFormatDate(date, relative = false, justToday = false) { second: 1000 } - var rtf = new Intl.RelativeTimeFormat('en', { numeric: 'auto' }) + lang = 'en' + if (localStorage.requestLanguage !== undefined) lang = localStorage.requestLanguage + + var rtf = new Intl.RelativeTimeFormat(lang, { numeric: 'auto' }) var getRelativeTime = (date, date2 = new Date()) => { var elapsed = date - date2
Instrument${getTranslationKey('encore-chart:instrument')} E M H
${track}${getTranslationKey(track)}