Browse Source

working on german translation

lang_de
Stephan Richter 2 years ago
parent
commit
3ce5d8e8f3
  1. 6
      src/main/java/de/srsoftware/widerhall/data/MailingList.java
  2. 52
      src/main/java/de/srsoftware/widerhall/web/Rest.java

6
src/main/java/de/srsoftware/widerhall/data/MailingList.java

@ -356,7 +356,7 @@ public class MailingList {
try { try {
sendConfirmationRequest(user, member.token()); sendConfirmationRequest(user, member.token());
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new MessagingException(t("Failed to send email to {}",user.email()),e); throw new MessagingException(t("Senden der Email an {} fehlgeschlagen",user.email()),e);
} }
} }
@ -368,8 +368,8 @@ public class MailingList {
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
*/ */
public void test(User user) throws MessagingException, UnsupportedEncodingException { public void test(User user) throws MessagingException, UnsupportedEncodingException {
var subject = t("{}: test mail",name()); var subject = t("{}: Test-Mail",name());
var text = "If you received this mail, the SMTP settings of your mailing list are correct."; var text = "Wenn Sie diese Nachricht empfangen haben, sind die SMTP-Einstellungen Ihrer Mailing-Liste korrekt.";
smtp.login().send(email(),name(),user.email(),subject,text); smtp.login().send(email(),name(),user.email(),subject,text);
} }
} }

52
src/main/java/de/srsoftware/widerhall/web/Rest.java

@ -44,15 +44,15 @@ public class Rest extends HttpServlet {
try { try {
int perm = Integer.parseInt(permissions); int perm = Integer.parseInt(permissions);
var user = User.loadAll(List.of(userEmail)).stream().findAny().orElse(null); var user = User.loadAll(List.of(userEmail)).stream().findAny().orElse(null);
if (user == null) return Map.of(ERROR,t("Failed to load user for address {}",userEmail)); if (user == null) return Map.of(ERROR,t("Laden des Nutzers für die Adresse {} fehlgeschlagen",userEmail));
user.addPermission(perm); user.addPermission(perm);
} catch (NumberFormatException nfe){ } catch (NumberFormatException nfe){
return Map.of(ERROR,"no valid permissions provided!"); return Map.of(ERROR,"Keine gültigen Berechtigungen übergeben!");
} catch (SQLException e) { } catch (SQLException e) {
LOG.debug("Failed to load user for address {}",userEmail,e); LOG.debug("Laden des Nutzers für die Adresse {} fehlgeschlagen",userEmail,e);
return Map.of(ERROR,t("Failed to load user for address {}",userEmail)); return Map.of(ERROR,t("Laden des Nutzers für die Adresse {} fehlgeschlagen",userEmail));
} }
return Map.of(SUCCESS,"Updated user permissions"); return Map.of(SUCCESS,"Nutzer-Berechtigungen aktualisiert");
} }
@Override @Override
@ -68,19 +68,19 @@ public class Rest extends HttpServlet {
} }
private Map dropPermission(String userEmail, String permissions) { private Map dropPermission(String userEmail, String permissions) {
if (userEmail == null || userEmail.isBlank()) return Map.of(ERROR,"missing user email address!"); if (userEmail == null || userEmail.isBlank()) return Map.of(ERROR,"Nutzer-Emailadresse fehlt!");
try { try {
int perm = Integer.parseInt(permissions); int perm = Integer.parseInt(permissions);
var user = User.loadAll(List.of(userEmail)).stream().findAny().orElse(null); var user = User.loadAll(List.of(userEmail)).stream().findAny().orElse(null);
if (user == null) return Map.of(ERROR,t("Failed to load user for address {}",userEmail)); if (user == null) return Map.of(ERROR,t("Laden des Nutzers für die Adresse {} fehlgeschlagen",userEmail));
user.dropPermission(perm); user.dropPermission(perm);
} catch (NumberFormatException nfe){ } catch (NumberFormatException nfe){
return Map.of(ERROR,"no valid permissions provided!"); return Map.of(ERROR,"Keine gültigen Berechtigungen übergeben!");
} catch (SQLException e) { } catch (SQLException e) {
LOG.debug("Failed to load user for address {}",userEmail,e); LOG.debug("Laden des Nutzers für die Adresse {} fehlgeschlagen",userEmail,e);
return Map.of(ERROR,t("Failed to load user for address {}",userEmail)); return Map.of(ERROR,t("Laden des Nutzers für die Adresse {} fehlgeschlagen",userEmail));
} }
return Map.of(SUCCESS,"Updated user permissions"); return Map.of(SUCCESS,"Nutzer-Berechtigungen aktualisiert");
} }
public String handleGet(HttpServletRequest req, HttpServletResponse resp){ public String handleGet(HttpServletRequest req, HttpServletResponse resp){
@ -95,8 +95,8 @@ public class Rest extends HttpServlet {
try { try {
json.put("users", (user.hashPermission(User.PERMISSION_ADMIN) ? User.loadAll() : List.of(user)).stream().map(User::safeMap).toList()); json.put("users", (user.hashPermission(User.PERMISSION_ADMIN) ? User.loadAll() : List.of(user)).stream().map(User::safeMap).toList());
} catch (SQLException e) { } catch (SQLException e) {
LOG.debug("Failed to load user list:",e); LOG.debug("Laden der Nutzerliste fehlgeschlagen:",e);
json.put(ERROR,"failed to load user list"); json.put(ERROR,"Laden der Nutzerliste fehlgeschlagen");
} }
break; break;
case LIST_EDITABLE: case LIST_EDITABLE:
@ -105,7 +105,7 @@ public class Rest extends HttpServlet {
case LIST_SUBSCRIBABLE: case LIST_SUBSCRIBABLE:
json.put("lists", MailingList.subscribable(user).stream().map(MailingList::minimalMap).toList()); json.put("lists", MailingList.subscribable(user).stream().map(MailingList::minimalMap).toList());
default: default:
json.put(ERROR,t("No handler for path '{}'!",path)); json.put(ERROR,t("Kein Handler für den Pfad '{}'!",path));
break; break;
} }
} else { } else {
@ -114,7 +114,7 @@ public class Rest extends HttpServlet {
json.put("lists", MailingList.subscribable().stream().map(MailingList::minimalMap).toList()); json.put("lists", MailingList.subscribable().stream().map(MailingList::minimalMap).toList());
break; break;
default: default:
json.put(ERROR,"Not logged in!"); json.put(ERROR,"Nicht eingeloggt!");
} }
} }
try { try {
@ -122,7 +122,7 @@ public class Rest extends HttpServlet {
resp.getWriter().println(json.toJSONString()); resp.getWriter().println(json.toJSONString());
return null; return null;
} catch (IOException e) { } catch (IOException e) {
return t("Failed to handle request: {}",e.getMessage()); return t("Konnte Anfrage nicht verarbeiten: {}",e.getMessage());
} }
} }
@ -160,26 +160,26 @@ public class Rest extends HttpServlet {
case USER_ADD_PERMISSION: case USER_ADD_PERMISSION:
if (user.hashPermission(User.PERMISSION_ADMIN)){ if (user.hashPermission(User.PERMISSION_ADMIN)){
json.putAll(addPermission(userEmail,permissions)); json.putAll(addPermission(userEmail,permissions));
} else json.put(ERROR,"You are not allowed to alter user permissions!"); } else json.put(ERROR,"Sie haben nicht die Berechtigung, um Berechtigungen zu ändern!");
break; break;
case USER_DROP_PERMISSION: case USER_DROP_PERMISSION:
if (user.hashPermission(User.PERMISSION_ADMIN)){ if (user.hashPermission(User.PERMISSION_ADMIN)){
json.putAll(dropPermission(userEmail,permissions)); json.putAll(dropPermission(userEmail,permissions));
} else json.put(ERROR,"You are not allowed to alter user permissions!"); } else json.put(ERROR,"Sie haben nicht die Berechtigung, um Berechtigungen zu ändern!");
break; break;
default: default:
json.put(ERROR,t("No handler for path '{}'!",path)); json.put(ERROR,t("Kein Handler für den Pfad '{}'!",path));
break; break;
} }
} else { } else {
json.put(ERROR,"Not logged in!"); json.put(ERROR,"Nicht eingeloggt!");
} }
try { try {
resp.setContentType("application/json"); resp.setContentType("application/json");
resp.getWriter().println(json.toJSONString()); resp.getWriter().println(json.toJSONString());
return null; return null;
} catch (IOException e) { } catch (IOException e) {
return t("Failed to handle request: {}",e.getMessage()); return t("Konnte Anfrage nicht verarbeiten: {}",e.getMessage());
} }
} }
@ -198,11 +198,11 @@ public class Rest extends HttpServlet {
.toList(); .toList();
return Map.of(MEMBERS,members); return Map.of(MEMBERS,members);
} catch (SQLException e) { } catch (SQLException e) {
LOG.error("Failed to load member list: ",e); LOG.error("Laden der Mitglieder-Liste fehlgeschlagen: ",e);
return Map.of("error",t("Failed to load member list '{}'",listEmail)); return Map.of("error",t("Laden der Mitglieder-Liste von '{}' fehlgeschlagen",listEmail));
} }
} }
return Map.of("error",t("You are not allowed to list members '{}'",listEmail)); return Map.of("error",t("Sie haben nicht die Berechtigng, um die Mitglieder von '{}' aufzulisten.",listEmail));
} }
private Map enableList(String listEmail, User user, boolean enable) { private Map enableList(String listEmail, User user, boolean enable) {
@ -210,9 +210,9 @@ public class Rest extends HttpServlet {
if (user.hashPermission(User.PERMISSION_ADMIN) || ListMember.listsOwnedBy(user).contains(listEmail)){ if (user.hashPermission(User.PERMISSION_ADMIN) || ListMember.listsOwnedBy(user).contains(listEmail)){
try { try {
MailingList.load(listEmail).enable(enable); MailingList.load(listEmail).enable(enable);
return Map.of(SUCCESS,t("Mailing list '{}' was {}!",listEmail,enable ? "enabled" : "disabled")); return Map.of(SUCCESS,t("Mailing-List '{}' wurde {}!",listEmail,enable ? "aktiviert" : "inaktiviert"));
} catch (SQLException e) { } catch (SQLException e) {
LOG.error("Failed to enable/disable mailing list: ",e); LOG.error("Aktivieren/Inaktivieren der Mailing-Liste fehlgeschlagen: ",e);
return Map.of("error",t("Failed to update list '{}'",listEmail)); return Map.of("error",t("Failed to update list '{}'",listEmail));
} }
} }

Loading…
Cancel
Save