mirror of
https://github.com/keycloak/keycloak.git
synced 2026-02-09 16:58:58 -06:00
i18n for emails
This commit is contained in:
@@ -1,5 +1 @@
|
||||
Someone has created a Keycloak account with this email address. If this was you, click the link below to verify your email address:
|
||||
${link}
|
||||
This link will expire within ${linkExpiration} minutes.
|
||||
|
||||
If you didn't create this account, just ignore this message.
|
||||
${rb.emailVerificationBody?replace("{0}",link)?replace("{1}",linkExpiration)}
|
||||
@@ -1,5 +0,0 @@
|
||||
Someone has created a Keycloak account with this email address. If this was you, click the link below to verify your email address:
|
||||
${link}
|
||||
This link will expire within ${linkExpiration} minutes.
|
||||
|
||||
If you didn't create this account, just ignore this message.
|
||||
@@ -1,5 +0,0 @@
|
||||
Someone has created a Keycloak account with this email address. If this was you, click the link below to verify your email address:
|
||||
${link}
|
||||
This link will expire within ${linkExpiration} minutes.
|
||||
|
||||
If you didn't create this account, just ignore this message.
|
||||
@@ -1 +1 @@
|
||||
A failed login attempt was dettected to your account on ${event.date?datetime} from ${event.ipAddress}. If this was not you, please contact an admin.
|
||||
${rb.eventLoginErrorBody?replace("{0}",event.date?datetime)?replace("{1}",event.ipAddress)}
|
||||
@@ -1 +0,0 @@
|
||||
A failed login attempt was dettected to your account on ${event.date?datetime} from ${event.ipAddress}. If this was not you, please contact an admin.
|
||||
@@ -1 +0,0 @@
|
||||
A failed login attempt was dettected to your account on ${event.date?datetime} from ${event.ipAddress}. If this was not you, please contact an admin.
|
||||
@@ -1 +1 @@
|
||||
TOTP was removed from your account on ${event.date?datetime} from ${event.ipAddress}. If this was not you, please contact an admin.
|
||||
${rb.eventRemoveTotpBody?replace("{0}",event.date?datetime)?replace("{1}",event.ipAddress)}
|
||||
@@ -1 +0,0 @@
|
||||
TOTP was removed from your account on ${event.date?datetime} from ${event.ipAddress}. If this was not you, please contact an admin.
|
||||
@@ -1 +0,0 @@
|
||||
TOTP was removed from your account on ${event.date?datetime} from ${event.ipAddress}. If this was not you, please contact an admin.
|
||||
@@ -1 +1 @@
|
||||
Your password was changed on ${event.date?datetime} from ${event.ipAddress}. If this was not you, please contact an admin.
|
||||
${rb.eventUpdatePasswordBody?replace("{0}",event.date?datetime)?replace("{1}",event.ipAddress)}
|
||||
@@ -1 +0,0 @@
|
||||
Your password was changed on ${event.date?datetime} from ${event.ipAddress}. If this was not you, please contact an admin.
|
||||
@@ -1 +0,0 @@
|
||||
Your password was changed on ${event.date?datetime} from ${event.ipAddress}. If this was not you, please contact an admin.
|
||||
@@ -1 +1 @@
|
||||
TOTP was updated for your account on ${event.date?datetime} from ${event.ipAddress}. If this was not you, please contact an admin.
|
||||
${rb.eventUpdateTotpBody?replace("{0}",event.date?datetime)?replace("{1}",event.ipAddress)}
|
||||
@@ -1 +0,0 @@
|
||||
TOTP was updated for your account on ${event.date?datetime} from ${event.ipAddress}. If this was not you, please contact an admin.
|
||||
@@ -1 +0,0 @@
|
||||
TOTP was updated for your account on ${event.date?datetime} from ${event.ipAddress}. If this was not you, please contact an admin.
|
||||
@@ -1,2 +1,12 @@
|
||||
emailVerificationSubject=Verify email
|
||||
passwordResetSubject=Reset password
|
||||
emailVerificationBody=Someone has created a Keycloak account with this email address. If this was you, click the link below to verify your email address\n\n{0}\n\nThis link will expire within {1} minutes.\n\nIf you didn't create this account, just ignore this message.
|
||||
passwordResetSubject=Reset password
|
||||
passwordResetBody=Someone just requested to change your Keycloak account's password. If this was you, click on the link below to set a new password\n\n{0}\n\nThis link will expire within {1} minutes.\n\nIf you don't want to reset your password, just ignore this message and nothing will be changed.
|
||||
eventLoginErrorSubject=Login error
|
||||
eventLoginErrorBody=A failed login attempt was dettected to your account on {0} from {1}. If this was not you, please contact an admin.
|
||||
eventRemoveTotpSubject=Remove TOTP
|
||||
eventRemoveTotpBody=TOTP was removed from your account on {0} from {1}. If this was not you, please contact an admin.
|
||||
eventUpdatePasswordSubject=Update password
|
||||
eventUpdatePasswordBody=Your password was changed on {0} from {1}. If this was not you, please contact an admin.
|
||||
eventUpdateTotpSubject=Update TOTP
|
||||
eventUpdateTotpBody=TOTP was updated for your account on {0} from {1}. If this was not you, please contact an admin.
|
||||
|
||||
@@ -1,2 +1,12 @@
|
||||
emailVerificationSubject=Verify email
|
||||
passwordResetSubject=Passwort zurücksetzen
|
||||
passwordResetSubject=Passwort zur\u00fcckzusetzen
|
||||
passwordResetBody=Jemand hat angeforder Ihr Keycloak Passwort zur\u00fcckzusetzen. Falls das Sie waren, dann klicken Sie auf den folgenden Link um das Passwort zur\u00fcckzusetzen.\n\n{0}\n\nDieser Link wird in {1} Minuten ablaufen.\n\nFalls Sie das Passwort nicht zur\u00fccksetzen mu\u00f6chten, dann k\u00f6nnen Sie diese E-Mail ignorieren.
|
||||
emailVerificationBody=Someone has created a Keycloak account with this email address. If this was you, click the link below to verify your email address\n\n{0}\n\nThis link will expire within {1} minutes.\n\nIf you didn't create this account, just ignore this message.
|
||||
eventLoginErrorSubject=Login error
|
||||
eventLoginErrorBody=A failed login attempt was dettected to your account on {0} from {1}. If this was not you, please contact an admin.
|
||||
eventRemoveTotpSubject=Remove TOTP
|
||||
eventRemoveTotpBody=TOTP was removed from your account on {0} from {1}. If this was not you, please contact an admin.
|
||||
eventUpdatePasswordSubject=Update password
|
||||
eventUpdatePasswordBody=Your password was changed on {0} from {1}. If this was not you, please contact an admin.
|
||||
eventUpdateTotpSubject=Update TOTP
|
||||
eventUpdateTotpBody=TOTP was updated for your account on {0} from {1}. If this was not you, please contact an admin.
|
||||
|
||||
@@ -1,2 +1,12 @@
|
||||
emailVerificationSubject=Verify email
|
||||
passwordResetSubject=Reset password
|
||||
emailVerificationBody=Someone has created a Keycloak account with this email address. If this was you, click the link below to verify your email address\n\n{0}\n\nThis link will expire within {1} minutes.\n\nIf you didn't create this account, just ignore this message.
|
||||
passwordResetSubject=Reset password
|
||||
passwordResetBody=Someone just requested to change your Keycloak account's password. If this was you, click on the link below to set a new password\n\n{0}\n\nThis link will expire within {1} minutes.\n\nIf you don't want to reset your password, just ignore this message and nothing will be changed.
|
||||
eventLoginErrorSubject=Login error
|
||||
eventLoginErrorBody=A failed login attempt was dettected to your account on {0} from {1}. If this was not you, please contact an admin.
|
||||
eventRemoveTotpSubject=Remove TOTP
|
||||
eventRemoveTotpBody=TOTP was removed from your account on {0} from {1}. If this was not you, please contact an admin.
|
||||
eventUpdatePasswordSubject=Update password
|
||||
eventUpdatePasswordBody=Your password was changed on {0} from {1}. If this was not you, please contact an admin.
|
||||
eventUpdateTotpSubject=Update TOTP
|
||||
eventUpdateTotpBody=TOTP was updated for your account on {0} from {1}. If this was not you, please contact an admin.
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
Someone just requested to change your Keycloak account's password. If this was you, click on the link below to set a new password:
|
||||
${link}
|
||||
This link will expire within ${linkExpiration} minutes.
|
||||
|
||||
If you don't want to reset your password, just ignore this message and nothing will be changed.
|
||||
${rb.passwordResetBody?replace("{0}",link)?replace("{1}",linkExpiration)}
|
||||
@@ -1,5 +0,0 @@
|
||||
Jemand hat angeforder ihr Passwort zurück zu setzen:
|
||||
${link}
|
||||
This link will expire within ${linkExpiration} minutes.
|
||||
|
||||
If you don't want to reset your password, just ignore this message and nothing will be changed.
|
||||
@@ -1,5 +0,0 @@
|
||||
Someone just requested to change your Keycloak account's password. If this was you, click on the link below to set a new password:
|
||||
${link}
|
||||
This link will expire within ${linkExpiration} minutes.
|
||||
|
||||
If you don't want to reset your password, just ignore this message and nothing will be changed.
|
||||
@@ -5,6 +5,7 @@ import org.keycloak.email.EmailException;
|
||||
import org.keycloak.email.EmailProvider;
|
||||
import org.keycloak.email.freemarker.beans.EventBean;
|
||||
import org.keycloak.events.Event;
|
||||
import org.keycloak.events.EventType;
|
||||
import org.keycloak.freemarker.FreeMarkerUtil;
|
||||
import org.keycloak.freemarker.LocaleHelper;
|
||||
import org.keycloak.freemarker.Theme;
|
||||
@@ -54,7 +55,7 @@ public class FreeMarkerEmailProvider implements EmailProvider {
|
||||
Map<String, Object> attributes = new HashMap<String, Object>();
|
||||
attributes.put("event", new EventBean(event));
|
||||
|
||||
send("passwordResetSubject", getTemplate("event-" + event.getType().toString().toLowerCase()), attributes);
|
||||
send(toCamelCase(event.getType()) + "Subject", "event-" + event.getType().toString().toLowerCase() + ".ftl", attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +64,7 @@ public class FreeMarkerEmailProvider implements EmailProvider {
|
||||
attributes.put("link", link);
|
||||
attributes.put("linkExpiration", expirationInMinutes);
|
||||
|
||||
send("passwordResetSubject", getTemplate("password-reset"), attributes);
|
||||
send("passwordResetSubject", "password-reset.ftl", attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,15 +73,18 @@ public class FreeMarkerEmailProvider implements EmailProvider {
|
||||
attributes.put("link", link);
|
||||
attributes.put("linkExpiration", expirationInMinutes);
|
||||
|
||||
send("emailVerificationSubject", getTemplate("email-verification"), attributes);
|
||||
send("emailVerificationSubject", "email-verification.ftl", attributes);
|
||||
}
|
||||
|
||||
private void send(String subjectKey, String template, Map<String, Object> attributes) throws EmailException {
|
||||
try {
|
||||
ThemeProvider themeProvider = session.getProvider(ThemeProvider.class, "extending");
|
||||
Theme theme = themeProvider.getTheme(realm.getEmailTheme(), Theme.Type.EMAIL);
|
||||
|
||||
String subject = theme.getMessages(LocaleHelper.getLocale(realm,user)).getProperty(subjectKey);
|
||||
Locale locale = LocaleHelper.getLocale(realm, user);
|
||||
attributes.put("locale", locale);
|
||||
Properties rb = theme.getMessages(locale);
|
||||
attributes.put("rb", rb);
|
||||
String subject = rb.getProperty(subjectKey);
|
||||
String body = freeMarker.processTemplate(attributes, template, theme);
|
||||
|
||||
send(subject, body);
|
||||
@@ -148,14 +152,12 @@ public class FreeMarkerEmailProvider implements EmailProvider {
|
||||
public void close() {
|
||||
}
|
||||
|
||||
private String getTemplate(String name){
|
||||
StringBuilder sb = new StringBuilder(name);
|
||||
Locale locale = LocaleHelper.getLocale(realm, user);
|
||||
if(locale!=null){
|
||||
sb.append("_").append(locale.toString());
|
||||
private String toCamelCase(EventType event){
|
||||
StringBuilder sb = new StringBuilder("event");
|
||||
for(String s : event.name().toString().toLowerCase().split("_")){
|
||||
sb.append(s.substring(0,1).toUpperCase()).append(s.substring(1));
|
||||
}
|
||||
sb.append(".ftl");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user