6995-testToMaster_2410 #2139

Merged
alexm merged 236 commits from 6995-testToMaster_2410 into master 2024-03-07 07:09:08 +00:00
2 changed files with 8 additions and 7 deletions
Showing only changes of commit 40a269c358 - Show all commits

View File

@ -32,8 +32,7 @@ module.exports = function() {
if (err.statusCode == 422) { if (err.statusCode == 422) {
try { try {
let code; let code;
let messages = err.details.messages; let {messages} = err.details;
for (code in messages) break;
err.message = req.__(messages[code][0]); err.message = req.__(messages[code][0]);
return next(err); return next(err);
} catch (e) {} } catch (e) {}
@ -44,7 +43,6 @@ module.exports = function() {
return next(new UserError(req.__(err.sqlMessage))); return next(new UserError(req.__(err.sqlMessage)));
// Logs error to console // Logs error to console
let env = process.env.NODE_ENV; let env = process.env.NODE_ENV;
let useCustomLogging = env && env != 'development' && let useCustomLogging = env && env != 'development' &&
(!err.statusCode || err.statusCode >= 500); (!err.statusCode || err.statusCode >= 500);

View File

@ -1,11 +1,13 @@
const SLASH = '/'; const SLASH = '/';
const MODULES = 'modules';
const BACK = 'back';
const path = require('path'); const path = require('path');
const glob = require('glob'); const glob = require('glob');
const modulesPath = `modules/**/back/locale/**/**.yml`; const modulesPath = `${MODULES}/**/${BACK}/locale/**/**.yml`;
const pathResolve = path.resolve(modulesPath); const pathResolve = path.resolve(modulesPath);
const modelsLocale = glob.sync(pathResolve, {}).map((f, data) => { const modelsLocale = glob.sync(pathResolve, {}).map(f => {
const file = require(f); const file = require(f);
const model = f.substring(f.indexOf('modules'), f.indexOf('back') - 1).split(SLASH)[1]; const model = f.substring(f.indexOf(MODULES), f.indexOf(BACK) - 1).split(SLASH)[1];
const locale = path.parse(f).base.split('.')[0]; const locale = path.parse(f).base.split('.')[0];
return [keyMap(model, locale), file.columns]; return [keyMap(model, locale), file.columns];
} }
@ -96,7 +98,8 @@ module.exports = {
} }
} }
if (tag) { if (tag) {
const tagValue = mapLocale.get(keyMap(moduleOriginal, $t.getLocale()))[tag]; let tagValue = mapLocale.get(keyMap(moduleOriginal, $t.getLocale()))[tag];
if (!tagValue) tagValue = tag;
return {tag, tagValue}; return {tag, tagValue};
} }
} catch (error) { } catch (error) {