feat: card locale translations (#509)

* Add Card Translations

* Add tests and documentation for `?lang` option

* Card Translations: update Italian

* Run Prettier

* Correct German Translations.

Co-authored-by: schmelto <30869493+schmelto@users.noreply.github.com>

* refactor: added i18n class to manage translation logic & improved code

* Make the new src/translations.js more concise

* Update translations.js

Co-authored-by: schmelto <30869493+schmelto@users.noreply.github.com>

* Revert 4175484d69289e4ee7283ab968b8e71c3c5d77df

* fix: overlap because of language length

Co-authored-by: lrusso96 <russo.1699981@studenti.uniroma1.it>
Co-authored-by: schmelto <30869493+schmelto@users.noreply.github.com>
Co-authored-by: Anurag <hazru.anurag@gmail.com>
This commit is contained in:
Nathan Chu
2020-10-04 13:35:15 +05:30
committed by GitHub
co-authored by lrusso96 schmelto Anurag
parent 2707d07453
commit f1df178643
16 changed files with 337 additions and 27 deletions
+7
View File
@@ -5,6 +5,7 @@ const {
parseArray,
clampValue,
CONSTANTS,
isLocaleAvailable,
} = require("../src/common/utils");
const fetchStats = require("../src/fetchers/stats-fetcher");
const renderStatsCard = require("../src/cards/stats-card");
@@ -28,6 +29,7 @@ module.exports = async (req, res) => {
theme,
cache_seconds,
custom_title,
locale,
} = req.query;
let stats;
@@ -37,6 +39,10 @@ module.exports = async (req, res) => {
return res.send(renderError("Something went wrong"));
}
if (locale && !isLocaleAvailable(locale)) {
return res.send(renderError("Something went wrong", "Language not found"));
}
try {
stats = await fetchStats(
username,
@@ -67,6 +73,7 @@ module.exports = async (req, res) => {
bg_color,
theme,
custom_title,
locale: locale ? locale.toLowerCase() : null,
}),
);
} catch (err) {