Skip to content

Commit

Permalink
fix i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
shironegi39 committed Sep 26, 2024
1 parent e3e5185 commit 22bcbab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
8 changes: 0 additions & 8 deletions apps/app/src/server/crowi/express-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,4 @@ module.exports = function(crowi, app) {
app.use(registerSafeRedirect);
app.use(injectCurrentuserToLocalvars);
app.use(autoReconnectToS2sMsgServer);

// TODO: Remove this workaround implementation when i18n works correctly.
// For now, req.t returns string given to req.t(string)
app.use((req, res, next) => {
req.t = str => (typeof str === 'string' ? str : '');

next();
});
};
24 changes: 20 additions & 4 deletions apps/app/src/server/routes/apiv3/app-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,26 @@ module.exports = (crowi) => {
body('gcsBucket').trim(),
body('gcsUploadNamespace').trim(),
body('gcsReferenceFileWithRelayMode').if(value => value != null).isBoolean(),
body('s3Region').trim().if(value => value !== '').matches(/^[a-z]+-[a-z]+-\d+$/)
.withMessage((value, { req }) => req.t('validation.aws_region')),
body('s3CustomEndpoint').trim().if(value => value !== '').matches(/^(https?:\/\/[^/]+|)$/)
.withMessage((value, { req }) => req.t('validation.aws_custom_endpoint')),
body('s3Region')
.trim()
.if(value => value !== '')
.custom(async(value) => {
const { t } = await getTranslation();
if (!/^[a-z]+-[a-z]+-\d+$/.test(value)) {
throw new Error(t('validation.aws_region'));
}
return true;
}),
body('s3CustomEndpoint')
.trim()
.if(value => value !== '')
.custom(async(value) => {
const { t } = await getTranslation();
if (!/^(https?:\/\/[^/]+|)$/.test(value)) {
throw new Error(t('validation.aws_custom_endpoint'));
}
return true;
}),
body('s3Bucket').trim(),
body('s3AccessKeyId').trim().if(value => value !== '').matches(/^[\da-zA-Z]+$/),
body('s3SecretAccessKey').trim(),
Expand Down

0 comments on commit 22bcbab

Please sign in to comment.