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
@@ -4,6 +4,7 @@ const {
parseBoolean,
clampValue,
CONSTANTS,
isLocaleAvailable,
} = require("../src/common/utils");
const fetchRepo = require("../src/fetchers/repo-fetcher");
const renderRepoCard = require("../src/cards/repo-card");
@@ -21,6 +22,7 @@ module.exports = async (req, res) => {
theme,
show_owner,
cache_seconds,
locale,
} = req.query;
let repoData;
@@ -31,6 +33,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 {
repoData = await fetchRepo(username, repo);
@@ -64,6 +70,7 @@ module.exports = async (req, res) => {
bg_color,
theme,
show_owner: parseBoolean(show_owner),
locale: locale ? locale.toLowerCase() : null,
}),
);
} catch (err) {