Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
feat(locale-data): add messages for item api data
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jun 14, 2018
1 parent b568c1a commit 77377fb
Show file tree
Hide file tree
Showing 17 changed files with 613 additions and 0 deletions.
30 changes: 30 additions & 0 deletions locale-data/de/api_messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"Armour": "Rüstung",
"Attacks per Second": "Angriffe pro Sekunde",
"Bow": "Bogen",
"Chaos Damage": "Chaosschaden",
"Claw": "Klaue",
"Corrupted": "Verderbt",
"Critical Strike Chance": "Kritische Trefferchance",
"Dagger": "Dolch",
"Dex": "Ges",
"Elemental Damage": "Elementarschaden",
"Energy Shield": "Energieschild",
"Evasion Rating": "Ausweichwert",
"Int": "Int",
"Level": "Stufe",
"Mirrored": "Gespiegelt",
"One Handed Axe": "Einhandaxt",
"One Handed Mace": "Einhandstreitkolben",
"One Handed Sword": "Einhandschwert",
"Physical Damage": "Physischer Schaden",
"Requires": "Erfordert",
"Staff": "Stab",
"Str": "Str",
"Two Handed Axe": "Zweihandaxt",
"Two Handed Mace": "Zweihandstreitkolben",
"Two Handed Sword": "Zweihandschwert",
"Unidentified": "Nicht identifiziert",
"Wand": "Zauberstab",
"Weapon Range": "Waffenreichweite"
}
30 changes: 30 additions & 0 deletions locale-data/es/api_messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"Armour": "Armadura",
"Attacks per Second": "Ataques por Segundo",
"Bow": "Arco",
"Chaos Damage": "Daño de Caos",
"Claw": "Garra",
"Corrupted": "Corrupto",
"Critical Strike Chance": "Daño de Golpe Crítico",
"Dagger": "Daga",
"Dex": "Des",
"Elemental Damage": "Daño Elemental",
"Energy Shield": "Escudo de Energía",
"Evasion Rating": "Índice de Evasión",
"Int": "Int",
"Level": "Nivel",
"Mirrored": "Reflejado",
"One Handed Axe": "Hacha a Una Mano",
"One Handed Mace": "Maza a Una Mano",
"One Handed Sword": "Espada a Una Mano",
"Physical Damage": "Daño Físico",
"Requires": "Requiere",
"Staff": "Báculo",
"Str": "Fue",
"Two Handed Axe": "Hacha a Dos Manos",
"Two Handed Mace": "Maza a Dos Manos",
"Two Handed Sword": "Espada a Dos Manos",
"Unidentified": "Sin identificar",
"Wand": "Varita",
"Weapon Range": "Rango de Arma"
}
30 changes: 30 additions & 0 deletions locale-data/fr/api_messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"Armour": "Armure",
"Attacks per Second": "Attaques par seconde",
"Bow": "Arc",
"Chaos Damage": "Dégâts de chaos",
"Claw": "Griffe",
"Corrupted": "Corrompu",
"Critical Strike Chance": "Chances de coup critique",
"Dagger": "Dague",
"Dex": "Dex",
"Elemental Damage": "Dégâts élémentaires",
"Energy Shield": "Bouclier d'énergie",
"Evasion Rating": "Score d'Évasion",
"Int": "Int",
"Level": "Niveau",
"Mirrored": "Reflété",
"One Handed Axe": "Hache à une main",
"One Handed Mace": "Masse à une main",
"One Handed Sword": "Épée à une main",
"Physical Damage": "Dégâts physiques",
"Requires": "Nécessite",
"Staff": "Bâton",
"Str": "For",
"Two Handed Axe": "Hache à deux mains",
"Two Handed Mace": "Masse à deux mains",
"Two Handed Sword": "Épée à deux mains",
"Unidentified": "Non identifié",
"Wand": "Baguette",
"Weapon Range": "Allonge"
}
30 changes: 30 additions & 0 deletions locale-data/pt/api_messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"Armour": "Armadura",
"Attacks per Second": "Ataques por Segundo",
"Bow": "Arco",
"Chaos Damage": "Dano de Caos",
"Claw": "Garra",
"Corrupted": "Corrompido",
"Critical Strike Chance": "Chance de Crítico",
"Dagger": "Adaga",
"Dex": "Des",
"Elemental Damage": "Dano Elemental",
"Energy Shield": "Escudo de Energia",
"Evasion Rating": "Evasão",
"Int": "Int",
"Level": "Nível",
"Mirrored": "Espelhado",
"One Handed Axe": "Machado de Uma Mão",
"One Handed Mace": "Maça de Uma Mão",
"One Handed Sword": "Espada de Uma Mão",
"Physical Damage": "Dano Físico",
"Requires": "Requer",
"Staff": "Cajado",
"Str": "For",
"Two Handed Axe": "Machado de Duas Mãos",
"Two Handed Mace": "Maça de Duas Mãos",
"Two Handed Sword": "Espada de Duas Mãos",
"Unidentified": "Não Identificado",
"Wand": "Varinha",
"Weapon Range": "Alcance da Arma"
}
30 changes: 30 additions & 0 deletions locale-data/ru/api_messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"Armour": "Броня",
"Attacks per Second": "Атак в секунду",
"Bow": "Лук",
"Chaos Damage": "Урон хаосом",
"Claw": "Когти",
"Corrupted": "Оскверненный",
"Critical Strike Chance": "Шанс критического удара",
"Dagger": "Кинжал",
"Dex": "Ловк",
"Elemental Damage": "Урон от стихий",
"Energy Shield": "Энерг. щит",
"Evasion Rating": "Уклонение",
"Int": "Инт",
"Level": "Уровень",
"Mirrored": "Отзеркаленный",
"One Handed Axe": "Одноручный топор",
"One Handed Mace": "Одноручная булава",
"One Handed Sword": "Одноручный меч",
"Physical Damage": "Физический урон",
"Requires": "Требует",
"Staff": "Посох",
"Str": "Сила",
"Two Handed Axe": "Двуручный топор",
"Two Handed Mace": "Двуручная булава",
"Two Handed Sword": "Двуручный меч",
"Unidentified": "Неопознанный",
"Wand": "Жезл",
"Weapon Range": "Дальность оружия"
}
30 changes: 30 additions & 0 deletions locale-data/th/api_messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"Armour": "เกราะ",
"Attacks per Second": "การโจมตีต่อวินาที",
"Bow": "ธนู",
"Chaos Damage": "ความเสียหายจากเคออส",
"Claw": "กรงเล็บ",
"Corrupted": "Corrupted",
"Critical Strike Chance": "โอกาสจู่โจมคริติคอล",
"Dagger": "มีด",
"Dex": "Dex",
"Elemental Damage": "ความเสียหายจากธาตุ",
"Energy Shield": "โล่พลังงาน",
"Evasion Rating": "อัตราการหลบหลีก",
"Int": "Int",
"Level": "เลเวล",
"Mirrored": "สะท้อน",
"One Handed Axe": "ขวานมือเดียว",
"One Handed Mace": "กระบองมือเดียว",
"One Handed Sword": "ดาบมือเดียว",
"Physical Damage": "ความเสียหายทางกายภาพ",
"Requires": "ต้องการ",
"Staff": "ไม้เท้า",
"Str": "Str",
"Two Handed Axe": "ขวานสองมือ",
"Two Handed Mace": "กระบองสองมือ",
"Two Handed Sword": "ดาบสองมือ",
"Unidentified": "ยังไม่ได้ตรวจสอบ",
"Wand": "คทา",
"Weapon Range": "ระยะโจมตีของอาวุธ"
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"format": "prettier --write src/**/*.ts",
"format:check": "prettier --list-different src/**/*.ts",
"generate-locale-data-popup": "node --harmony_async_iteration scripts/popup/createMessages && node --harmony_async_iteration scripts/popup/createApiMessages",
"postgenerate-locale-data-popup": "prettier --write \"locale-data/**/api_messages.json\"",
"generate-locale-data:clean": "rimraf locale-data/**/*.json",
"generate-locale-data": "yarn run parse-locale-data && yarn run process-locale-data",
"generate-skill-meta": "node scripts/generateSkillMeta",
Expand Down Expand Up @@ -59,7 +61,10 @@
"@types/jest": "^23.0.0",
"@types/node": "^9.3.0",
"coveralls": "^3.0.0",
"dot-prop": "^4.2.0",
"jest": "^23.0.0",
"limiter": "^1.1.3",
"mkdirp": "^0.5.1",
"moo": "^0.4.3",
"nearley": "^2.11.0",
"poe-mods": "^1.8.0",
Expand Down
1 change: 1 addition & 0 deletions scripts/popup/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp
45 changes: 45 additions & 0 deletions scripts/popup/api/getApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const https = require('https');
const { createGunzip } = require('zlib');

module.exports = async function getApi(endpoint, fn_options = {}) {
const { subdomain, timeout = 30 * 1000 } = fn_options;

const gunzip = createGunzip();
const options = {
host: `${subdomain ? `${subdomain}.` : ''}pathofexile.com`,
path: `/api/${endpoint}`,
headers: {
'Accept-Encoding': 'gzip'
}
};
console.log(`loading ${options.host}${options.path}`);

return await new Promise((resolve, reject) => {
let data = '';
const request = https
.get(options, response => {
const readStream =
response.headers['content-encoding'] === 'gzip'
? response.pipe(gunzip)
: response;

// response.pipe(file); but with a write after response finishes
readStream.on('data', chunk => (data += chunk));
readStream.on('end', () => {
const json = JSON.parse(data);
if (response.statusCode !== 200) {
reject(json)
} else {
resolve(json);
}

});
response.on('error', err => reject(err));
})
.on('error', err => reject(err))
.setTimeout(timeout, () => {
request.abort();
reject(`timeout after ${timeout}ms`);
});
});
};
23 changes: 23 additions & 0 deletions scripts/popup/api/getStashTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { RateLimiter } = require('limiter');

const getApi = require('./getApi');

const limiter = new RateLimiter(2, 'second');

module.exports = async function getStashTabLimited(id, options = {}) {
return await new Promise((resolve, reject) => {
limiter.removeTokens(1, err => {
if (err) {
reject(err);
} else {
getStashTab(id, options)
.then(result => resolve(result))
.catch(err => reject(err));
}
});
});
};

async function getStashTab(id, options = {}) {
return await getApi(`public-stash-tabs?id=${id}`, options);
}
28 changes: 28 additions & 0 deletions scripts/popup/api/getTradeItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { RateLimiter } = require('limiter');

const getApi = require('./getApi');

// X-Rate-Limit-IP: 20:5:60
// 20 per 5 seconds, don't know how to apply this with limiter so fallback to 4 every second
const limiter = new RateLimiter(3, 'second');

module.exports = async function getTradeItemLimited(item_ids, options = {}) {
return await new Promise((resolve, reject) => {
limiter.removeTokens(1, err => {
if (err) {
reject(err);
} else {
getTradeItem(item_ids, options)
.then(result => resolve(result))
.catch(err => reject(err));
}
});
});
};

async function getTradeItem(item_ids, options = {}) {
const ids = Array.isArray(item_ids) ? item_ids.join(',') : item_ids;

const { result } = await getApi(`trade/fetch/${ids}`, options);
return result.map(({ item }) => item);
}
4 changes: 4 additions & 0 deletions scripts/popup/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const getStashTab = require('./getStashTab');
const getTradeItem = require('./getTradeItem');

module.exports = { getStashTab, getTradeItem };
14 changes: 14 additions & 0 deletions scripts/popup/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const path = require('path');

const LOCALE_DATA_DIR = path.join(__dirname, '../../locale-data');
const TMP_DIR = path.join(__dirname, 'tmp/messages');
const LOCALES = [
{ short: 'pt', code: 'pt_BR', subdomain: 'br' },
{ short: 'ru', code: 'ru_RU' },
{ short: 'th', code: 'th_TH' },
{ short: 'de', code: 'de_DE' },
{ short: 'fr', code: 'fr_FR' },
{ short: 'es', code: 'es_ES' }
];

module.exports = { LOCALE_DATA_DIR, LOCALES, TMP_DIR };
Loading

0 comments on commit 77377fb

Please sign in to comment.