working on backend-side translations

This commit is contained in:
2025-12-15 22:49:17 +01:00
parent c7b5b11f4c
commit 8575a9a3a4
6 changed files with 77 additions and 46 deletions

View File

@@ -3,8 +3,7 @@ package de.srsoftware.umbrella.core;
import static de.srsoftware.tools.Optionals.nullable;
import static de.srsoftware.umbrella.core.ModuleRegistry.translator;
import static java.lang.System.Logger.Level.DEBUG;
import static java.lang.System.Logger.Level.WARNING;
import static java.lang.System.Logger.Level.*;
import static java.net.HttpURLConnection.*;
import static java.text.MessageFormat.format;
@@ -74,8 +73,13 @@ public abstract class BaseHandler extends PathHandler {
}
public boolean send(HttpExchange ex, UmbrellaException e) throws IOException {
var cause = e.getCause();
String lang = languages(ex).stream().findFirst().orElse(null);
var translatedMessage = translator().translate(lang,e.getMessage());
if (cause != null){
var msg = "en".equals(lang) ? translatedMessage : translator().translate("en",e.getMessage());
LOG.log(ERROR,format(msg,e.fills()),cause);
}
return sendContent(ex,e.statusCode(),format(translatedMessage,e.fills()));
}

View File

@@ -14,7 +14,6 @@ public class Errors {
public static final String FAILED_TO_DROP_ENTITY_OF_ENTITY = "failed_to_drop_entity_from_entity";
public static final String FAILED_TO_DROP_NOTES = "failed_to_drop_notes";
public static final String FAILED_TO_GET_FREE_ID = "failed_to_get_free_id";
public static final String FAILED_TO_INSERT_PROJECT = "failed_to_insert_project";
public static final String FAILED_TO_LIST_ENTITIES = "failed_to_list_entities";
public static final String FAILED_TO_LOAD_CHILD_LOCATIONS = "failed_to_load_child_locations";
public static final String FAILED_TO_LOAD_ENTITY_MEMBERS = "failed_to_load_entity_members";
@@ -24,7 +23,6 @@ public class Errors {
public static final String FAILED_TO_LOAD_CUSTOMER_SETTINGS = "failed_to_load_customer_settings";
public static final String FAILED_TO_LOAD_ENTITY = "failed_to_load_entity";
public static final String FAILED_TO_LOAD_ENTITY_BY_ID = "failed_to_load_entity_by_id";
public static final String FAILED_TO_LOAD_USER_COMPANIES = "failed_to_load_user_companies";
public static final String FAILED_TO_LOAD_USER_SETTINGS = "failed_to_load_user_settings";
public static final String FAILED_TO_MOVE = "failed_to_move";
public static final String FAILED_TO_READ_LAST_DOCID = "failed_to_read_last_docId";