From 7b84baf0d4c6bfe5c38fdf5257482811fd1d6b1d Mon Sep 17 00:00:00 2001 From: Kichiyaki Date: Wed, 22 Jul 2020 17:02:49 +0200 Subject: [PATCH] translate extendedPlayerProfile into Polish --- dist/extendedPlayerProfile.js | 104 +++++++++++++++++++++++++----- src/extendedPlayerProfile.js | 54 ++++++++-------- src/i18n/extendedPlayerProfile.js | 61 ++++++++++++++++++ 3 files changed, 177 insertions(+), 42 deletions(-) create mode 100644 src/i18n/extendedPlayerProfile.js diff --git a/dist/extendedPlayerProfile.js b/dist/extendedPlayerProfile.js index 3c6c50c..91fb4be 100644 --- a/dist/extendedPlayerProfile.js +++ b/dist/extendedPlayerProfile.js @@ -157,6 +157,75 @@ var _default = function _default() { }); }; +exports.default = _default; +},{}],"I8dv":[function(require,module,exports) { +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +const translations = { + pl_PL: { + date: 'Data', + newTribe: 'Nowe plemię', + oldTribe: 'Poprzednie plemię', + joinedAt: 'Dołączył', + dailyGrowth: 'Dzienny przyrost', + bestRank: 'Najlepszy ranking', + mostPoints: 'Najwięcej punktów', + mostVillages: 'Najwięcej wiosek', + oldName: 'Poprzedni nick', + newName: 'Nowy nick', + playerServers: "Serwery gracza", + inADayBestScores: "Dzienne rankingi", + unitsDefeatedWhileAttacking: 'Jako atakujący', + unitsDefeatedWhileDefending: 'Jako obrońca', + unitsDefeatedWhileSupporting: 'Jako wspierający', + resourcesPlundered: 'Sfarmione surowce', + villagesPlundered: 'Splądrowane wioski', + resourcesGathered: 'Zebrane surowce', + villagesConquered: 'Podbite wioski', + exportedVillages: 'Wyeksportowane wioski', + action: { + showTribeChanges: 'Pokaż zmiany plemion', + showEnnoblements: 'Pokaż przejęcia', + exportVillages: 'Wyeksportuj wioski', + showHistory: 'Pokaż historię' + } + }, + en_DK: { + date: 'Date', + newTribe: 'New tribe', + oldTribe: 'Old tribe', + joinedAt: 'Joined at', + dailyGrowth: 'Daily growth', + bestRank: 'Best rank', + mostPoints: 'Most points', + mostVillages: 'Most villages', + oldName: 'Old name', + newName: 'New name', + playerServers: "Player's servers", + inADayBestScores: "'In a day' best scores", + unitsDefeatedWhileAttacking: 'Units defeated while attacking', + unitsDefeatedWhileDefending: 'Units defeated while defending', + unitsDefeatedWhileSupporting: 'Units defeated while supporting', + resourcesPlundered: 'Resources plundered', + villagesPlundered: 'Villages plundered', + resourcesGathered: 'Resources gathered', + villagesConquered: 'Villages conquered', + exportedVillages: 'Exported villages', + action: { + showTribeChanges: 'Show tribe changes', + showEnnoblements: 'Show ennoblements', + exportVillages: 'Export villages', + showHistory: 'Show history' + } + } +}; + +var _default = () => translations[window.game_data.locale] || translations.en_DK; + exports.default = _default; },{}],"l9PO":[function(require,module,exports) { "use strict"; @@ -1023,6 +1092,8 @@ exports.setItem = setItem; var _requestCreator = _interopRequireDefault(require("./libs/requestCreator")); +var _extendedPlayerProfile = _interopRequireDefault(require("./i18n/extendedPlayerProfile")); + var _renderTodaysStats = _interopRequireDefault(require("./common/renderTodaysStats")); var _showPopup = _interopRequireDefault(require("./utils/showPopup")); @@ -1058,7 +1129,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope // @namespace https://github.com/tribalwarshelp/scripts // @updateURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedPlayerProfile.js // @downloadURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedPlayerProfile.js -// @version 1.0.9 +// @version 1.1.0 // @description Extended Player Profile // @author Kichiyaki http://dawid-wysokinski.pl/ // @match *://*/game.php*screen=info_player* @@ -1085,6 +1156,7 @@ const ENNOBLEMENTS_PER_PAGE = 15; const profileInfoTBody = document.querySelector('#player_info > tbody'); const actionContainer = PLAYER_ID === CURRENT_PLAYER_ID ? profileInfoTBody : document.querySelector('#content_value > table > tbody > tr > td:nth-child(1) > table:nth-child(2) > tbody'); const otherElementContainer = document.querySelector(PLAYER_ID === CURRENT_PLAYER_ID ? '#content_value > table:nth-child(7) > tbody > tr > td:nth-child(2)' : '#content_value > table > tbody > tr > td:nth-child(2)'); +const translations = (0, _extendedPlayerProfile.default)(); const loadDataFromCache = () => { return (0, _localStorage.getItem)(LOCAL_STORAGE_KEY); @@ -1174,7 +1246,7 @@ const renderPlayerServers = player => { playerServers.id = 'playerServers'; playerServers.classList.add('vis'); playerServers.width = '100%'; - playerServers.innerHTML = "\n \n \n \n Player's servers\n \n \n \n \n \n \n \n "; + playerServers.innerHTML = "\n \n \n \n ".concat(translations.playerServers, "\n \n \n \n \n \n \n \n "); otherElementContainer.prepend(playerServers); } @@ -1191,7 +1263,7 @@ const renderPlayerOtherNames = player => { otherElementContainer.prepend(playerOtherNames); } - playerOtherNames.innerHTML = "\n \n \n \n \n \n \n \n ".concat(player.nameChanges.map(nameChange => { + playerOtherNames.innerHTML = "\n
\n Old name\n \n New name\n \n Date\n
\n \n \n \n \n \n \n ").concat(player.nameChanges.map(nameChange => { return "\n \n \n \n
\n ".concat(translations.oldName, "\n \n ").concat(translations.newName, "\n \n ").concat(translations.date, "\n
\n ".concat(nameChange.oldName, "\n \n ").concat(nameChange.newName, "\n \n ").concat((0, _formatDate.default)(nameChange.changeDate, { year: 'numeric', month: '2-digit', @@ -1210,7 +1282,7 @@ const renderInADayRanks = player => { otherElementContainer.prepend(inADayRanks); } - inADayRanks.innerHTML = "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n 'In a day' best scores\n
\n Units defeated while attacking:\n \n ".concat(player.inADay.att.score.toLocaleString(), " (").concat(player.inADay.att.rank, ".)\n
\n Units defeated while defending:\n \n ").concat(player.inADay.def.score.toLocaleString(), " (").concat(player.inADay.def.rank, ".)\n
\n Units defeated while supporting:\n \n ").concat(player.inADay.sup.score.toLocaleString(), " (").concat(player.inADay.sup.rank, ".)\n
\n Resources plundered:\n \n ").concat(player.inADay.lootRes.score.toLocaleString(), " (").concat(player.inADay.lootRes.rank, ".)\n
\n Villages plundered:\n \n ").concat(player.inADay.lootVil.score.toLocaleString(), " (").concat(player.inADay.lootVil.rank, ".)\n
\n Resources gathered:\n \n ").concat(player.inADay.scavenge.score.toLocaleString(), " (").concat(player.inADay.scavenge.rank, ".)\n
\n Villages conquered:\n \n ").concat(player.inADay.conquer.score.toLocaleString(), " (").concat(player.inADay.conquer.rank, ".)\n
\n "); + inADayRanks.innerHTML = "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n ".concat(translations.inADayBestScores, "\n
\n ").concat(translations.unitsDefeatedWhileAttacking, "\n \n ").concat(player.inADay.att.score.toLocaleString(), " (").concat(player.inADay.att.rank, ".)\n
\n ").concat(translations.unitsDefeatedWhileDefending, "\n \n ").concat(player.inADay.def.score.toLocaleString(), " (").concat(player.inADay.def.rank, ".)\n
\n ").concat(translations.unitsDefeatedWhileSupporting, "\n \n ").concat(player.inADay.sup.score.toLocaleString(), " (").concat(player.inADay.sup.rank, ".)\n
\n ").concat(translations.resourcesPlundered, "\n \n ").concat(player.inADay.lootRes.score.toLocaleString(), " (").concat(player.inADay.lootRes.rank, ".)\n
\n ").concat(translations.villagesPlundered, "\n \n ").concat(player.inADay.lootVil.score.toLocaleString(), " (").concat(player.inADay.lootVil.rank, ".)\n
\n ").concat(translations.resourcesGathered, "\n \n ").concat(player.inADay.scavenge.score.toLocaleString(), " (").concat(player.inADay.scavenge.rank, ".)\n
\n ").concat(translations.villagesConquered, "\n \n ").concat(player.inADay.conquer.score.toLocaleString(), " (").concat(player.inADay.conquer.rank, ".)\n
\n "); }; const render = (_ref2) => { @@ -1219,23 +1291,23 @@ const render = (_ref2) => { dailyPlayerStats } = _ref2; [{ - title: 'Joined at:', + title: translations.joinedAt + ':', data: (0, _formatDate.default)(player.joinedAt), id: 'joined_at' }, { - title: 'Daily growth:', + title: translations.dailyGrowth + ':', data: player.dailyGrowth.toLocaleString(), id: 'dg' }, { - title: 'Best rank:', + title: translations.bestRank + ':', data: player.bestRank + ' ' + "(".concat((0, _formatDate.default)(player.bestRankAt), ")"), id: 'best_rank' }, { - title: 'Most points:', + title: translations.mostPoints + ':', data: player.mostPoints.toLocaleString() + ' ' + "(".concat((0, _formatDate.default)(player.mostPointsAt), ")"), id: 'most_points' }, { - title: 'Most villages:', + title: translations.mostVillages + ':', data: player.mostVillages + ' ' + "(".concat((0, _formatDate.default)(player.mostVillagesAt), ")"), id: 'most_villages' }].forEach(data => { @@ -1262,7 +1334,7 @@ const renderTribeChanges = (e, currentPage, tribeChanges) => { limit: TRIBE_CHANGES_PER_PAGE, currentPage }); - const html = "\n
\n ").concat(paginationItems.join(''), "\n
\n \n \n \n \n \n \n \n ").concat(tribeChanges.items.map(tribeChange => { + const html = "\n
\n ").concat(paginationItems.join(''), "\n
\n
\n Date\n \n New tribe\n \n Old tribe\n
\n \n \n \n \n \n \n ").concat(tribeChanges.items.map(tribeChange => { let rowHTML = '' + ""); if (tribeChange.newTribe) { @@ -1378,7 +1450,7 @@ const handleShowPlayerEnnoblementsClick = async e => { const handleExportPlayerVillagesButtonClick = e => { e.preventDefault(); - Dialog.show('Exported villages', "")); + Dialog.show(translations.exportedVillages, "")); }; const wrapAction = action => { @@ -1394,24 +1466,24 @@ const renderActions = () => { const showTribeChanges = document.createElement('a'); showTribeChanges.href = '#'; (0, _pagination.setPage)(showTribeChanges, '1'); - showTribeChanges.innerHTML = 'Show tribe changes'; + showTribeChanges.innerHTML = translations.action.showTribeChanges; showTribeChanges.addEventListener('click', handleShowTribeChangesButtonClick); actionContainer.appendChild(wrapAction(showTribeChanges)); const showPlayerHistory = document.createElement('a'); showPlayerHistory.href = '#'; (0, _pagination.setPage)(showPlayerHistory, '1'); - showPlayerHistory.innerHTML = 'Show history'; + showPlayerHistory.innerHTML = translations.action.showHistory; showPlayerHistory.addEventListener('click', handleShowPlayerHistoryClick); actionContainer.appendChild(wrapAction(showPlayerHistory)); const showEnnoblements = document.createElement('a'); showEnnoblements.href = '#'; (0, _pagination.setPage)(showEnnoblements, '1'); - showEnnoblements.innerHTML = 'Show ennoblements'; + showEnnoblements.innerHTML = translations.action.showEnnoblements; showEnnoblements.addEventListener('click', handleShowPlayerEnnoblementsClick); actionContainer.appendChild(wrapAction(showEnnoblements)); const exportPlayerVillages = document.createElement('a'); exportPlayerVillages.href = '#'; - exportPlayerVillages.innerHTML = "Export villages"; + exportPlayerVillages.innerHTML = translations.action.exportVillages; exportPlayerVillages.addEventListener('click', handleExportPlayerVillagesButtonClick); actionContainer.appendChild(wrapAction(exportPlayerVillages)); }; @@ -1434,4 +1506,4 @@ const renderActions = () => { console.log('extended player profile', error); } })(); -},{"./libs/requestCreator":"Ph2E","./common/renderTodaysStats":"yrCm","./utils/showPopup":"chDM","./common/showEnnoblementsPopup":"vNT1","./common/showHistoryPopup":"kEDU","./utils/pagination":"fCHX","./utils/getIDFromURL":"tQUs","./utils/getCurrentServer":"DMkL","./utils/formatDate":"V6Mf","./utils/twstats":"Syko","./utils/tribalwars":"fHHP","./utils/localStorage":"KWxH"}]},{},["yRop"], null) \ No newline at end of file +},{"./libs/requestCreator":"Ph2E","./i18n/extendedPlayerProfile":"I8dv","./common/renderTodaysStats":"yrCm","./utils/showPopup":"chDM","./common/showEnnoblementsPopup":"vNT1","./common/showHistoryPopup":"kEDU","./utils/pagination":"fCHX","./utils/getIDFromURL":"tQUs","./utils/getCurrentServer":"DMkL","./utils/formatDate":"V6Mf","./utils/twstats":"Syko","./utils/tribalwars":"fHHP","./utils/localStorage":"KWxH"}]},{},["yRop"], null) \ No newline at end of file diff --git a/src/extendedPlayerProfile.js b/src/extendedPlayerProfile.js index 903e917..124a71e 100644 --- a/src/extendedPlayerProfile.js +++ b/src/extendedPlayerProfile.js @@ -1,4 +1,5 @@ import requestCreator from './libs/requestCreator'; +import getTranslations from './i18n/extendedPlayerProfile'; import renderTodaysStats from './common/renderTodaysStats'; import showPopup from './utils/showPopup'; import showEnnoblementsPopup from './common/showEnnoblementsPopup'; @@ -21,7 +22,7 @@ import { setItem, getItem } from './utils/localStorage'; // @namespace https://github.com/tribalwarshelp/scripts // @updateURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedPlayerProfile.js // @downloadURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedPlayerProfile.js -// @version 1.0.9 +// @version 1.1.0 // @description Extended Player Profile // @author Kichiyaki http://dawid-wysokinski.pl/ // @match *://*/game.php*screen=info_player* @@ -180,6 +181,7 @@ const otherElementContainer = document.querySelector( ? '#content_value > table:nth-child(7) > tbody > tr > td:nth-child(2)' : '#content_value > table > tbody > tr > td:nth-child(2)' ); +const translations = getTranslations(); const loadDataFromCache = () => { return getItem(LOCAL_STORAGE_KEY); @@ -262,7 +264,7 @@ const renderPlayerServers = (player) => { @@ -298,13 +300,13 @@ const renderPlayerOtherNames = (player) => { ${player.nameChanges @@ -347,12 +349,12 @@ const renderInADayRanks = (player) => { ${tribeChanges.items @@ -619,7 +621,7 @@ const handleExportPlayerVillagesButtonClick = (e) => { e.preventDefault(); Dialog.show( - 'Exported villages', + translations.exportedVillages, `
\n ").concat(translations.date, "\n \n ").concat(translations.newTribe, "\n \n ").concat(translations.oldTribe, "\n
".concat((0, _formatDate.default)(tribeChange.createdAt), "
- Player's servers + ${translations.playerServers}
- Old name + ${translations.oldName} - New name + ${translations.newName} - Date + ${translations.date}
- 'In a day' best scores + ${translations.inADayBestScores}
- Units defeated while attacking: + ${translations.unitsDefeatedWhileAttacking} ${player.inADay.att.score.toLocaleString()} (${ @@ -362,7 +364,7 @@ const renderInADayRanks = (player) => {
- Units defeated while defending: + ${translations.unitsDefeatedWhileDefending} ${player.inADay.def.score.toLocaleString()} (${ @@ -372,7 +374,7 @@ const renderInADayRanks = (player) => {
- Units defeated while supporting: + ${translations.unitsDefeatedWhileSupporting} ${player.inADay.sup.score.toLocaleString()} (${ @@ -382,7 +384,7 @@ const renderInADayRanks = (player) => {
- Resources plundered: + ${translations.resourcesPlundered} ${player.inADay.lootRes.score.toLocaleString()} (${ @@ -392,7 +394,7 @@ const renderInADayRanks = (player) => {
- Villages plundered: + ${translations.villagesPlundered} ${player.inADay.lootVil.score.toLocaleString()} (${ @@ -402,7 +404,7 @@ const renderInADayRanks = (player) => {
- Resources gathered: + ${translations.resourcesGathered} ${player.inADay.scavenge.score.toLocaleString()} (${ @@ -412,7 +414,7 @@ const renderInADayRanks = (player) => {
- Villages conquered: + ${translations.villagesConquered} ${player.inADay.conquer.score.toLocaleString()} (${ @@ -428,22 +430,22 @@ const renderInADayRanks = (player) => { const render = ({ player, dailyPlayerStats }) => { [ { - title: 'Joined at:', + title: translations.joinedAt + ':', data: formatDate(player.joinedAt), id: 'joined_at', }, { - title: 'Daily growth:', + title: translations.dailyGrowth + ':', data: player.dailyGrowth.toLocaleString(), id: 'dg', }, { - title: 'Best rank:', + title: translations.bestRank + ':', data: player.bestRank + ' ' + `(${formatDate(player.bestRankAt)})`, id: 'best_rank', }, { - title: 'Most points:', + title: translations.mostPoints + ':', data: player.mostPoints.toLocaleString() + ' ' + @@ -451,7 +453,7 @@ const render = ({ player, dailyPlayerStats }) => { id: 'most_points', }, { - title: 'Most villages:', + title: translations.mostVillages + ':', data: player.mostVillages + ' ' + `(${formatDate(player.mostVillagesAt)})`, id: 'most_villages', @@ -486,13 +488,13 @@ const renderTribeChanges = (e, currentPage, tribeChanges) => {
- Date + ${translations.date} - New tribe + ${translations.newTribe} - Old tribe + ${translations.oldTribe}