From b1614f0592d987d1146667c281eff4b2f2cfcc95 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 21 Feb 2021 20:06:10 +0000 Subject: [PATCH] lint: i18n.js Partial, still 3 more to do that are slightly higher hanging that can get done. --- src/node/hooks/i18n.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/node/hooks/i18n.js b/src/node/hooks/i18n.js index 81944a074..1cd663c4d 100644 --- a/src/node/hooks/i18n.js +++ b/src/node/hooks/i18n.js @@ -84,18 +84,18 @@ const getAllLocales = () => { // e.g. { es: {nativeName: "espaƱol", direction: "ltr"}, ... } const getAvailableLangs = (locales) => { const result = {}; - _.each(_.keys(locales), (langcode) => { + for (const langcode of Object.keys(locales)) { result[langcode] = languages.getLanguageInfo(langcode); - }); + } return result; }; // returns locale index that will be served in /locales.json const generateLocaleIndex = (locales) => { const result = _.clone(locales); // keep English strings - _.each(_.keys(locales), (langcode) => { + for (const langcode of Object.keys(locales)) { if (langcode !== 'en') result[langcode] = `locales/${langcode}.json`; - }); + } return JSON.stringify(result); }; @@ -109,7 +109,7 @@ exports.expressCreateServer = (n, args, cb) => { args.app.get('/locales/:locale', (req, res) => { // works with /locale/en and /locale/en.json requests const locale = req.params.locale.split('.')[0]; - if (exports.availableLangs.hasOwnProperty(locale)) { + if (Object.prototype.hasOwnProperty.call(exports.availableLangs, locale)) { res.setHeader('Cache-Control', `public, max-age=${settings.maxAge}`); res.setHeader('Content-Type', 'application/json; charset=utf-8'); res.send(`{"${locale}":${JSON.stringify(locales[locale])}}`);