mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-10-03 04:54:41 +00:00
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:
16 files changed
+337
-27
No files matched your search
@@ -5,6 +5,7 @@ const {
|
||||
parseBoolean,
|
||||
parseArray,
|
||||
CONSTANTS,
|
||||
isLocaleAvailable,
|
||||
} = require("../src/common/utils");
|
||||
const fetchTopLanguages = require("../src/fetchers/top-languages-fetcher");
|
||||
const renderTopLanguages = require("../src/cards/top-languages-card");
|
||||
@@ -26,6 +27,7 @@ module.exports = async (req, res) => {
|
||||
langs_count,
|
||||
exclude_repo,
|
||||
custom_title,
|
||||
locale,
|
||||
} = req.query;
|
||||
let topLangs;
|
||||
|
||||
@@ -35,6 +37,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 {
|
||||
topLangs = await fetchTopLanguages(
|
||||
username,
|
||||
@@ -62,6 +68,7 @@ module.exports = async (req, res) => {
|
||||
bg_color,
|
||||
theme,
|
||||
layout,
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
|
||||
Reference in new issue
Block a user