feat(i18n): add i18n on server side

- remove the hardcoded list of locales in favor of a discovry on start time
    - server will stop on badly formatted locale .json
    - add server.* entries for serer side translation

    server side translation will be used for templating and email
    note: no json in some embded html (like in /magic), amount of work was similar
This commit is contained in:
Edouard Vanbelle
2026-06-03 13:18:05 +02:00
parent e0f59aa942
commit 044bd76738
32 changed files with 1520 additions and 149 deletions
+3 -2
View File
@@ -51,11 +51,12 @@ impl I18nHandler {
None => None,
};
let resolved_locale = locale.clone().unwrap_or_default();
match service.translate(&query.key, locale).await {
Ok(text) => {
let response = TranslationResponseDto {
key: query.key,
locale: locale.unwrap_or(Locale::default()).as_str().to_string(),
locale: resolved_locale.as_str().to_string(),
text,
};
(StatusCode::OK, Json(response)).into_response()
@@ -75,7 +76,7 @@ impl I18nHandler {
let error = TranslationErrorDto {
key: query.key,
locale: locale.unwrap_or(Locale::default()).as_str().to_string(),
locale: resolved_locale.as_str().to_string(),
error: error_msg,
};