Compile .po files

Since cargo is usually not run as root, we can't install .mo files to the standard location (/usr/local/share/locale/),
so we install them to ./translations and load them from there.
This commit is contained in:
Bat
2018-06-15 18:43:24 +01:00
parent 978104b518
commit 7313f60d14
4 changed files with 26 additions and 9 deletions
+3 -1
View File
@@ -1,5 +1,7 @@
use gettextrs::*;
use rocket::{Data, Request, Rocket, fairing::{Fairing, Info, Kind}};
use std::fs;
use std::path::PathBuf;
const ACCEPT_LANG: &'static str = "Accept-Language";
@@ -24,7 +26,7 @@ impl Fairing for I18n {
}
fn on_attach(&self, rocket: Rocket) -> Result<Rocket, Rocket> {
bindtextdomain(self.domain, "/usr/local/share/locale");
bindtextdomain(self.domain, fs::canonicalize(&PathBuf::from("./translations")).unwrap().to_str().unwrap());
textdomain(self.domain);
Ok(rocket)
}