lint: i18n.js

Partial, still 3 more to do that are slightly higher hanging that can get done.
pull/4842/head
John McLear 2021-02-21 20:06:10 +00:00 committed by Richard Hansen
parent 586af5e16e
commit b1614f0592
1 changed files with 5 additions and 5 deletions

View File

@ -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])}}`);