mirror of
https://git.42l.fr/neil/sncf.git
synced 2024-04-27 19:52:45 +02:00
fixing crash with missing translations (#3)
This commit is contained in:
parent
0b019ab691
commit
c76d3e5a68
|
@ -41,17 +41,17 @@ mod filters {
|
|||
use crate::config::LOC;
|
||||
|
||||
pub fn tr(key: &str, lang: &str) -> askama::Result<String> {
|
||||
let translation = LOC.get(key).ok_or_else(|| {
|
||||
eprintln!("tr filter: couldn't find the key {}", key);
|
||||
askama::Error::from(std::fmt::Error)
|
||||
})?;
|
||||
Ok(String::from(
|
||||
LOC.get(key)
|
||||
.ok_or_else(|| {
|
||||
eprintln!("tr filter: couldn't find the key {}", key);
|
||||
askama::Error::from(std::fmt::Error)
|
||||
})?
|
||||
translation
|
||||
.get(lang)
|
||||
.ok_or_else(|| {
|
||||
.unwrap_or(translation.get("en").ok_or_else(|| {
|
||||
eprintln!("tr filter: couldn't find the lang {} in key {}", lang, key);
|
||||
askama::Error::from(std::fmt::Error)
|
||||
})?
|
||||
})?)
|
||||
.as_str()
|
||||
.ok_or_else(|| {
|
||||
eprintln!("tr filter: lang {} in key {} is not str", lang, key);
|
||||
|
|
Loading…
Reference in a new issue