Skip to content

Commit

Permalink
added email translation for contact
Browse files Browse the repository at this point in the history
  • Loading branch information
carvalholuigi25 committed Nov 4, 2023
1 parent 53dfdd0 commit c43ea12
Show file tree
Hide file tree
Showing 21 changed files with 233 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.maxTokenizationLineLength": 20000000
}
13 changes: 13 additions & 0 deletions public/locales/ae.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": "د.إ"
},
"Templates": {
"Email": {
"lang": "ae",
"thankyoumsg": "شكرًا لاتصالك بنا! إليك الرسالة:",
"emaildate": "تاريخ:",
"emailto": "ل:",
"emailfrom": "من:",
"emailname": "اسم:",
"emailsubject": "المادة:",
"emailbody": "رسالة:",
"copyright": "م الإنشاء بواسطة لويس كارفاليو "
}
}
}
13 changes: 13 additions & 0 deletions public/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": ""
},
"Templates": {
"Email": {
"lang": "de",
"thankyoumsg": "Danke, dass Sie uns kontaktiert haben! Hier ist die Nachricht:",
"emaildate": "Datum:",
"emailto": "Zu:",
"emailfrom": "Von:",
"emailname": "Name:",
"emailsubject": "Thema:",
"emailbody": "Botschaft:",
"copyright": "Erstellt von"
}
}
}
13 changes: 13 additions & 0 deletions public/locales/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": "£"
},
"Templates": {
"Email": {
"lang": "en-GB",
"thankyoumsg": "Thank you for contact us! Here's the message:",
"emaildate": "Date:",
"emailto": "To:",
"emailfrom": "From:",
"emailname": "Name:",
"emailsubject": "Subject:",
"emailbody": "Body:",
"copyright": "Created by"
}
}
}
13 changes: 13 additions & 0 deletions public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": "$"
},
"Templates": {
"Email": {
"lang": "en-US",
"thankyoumsg": "Thank you for contact us! Here's the message:",
"emaildate": "Date:",
"emailto": "To:",
"emailfrom": "From:",
"emailname": "Name:",
"emailsubject": "Subject:",
"emailbody": "Body:",
"copyright": "Created by"
}
}
}
13 changes: 13 additions & 0 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": "£"
},
"Templates": {
"Email": {
"lang": "en",
"thankyoumsg": "Thank you for contact us! Here's the message:",
"emaildate": "Date:",
"emailto": "To:",
"emailfrom": "From:",
"emailname": "Name:",
"emailsubject": "Subject:",
"emailbody": "Body:",
"copyright": "Created by"
}
}
}
13 changes: 13 additions & 0 deletions public/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": ""
},
"Templates": {
"Email": {
"lang": "es",
"thankyoumsg": "¡Gracias por contactarnos! Aquí está el mensaje:",
"emaildate": "Fecha:",
"emailto": "Para:",
"emailfrom": "De:",
"emailname": "Nombre:",
"emailsubject": "Sujeto:",
"emailbody": "Mensaje:",
"copyright": "Creado por"
}
}
}
13 changes: 13 additions & 0 deletions public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": ""
},
"Templates": {
"Email": {
"lang": "fr",
"thankyoumsg": "Merci de nous contacter! Voici le message:",
"emaildate": "Date:",
"emailto": "Pour:",
"emailfrom": "Depuis:",
"emailname": "Nom:",
"emailsubject": "Sujet:",
"emailbody": "Message:",
"copyright": "Créé par"
}
}
}
13 changes: 13 additions & 0 deletions public/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": "$"
},
"Templates": {
"Email": {
"lang": "hi",
"thankyoumsg": "Mahalo no kou ho'oka'a'ike mai iā mākou! Eia ka memo:",
"emaildate": "La:",
"emailto": "I:",
"emailfrom": "Mai:",
"emailname": "Inoa:",
"emailsubject": "Ke kumuhana:",
"emailbody": "Memo:",
"copyright": "Hana 'ia e"
}
}
}
13 changes: 13 additions & 0 deletions public/locales/il.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": ""
},
"Templates": {
"Email": {
"lang": "il",
"thankyoumsg": "תודה שפנית אלינו! הנה ההודעה:",
"emaildate": "תַאֲרִיך:",
"emailto": "ל:",
"emailfrom": "מ:",
"emailname": "שֵׁם:",
"emailsubject": "נושא:",
"emailbody": "הוֹדָעָה:",
"copyright": "מיוצר ע'י"
}
}
}
13 changes: 13 additions & 0 deletions public/locales/in.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": ""
},
"Templates": {
"Email": {
"lang": "in",
"thankyoumsg": "हमसे संपर्क करने के लिए धन्यवाद! संदेश यह है:",
"emaildate": "तारीख:",
"emailto": "को:",
"emailfrom": "से:",
"emailname": "नाम:",
"emailsubject": "विषय:",
"emailbody": "संदेश:",
"copyright": "द्वारा निर्मित"
}
}
}
13 changes: 13 additions & 0 deletions public/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": ""
},
"Templates": {
"Email": {
"lang": "it",
"thankyoumsg": "Grazie per averci contattato! Ecco il messaggio:",
"emaildate": "Data:",
"emailto": "A:",
"emailfrom": "Da:",
"emailname": "Nome:",
"emailsubject": "Soggetto:",
"emailbody": "Messaggio:",
"copyright": "Creato da"
}
}
}
13 changes: 13 additions & 0 deletions public/locales/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": "¥"
},
"Templates": {
"Email": {
"lang": "jp",
"thankyoumsg": "「ご連絡いただきありがとうございます。メッセージは次のとおりです。」",
"emaildate": "日付:",
"emailto": "に:",
"emailfrom": "から:",
"emailname": "名前:",
"emailsubject": "主題:",
"emailbody": "メッセージ:",
"copyright": "によって作成された"
}
}
}
13 changes: 13 additions & 0 deletions public/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": ""
},
"Templates": {
"Email": {
"lang": "pt",
"thankyoumsg": "Obrigado por entrar em contato conosco! Aqui está a mensagem:",
"emaildate": "Data:",
"emailto": "Para:",
"emailfrom": "De:",
"emailname": "Nome:",
"emailsubject": "Assunto:",
"emailbody": "Mensagem:",
"copyright": "Criado por"
}
}
}
13 changes: 13 additions & 0 deletions public/locales/ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,18 @@
},
"Currency": {
"symbol": ""
},
"Templates": {
"Email": {
"lang": "ua",
"thankyoumsg": "Дякуємо за звернення до нас! Ось повідомлення:",
"emaildate": "Дата:",
"emailto": "Кому:",
"emailfrom": "Від:",
"emailname": "Ім'я:",
"emailsubject": "Тема:",
"emailbody": "Тіло:",
"copyright": "Створено"
}
}
}
19 changes: 16 additions & 3 deletions src/app/[locale]/components/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import React, { useState } from 'react';
import styles from '../styles/page/page.module.scss';
import { useTranslations } from 'next-intl';
import { useLocale, useTranslations } from 'next-intl';

export default function ContactComponent() {
const t = useTranslations('Home');
const temailtrans = useTranslations('Templates.Email');
const locale = useLocale();

const [name, setName] = useState("");
const [email, setEmail] = useState("");
Expand Down Expand Up @@ -35,10 +37,21 @@ export default function ContactComponent() {
name: name,
email: email,
subject: subject,
message: message
message: message,
translationmsgs: {
lang: temailtrans('lang'),
thankyoumsg: temailtrans('thankyoumsg'),
emaildate: temailtrans('emaildate'),
emailto: temailtrans('emailto'),
emailfrom: temailtrans('emailfrom'),
emailname: temailtrans('emailname'),
emailsubject: temailtrans('emailsubject'),
emailbody: temailtrans('emailbody'),
copyright: temailtrans('copyright')
}
});

fetch('/api/sendemail', {
fetch('/api/'+ locale +'/sendemail', {
method: "post",
body: formData,
headers: new Headers({
Expand Down
Binary file added src/app/[locale]/favicon.ico
Binary file not shown.
5 changes: 4 additions & 1 deletion src/app/[locale]/templates/email.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions src/app/api/[locale]/sendemail/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { NextResponse } from "next/server";
import { sendMailUtil } from '../../../[locale]/utils/sendmailUtils';
import { EmailTemplate } from '../../../[locale]/templates';

export async function POST(req: any) {
const body = await req.json();
const curpath = `${process.env.TYPEENV === 'production' ? 'https://lcp-pi.vercel.app' : './public'}`;
const attachmentsobj = [{
filename: 'logo_compact.png',
path: `${curpath}/images/logos/logo_compact.png`,
cid: 'uniquelogo'
}];

const dataobj = {
to: process.env.EMAIL_USER,
from: `"${body.name}" <${body.email}>`,
subject: body.subject,
text: `${body.message}\r\n Sent by ${body.email} (${body.name})`,
html: EmailTemplate(body, body.translationmsgs),
attachments: attachmentsobj
};

console.log(dataobj);

await sendMailUtil(dataobj);

return NextResponse.json({ dataobj });
}
25 changes: 0 additions & 25 deletions src/app/api/sendemail/route.ts

This file was deleted.

Binary file added src/app/favicon.ico
Binary file not shown.

0 comments on commit c43ea12

Please sign in to comment.