fix(i18n): download english trending for fallback (#48652)

* fix(i18n): download english trending for fallback

Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com>

* fix: prevent duplicate download for english

Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com>

Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com>
This commit is contained in:
Oliver Eyton-Williams
2022-12-02 15:09:01 +01:00
committed by GitHub
parent a6c4e39dc1
commit 0b644afb0e
+5 -2
View File
@@ -9,7 +9,7 @@ const { clientLocale } = envData;
const createCdnUrl = (lang: string) =>
`https://cdn.freecodecamp.org/universal/trending/${lang}.yaml`;
const download = async () => {
const download = async (clientLocale: string) => {
const url = createCdnUrl(clientLocale);
const res = await fetch(url);
if (!res.ok) {
@@ -44,4 +44,7 @@ const download = async () => {
}
};
void download();
void download(clientLocale);
// TODO: remove the need to fallback to english once we're confident it's
// unnecessary (client/i18n/config.js will need all references to 'en' removing)
if (clientLocale !== 'english') void download('english');