Просмотр исходного кода

Merge pull request #4039 from weseek/imprv/gw6833-i18n-templete-file

apply i18n
Yuki Takei 4 лет назад
Родитель
Сommit
3fb744a90f
1 измененных файлов с 7 добавлено и 5 удалено
  1. 7 5
      src/server/routes/forgot-password.js

+ 7 - 5
src/server/routes/forgot-password.js

@@ -1,5 +1,5 @@
 module.exports = function(crowi, app) {
 module.exports = function(crowi, app) {
-  const { /* appService, */ mailService } = crowi;
+  const { /* appService, */ mailService, configManager } = crowi;
   const path = require('path');
   const path = require('path');
   const actions = {};
   const actions = {};
   const api = {};
   const api = {};
@@ -14,13 +14,12 @@ module.exports = function(crowi, app) {
   };
   };
 
 
 
 
-  async function sendPasswordResetEmail() {
+  async function sendPasswordResetEmail(i18n) {
 
 
     return mailService.send({
     return mailService.send({
       to: 'hoge@gmail.com',
       to: 'hoge@gmail.com',
       subject: 'forgotPasswordMailTest',
       subject: 'forgotPasswordMailTest',
-      // TODO: apply i18n by GW-6833
-      template: path.join(crowi.localeDir, 'en_US/notifications/passwordReset.txt'),
+      template: path.join(crowi.localeDir, `${i18n}/notifications/passwordReset.txt`),
       // TODO: need to set appropriate values by GW-6828
       // TODO: need to set appropriate values by GW-6828
       // vars: {
       // vars: {
       //   appTitle: appService.getAppTitle(),
       //   appTitle: appService.getAppTitle(),
@@ -31,7 +30,10 @@ module.exports = function(crowi, app) {
   }
   }
 
 
   api.post = async function(req, res) {
   api.post = async function(req, res) {
-    await sendPasswordResetEmail();
+    const grobalLang = configManager.getConfig('crowi', 'app:globalLang');
+    const i18n = req.language || grobalLang;
+
+    await sendPasswordResetEmail(i18n);
     return;
     return;
   };
   };