From d56c127306c47abe606defb9c9880d168eb77ffd Mon Sep 17 00:00:00 2001 From: Anatoly Date: Tue, 8 Mar 2022 12:06:28 +0300 Subject: [PATCH] i18n fix and Ukranian lang --- public/style.css | 13 ++++++++++--- src/output/helpers.js | 9 +++++++++ src/output/i18n.json | 13 +++++++++++++ src/output/index.js | 7 +++++-- src/output/template.hbs | 7 +++++-- 5 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 src/output/helpers.js diff --git a/public/style.css b/public/style.css index 1b6f211..af600c7 100644 --- a/public/style.css +++ b/public/style.css @@ -98,20 +98,27 @@ a { position: absolute; left: 0; top: 0; + margin: 10px; + z-index: 20; } .languages > a { position: relative; - display: block; - margin: 10px; - padding: 10px; + display: inline-block; + padding: 5px; height: 32px; + border-radius: 50%; } .languages img { max-height: 100%; } +.languages .selected { + background: rgb(233, 233, 233); + box-shadow: 0 0 5px rgba(0, 0, 0, 50%); +} + .controls { margin: 32px auto; display: flex; diff --git a/src/output/helpers.js b/src/output/helpers.js new file mode 100644 index 0000000..3db3b3c --- /dev/null +++ b/src/output/helpers.js @@ -0,0 +1,9 @@ +function ifEq (a, b, opts) { + if (a === b) { + return opts.fn(this) + } else { + return opts.inverse(this) + } +} + +module.exports = { ifEq } diff --git a/src/output/i18n.json b/src/output/i18n.json index 403ab7d..9b0c6cb 100644 --- a/src/output/i18n.json +++ b/src/output/i18n.json @@ -1,5 +1,6 @@ { "en": { + "link": "index", "title": "Market Gaps", "description": "Find a profitable difference between the price of the set and the price of the sum of it's parts.", "filter_by_difference": "Filter by difference:", @@ -10,6 +11,7 @@ "generated_at": "Generated at" }, "ru": { + "link": "ru", "title": "Market Gaps", "description": "Находите выгоду между покупкой сета по отдельности и продажей его в собранном виде.", "filter_by_difference": "Фильтровать по разнице:", @@ -18,5 +20,16 @@ "set_price": "Стоимость сета", "difference": "Разница", "generated_at": "Сгенерировано в" + }, + "ua": { + "link": "ua", + "title": "Market Gaps", + "description": "Знаходьте вигоду між покупкою сета окремо та продажем його в зібраному вигляді.", + "filter_by_difference": "Фільтрувати за різницею:", + "name": "Назва", + "parts_price": "Вартість частин", + "set_price": "Вартість сета", + "difference": "Різниця", + "generated_at": "Згенеровано в" } } \ No newline at end of file diff --git a/src/output/index.js b/src/output/index.js index 125c95c..e84f2fa 100644 --- a/src/output/index.js +++ b/src/output/index.js @@ -1,8 +1,11 @@ const fs = require('fs') const Handlebars = require('handlebars') +const { ifEq } = require('./helpers') const ListingSet = require('./ListingSet') const i18n = require('./i18n.json') +Handlebars.registerHelper('if_eq', ifEq) + class Output { constructor () { this.items = [] @@ -32,11 +35,11 @@ class Output { const template = await this._compileTemplate() Object.keys(i18n).forEach(locale => { - const filename = locale === 'en' ? 'index' : locale + const filename = i18n[locale].link this._writeToFile(`./public/${filename}.html`, template({ ...this, t: i18n[locale], - languages: Object.keys(i18n).filter(language => language !== locale) + languages: i18n })) }) } diff --git a/src/output/template.hbs b/src/output/template.hbs index 83df8b4..c1cf77d 100644 --- a/src/output/template.hbs +++ b/src/output/template.hbs @@ -36,8 +36,11 @@
{{#each languages}} - - + + {{/each}}