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:
+3
-1
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user