Skip to content

Commit

Permalink
fix: fixed available locale list (anuraghazra#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraghazra authored Oct 31, 2020
1 parent ff9cf13 commit 10d8ca6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const {
parseArray,
clampValue,
CONSTANTS,
isLocaleAvailable,
} = require("../src/common/utils");
const fetchStats = require("../src/fetchers/stats-fetcher");
const renderStatsCard = require("../src/cards/stats-card");
const blacklist = require("../src/common/blacklist");
const { isLocaleAvailable } = require("../src/translations");

module.exports = async (req, res) => {
const {
Expand Down
2 changes: 1 addition & 1 deletion api/pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const {
parseBoolean,
clampValue,
CONSTANTS,
isLocaleAvailable,
} = require("../src/common/utils");
const fetchRepo = require("../src/fetchers/repo-fetcher");
const renderRepoCard = require("../src/cards/repo-card");
const blacklist = require("../src/common/blacklist");
const { isLocaleAvailable } = require("../src/translations");

module.exports = async (req, res) => {
const {
Expand Down
2 changes: 1 addition & 1 deletion api/top-langs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ 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");
const blacklist = require("../src/common/blacklist");
const { isLocaleAvailable } = require("../src/translations");

module.exports = async (req, res) => {
const {
Expand Down
7 changes: 0 additions & 7 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,6 @@ class CustomError extends Error {
static USER_NOT_FOUND = "USER_NOT_FOUND";
}

function isLocaleAvailable(locale) {
return ["cn", "de", "en", "es", "fr", "it", "ja", "kr", "pt-br"].includes(
locale.toLowerCase(),
);
}

module.exports = {
renderError,
kFormatter,
Expand All @@ -207,7 +201,6 @@ module.exports = {
getCardColors,
clampValue,
wrapTextMultiline,
isLocaleAvailable,
logger,
CONSTANTS,
CustomError,
Expand Down
10 changes: 9 additions & 1 deletion src/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const statCardLocales = ({ name, apostrophe }) => {
"pt-pt": "Total de estrelas",
"pt-br": "Total de estrelas",
np: "कुल ताराहरू",
el: 'Σύνολο Αστεριών',
el: "Σύνολο Αστεριών",
},
"statcard.commits": {
cn: "总提交",
Expand Down Expand Up @@ -190,7 +190,15 @@ const wakatimeCardLocales = {
},
};

const availableLocales = Object.keys(repoCardLocales["repocard.archived"]);

function isLocaleAvailable(locale) {
return availableLocales.includes(locale.toLowerCase());
}

module.exports = {
isLocaleAvailable,
availableLocales,
statCardLocales,
repoCardLocales,
langCardLocales,
Expand Down

0 comments on commit 10d8ca6

Please sign in to comment.