unified translation of events and event-related emails

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-01-16 23:37:35 +01:00
parent 30651af62f
commit 5c36ab23bf
14 changed files with 94 additions and 74 deletions

View File

@@ -14,7 +14,7 @@ import java.util.*;
import org.json.JSONArray;
import org.json.JSONObject;
public record Message(UmbrellaUser sender, String subject, String body, Map<String,String> fills, List<Attachment> attachments) {
public record Message(UmbrellaUser sender, Translatable subject, Translatable body, List<Attachment> attachments) {
@Override
public boolean equals(Object o) {
if (!(o instanceof Message message)) return false;
@@ -43,7 +43,7 @@ public record Message(UmbrellaUser sender, String subject, String body, Map<Stri
}
}
}
return new Message(sender,subject,body,null, attachments);
return new Message(sender,new UnTranslatable(subject),new UnTranslatable(body),attachments);
}
@Override

View File

@@ -1,13 +1,15 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.model;
import static de.srsoftware.tools.Optionals.*;
import de.srsoftware.umbrella.core.ModuleRegistry;
import java.util.HashMap;
import java.util.Map;
public class Translatable {
private final String message;
private Map<String, Object> fills;
protected final String message;
private final Map<String, Object> fills;
private final HashMap<String,String> translated = new HashMap<>();
public Translatable(String message, Map<String,Object> fills){
@@ -39,7 +41,7 @@ public class Translatable {
}
public String translate(String language){
var translation = language != null ? translated.get(language) : null;
var translation = language == null ? null : translated.get(language);
if (translation == null){
var translatedFills = new HashMap<String,String>();
if (fills != null) {
@@ -54,7 +56,7 @@ public class Translatable {
}
}
translation = ModuleRegistry.translator().translate(language,message,translatedFills);
if (translation != null) translated.put(language,translation);
if (allSet(language, translation)) translated.put(language,translation);
}
return translation;
}

View File

@@ -0,0 +1,14 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.model;
public class UnTranslatable extends Translatable{
public UnTranslatable(String message) {
super(message, null);
}
public String translate(String language){
return message;
}
}