diff --git a/dist/bonusBarbarianVillageFinder.js b/dist/bonusBarbarianVillageFinder.js index 437d4e0..c94a290 100644 --- a/dist/bonusBarbarianVillageFinder.js +++ b/dist/bonusBarbarianVillageFinder.js @@ -157,6 +157,33 @@ var _default = function _default() { }); }; +exports.default = _default; +},{}],"MRps":[function(require,module,exports) { +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +const translations = { + pl_PL: { + actualCoords: 'Aktualne koordynaty', + searchBonusBarbarianVillages: 'Wyszukaj koczownicze', + village: 'Wioska', + distance: 'Dystans', + action: 'Akcja' + }, + en_DK: { + actualCoords: 'Actual coords', + searchBonusBarbarianVillages: 'Search bonus barbarian villages', + village: 'Village', + distance: 'Distance', + action: 'Action' + } +}; + +var _default = () => translations[window.game_data.locale] || translations.en_DK; + exports.default = _default; },{}],"DMkL":[function(require,module,exports) { "use strict"; @@ -348,6 +375,8 @@ exports.loadInADayData = loadInADayData; var _requestCreator = _interopRequireDefault(require("./libs/requestCreator")); +var _bonusBarbarianVillageFinder = _interopRequireDefault(require("./i18n/bonusBarbarianVillageFinder")); + var _getCurrentServer = _interopRequireDefault(require("./utils/getCurrentServer")); var _tribalwars = require("./utils/tribalwars"); @@ -365,7 +394,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/bonusBarbarianVillageFinder.js // @downloadURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/bonusBarbarianVillageFinder.js -// @version 0.3.0 +// @version 0.4.0 // @description Bonus barbarian village finder // @author Kichiyaki http://dawid-wysokinski.pl/ // @match *://*/game.php*screen=map* @@ -375,6 +404,7 @@ const SERVER = (0, _getCurrentServer.default)(); const QUERY = "\n query villages($server: String!, $filter: VillageFilter) {\n villages(server: $server, filter: $filter) {\n total\n items {\n id\n name\n bonus\n x\n y\n }\n }\n }\n"; const TABLE_ID = 'bonusBarbarianVillageFinderTable'; const ACTUAL_COORDS_ID = 'actualCoords'; +const translations = (0, _bonusBarbarianVillageFinder.default)(); let container = undefined; const buildReqOptions = (bonus, offset) => { @@ -433,15 +463,15 @@ const getBonuses = () => { }; const buildTableBodyHTML = villages => { - return "\n \n \n \n Village\n \n \n Distance\n \n \n Action\n \n \n ".concat(Array.isArray(villages) ? villages.map(village => "\n \n \n ").concat((0, _tribalwars.formatVillageName)(village.name, village.x, village.y), "\n \n \n \n ").concat(village.distance.toFixed(1), "\n \n \n Center\n \n ")).join('') : '', "\n \n "); + return "\n \n \n \n ".concat(translations.village, "\n \n \n ").concat(translations.distance, "\n \n \n ").concat(translations.action, "\n \n \n ").concat(Array.isArray(villages) ? villages.map(village => "\n \n \n ").concat((0, _tribalwars.formatVillageName)(village.name, village.x, village.y), "\n \n \n \n ").concat(village.distance.toFixed(1), "\n \n \n Center\n \n ")).join('') : '', "\n \n "); }; const updateActualCoords = () => { - document.querySelector('#' + ACTUAL_COORDS_ID).innerHTML = "Actual coords: ".concat(TWMap.pos.join('|'), ""); + document.querySelector('#' + ACTUAL_COORDS_ID).innerHTML = "".concat(translations.actualCoords, ": ").concat(TWMap.pos.join('|'), ""); }; const renderUI = () => { - const html = "\n

\n
\n \n \n
\n \n ").concat(buildTableBodyHTML(), "\n
\n "); + const html = "\n

\n
\n \n \n
\n \n ").concat(buildTableBodyHTML(), "\n
\n "); if (!container) { container = document.createElement('div'); @@ -458,4 +488,4 @@ const renderUI = () => { (function () { renderUI(); })(); -},{"./libs/requestCreator":"Ph2E","./utils/getCurrentServer":"DMkL","./utils/tribalwars":"fHHP"}]},{},["fvjy"], null) \ No newline at end of file +},{"./libs/requestCreator":"Ph2E","./i18n/bonusBarbarianVillageFinder":"MRps","./utils/getCurrentServer":"DMkL","./utils/tribalwars":"fHHP"}]},{},["fvjy"], null) \ No newline at end of file diff --git a/screenshots/bonusBarbarianVillageFinder.png b/screenshots/bonusBarbarianVillageFinder.png new file mode 100644 index 0000000..cd7606f Binary files /dev/null and b/screenshots/bonusBarbarianVillageFinder.png differ diff --git a/src/bonusBarbarianVillageFinder.js b/src/bonusBarbarianVillageFinder.js index 3327ead..e6a5c91 100644 --- a/src/bonusBarbarianVillageFinder.js +++ b/src/bonusBarbarianVillageFinder.js @@ -1,4 +1,5 @@ import requestCreator from './libs/requestCreator'; +import getTranslations from './i18n/bonusBarbarianVillageFinder'; import getCurrentServer from './utils/getCurrentServer'; import { formatVillageURL, formatVillageName } from './utils/tribalwars'; @@ -7,7 +8,7 @@ import { formatVillageURL, formatVillageName } from './utils/tribalwars'; // @namespace https://github.com/tribalwarshelp/scripts // @updateURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/bonusBarbarianVillageFinder.js // @downloadURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/bonusBarbarianVillageFinder.js -// @version 0.3.0 +// @version 0.4.0 // @description Bonus barbarian village finder // @author Kichiyaki http://dawid-wysokinski.pl/ // @match *://*/game.php*screen=map* @@ -31,6 +32,7 @@ const QUERY = ` `; const TABLE_ID = 'bonusBarbarianVillageFinderTable'; const ACTUAL_COORDS_ID = 'actualCoords'; +const translations = getTranslations(); let container = undefined; const buildReqOptions = (bonus, offset) => { @@ -95,13 +97,13 @@ const buildTableBodyHTML = (villages) => { - Village + ${translations.village} - Distance + ${translations.distance} - Action + ${translations.action} ${ @@ -132,9 +134,9 @@ const buildTableBodyHTML = (villages) => { }; const updateActualCoords = () => { - document.querySelector( - '#' + ACTUAL_COORDS_ID - ).innerHTML = `Actual coords: ${TWMap.pos.join('|')}`; + document.querySelector('#' + ACTUAL_COORDS_ID).innerHTML = `${ + translations.actualCoords + }: ${TWMap.pos.join('|')}`; }; const renderUI = () => { @@ -149,7 +151,9 @@ const renderUI = () => { ) .join('')} - + ${buildTableBodyHTML()} diff --git a/src/i18n/bonusBarbarianVillageFinder.js b/src/i18n/bonusBarbarianVillageFinder.js new file mode 100644 index 0000000..943173c --- /dev/null +++ b/src/i18n/bonusBarbarianVillageFinder.js @@ -0,0 +1,19 @@ +const translations = { + pl_PL: { + actualCoords: 'Aktualne koordynaty', + searchBonusBarbarianVillages: 'Wyszukaj koczownicze', + village: 'Wioska', + distance: 'Dystans', + action: 'Akcja', + }, + en_DK: { + actualCoords: 'Actual coords', + searchBonusBarbarianVillages: 'Search bonus barbarian villages', + village: 'Village', + distance: 'Distance', + action: 'Action', + }, +}; + +export default () => + translations[window.game_data.locale] || translations.en_DK;