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:
@@ -23,8 +23,9 @@ impl I18nApplicationService {
|
||||
|
||||
/// Get a translation for a key and locale
|
||||
pub async fn translate(&self, key: &str, locale: Option<Locale>) -> I18nResult<String> {
|
||||
let locale = locale.unwrap_or_default();
|
||||
self.i18n_service.translate(key, locale).await
|
||||
self.i18n_service
|
||||
.translate(key, locale.unwrap_or_default())
|
||||
.await
|
||||
}
|
||||
|
||||
/// Load translations for a locale
|
||||
@@ -38,7 +39,7 @@ impl I18nApplicationService {
|
||||
let mut results = Vec::new();
|
||||
|
||||
for locale in locales {
|
||||
let result = self.i18n_service.load_translations(locale).await;
|
||||
let result = self.i18n_service.load_translations(locale.clone()).await;
|
||||
results.push((locale, result));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user