mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-07-16 22:17:02 +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:
co-authored by
lrusso96
schmelto
Anurag
parent
2707d07453
commit
f1df178643
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -4,6 +4,7 @@ const {
|
||||
parseBoolean,
|
||||
clampValue,
|
||||
CONSTANTS,
|
||||
isLocaleAvailable,
|
||||
} = require("../src/common/utils");
|
||||
const { fetchLast7Days } = require("../src/fetchers/wakatime-fetcher");
|
||||
const wakatimeCard = require("../src/cards/wakatime-card");
|
||||
@@ -22,10 +23,15 @@ module.exports = async (req, res) => {
|
||||
hide_title,
|
||||
hide_progress,
|
||||
custom_title,
|
||||
locale,
|
||||
} = req.query;
|
||||
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(renderError("Something went wrong", "Language not found"));
|
||||
}
|
||||
|
||||
try {
|
||||
const last7Days = await fetchLast7Days({ username });
|
||||
|
||||
@@ -53,6 +59,7 @@ module.exports = async (req, res) => {
|
||||
bg_color,
|
||||
theme,
|
||||
hide_progress,
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user