summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/app.ts15
-rw-r--r--src/routes/event.ts14
-rw-r--r--src/util/validation.ts2
3 files changed, 16 insertions, 15 deletions
diff --git a/src/app.ts b/src/app.ts
index 47bb2d1..4cf37c8 100755
--- a/src/app.ts
+++ b/src/app.ts
@@ -13,7 +13,7 @@ import path from 'path';
const require = createRequire(import.meta.url);
const handlebarsI18next = require('handlebars-i18next');
-// ESモジュールで__dirnameを再現
+// Recreate __dirname in ES module
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@@ -37,7 +37,7 @@ const app = express();
app.locals.sendEmails = initEmailService();
-// ESモジュールで__dirnameを再現する部分を関数化
+// function to construct __dirname with ES module
const getLocalesPath = () => {
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@@ -75,11 +75,12 @@ async function initializeApp() {
app.use(handle(i18next));
- // 言語を明示的に切り替える
+ // to Switch language
app.use((req, res, next) => {
const currentLanguage = i18next.language;
i18next.changeLanguage(req.language);
const newLanguage = i18next.language;
+// Uncomment for debugging
// console.log('Language Change:', {
// header: req.headers['accept-language'],
// detected: req.language,
@@ -89,7 +90,7 @@ async function initializeApp() {
next();
});
-// // デバッグ用
+// Uncomment for debugging
// app.use((req, res, next) => {
// console.log('Language Detection:', {
// header: req.headers['accept-language'],
@@ -108,16 +109,16 @@ async function initializeApp() {
json: function (context: any) {
return JSON.stringify(context);
},
- // i18nextヘルパーを追加
+ // add i18next helpers
...getI18nHelpers(),
- plural: function (key: string, count: number, options: any) { // ★plural ヘルパーを登録
+ plural: function (key: string, count: number, options: any) { // Register the plural helper
const translation = i18next.t(key, { count: count });
return translation;
}
},
});
- // i18nextHelperの呼び出し方法を変更
+ // calling i18nextHelper
if (typeof handlebarsI18next === 'function') {
handlebarsI18next(hbsInstance.handlebars, i18next);
} else if (typeof handlebarsI18next.default === 'function') {
diff --git a/src/routes/event.ts b/src/routes/event.ts
index ca333c5..8972169 100644
--- a/src/routes/event.ts
+++ b/src/routes/event.ts
@@ -414,10 +414,10 @@ router.put(
"<p>" + i18next.t("routes.event.difftext") + "</p><ul>";
let displayDate;
if (event.name !== updatedEvent.name) {
- diffText += `<li>` + i18next.t("routes.event.namechanged") + updatedEvent.name + `</li>`;
+ diffText += `<li>` + i18next.t("routes.event.namechanged", { eventname: updatedEvent.name} ) + `</li>`;
}
if (event.location !== updatedEvent.location) {
- diffText += `<li>` + i18next.t("routes.event.locationchanged") + updatedEvent.location + `</li>`;
+ diffText += `<li>` + i18next.t("routes.event.locationchanged", { location: updatedEvent.location} ) + `</li>`;
}
if (
event.start.toISOString() !== updatedEvent.start.toISOString()
@@ -425,19 +425,19 @@ router.put(
displayDate = moment
.tz(updatedEvent.start, updatedEvent.timezone)
.format(i18next.t("common.datetimeformat"));
- diffText += `<li>` + i18next.t("routes.event.starttimechanged") + displayDate + `</li>`;
+ diffText += `<li>` + i18next.t("routes.event.starttimechanged", { starttime: displayDate }) + `</li>`;
}
if (event.end.toISOString() !== updatedEvent.end.toISOString()) {
displayDate = moment
.tz(updatedEvent.end, updatedEvent.timezone)
.format(i18next.t("common.datetimeformat"));
- diffText += `<li>` + i18next.t("routes.event.endtimechanged") + displayDate + `</li>`;
+ diffText += `<li>` + i18next.t("routes.event.endtimechanged", { endtime: displayDate }) + `</li>`;
}
if (event.timezone !== updatedEvent.timezone) {
- diffText += `<li>` + i18next.t("routes.event.timezonechanged") + updatedEvent.timezone + `</li>`;
+ diffText += `<li>` + i18next.t("routes.event.timezonechanged", { timezone: updatedEvent.timezone }) + `</li>`;
}
if (event.description !== updatedEvent.description) {
- diffText += `<li>` + i18next.t("routes.event.descriptionchanged") + `</li>`;
+ diffText += `<li>` + i18next.t("routes.event.descriptionchanged", { description: updatedEvent.description }) + `</li>`;
}
diffText += `</ul>`;
const updatedEventObject = await Event.findOneAndUpdate(
@@ -502,7 +502,7 @@ router.put(
sendEmailFromTemplate(
config.general.email,
attendeeEmails.join(","),
- `${event.name} ` + i18next.t("routes.event.editedsubject"),
+ i18next.t("routes.event.editedsubject", { eventname: event.name}),
"editEvent",
{
diffText,
diff --git a/src/util/validation.ts b/src/util/validation.ts
index 4ead7df..ccfc8d5 100644
--- a/src/util/validation.ts
+++ b/src/util/validation.ts
@@ -131,7 +131,7 @@ export const validateEventData = (
const errors: Error[] = [];
if (!validatedData.eventName) {
errors.push({
- message: i18next.t('validation.eventdata.eventname'),
+ message: i18next.t('util.validation.eventdata.eventname'),
field: "eventName",
});
}