Wait for process to finish successfully

Fix #7
Change gettext to an existing repository
Update to rocket 0.4.0-rc.1
Require newer rust toolchain
This commit is contained in:
Trinity Pointard 2018-11-01 19:11:16 +01:00 committed by Baptiste Gelez
parent 7fa1b0bd6b
commit c76d8381a0
3 changed files with 14 additions and 11 deletions

View file

@ -12,8 +12,8 @@ version = "0.2.0"
[dependencies]
serde_json = "1.0"
tera = "0.11"
gettext = { git = "https://github.com/BaptisteGelez/gettext", rev = "343ce3a33ae52c393cfd8f6f6403eb1dda542186" }
rocket = { git = "https://github.com/SergioBenitez/Rocket", rev = "55459db7732b9a240826a5c120c650f87e3372ce" }
gettext = { git = "https://github.com/justinas/gettext", rev = "e9213976f2e3d418ad367e1bf19bd98f47a42440" }
rocket = "0.4.0-rc.1"
[features]
build = []

View file

@ -1 +1 @@
nightly-2018-07-17
nightly-2018-10-31

View file

@ -101,11 +101,11 @@ use std::fs;
const ACCEPT_LANG: &'static str = "Accept-Language";
/// A request guard to get the right translation catalog for the current request
pub struct I18n<'a> {
pub catalog: Catalog<'a>,
pub struct I18n {
pub catalog: Catalog,
}
type Translations<'a> = Vec<(&'static str, Catalog<'a>)>;
type Translations = Vec<(&'static str, Catalog)>;
pub fn i18n(lang: Vec<&'static str>) -> Translations {
lang.iter().fold(Vec::new(), |mut trans, l| {
@ -117,10 +117,10 @@ pub fn i18n(lang: Vec<&'static str>) -> Translations {
})
}
impl<'a, 'r> FromRequest<'a, 'r> for I18n<'r> {
impl<'a, 'r> FromRequest<'a, 'r> for I18n{
type Error = ();
fn from_request(req: &'a Request<'r>) -> request::Outcome<I18n<'r>, ()> {
fn from_request(req: &'a Request) -> request::Outcome<I18n, ()> {
let langs = &*req
.guard::<State<Translations>>()
.expect("Couldn't retrieve translations because they are not managed by Rocket.");
@ -160,7 +160,8 @@ pub fn update_po(domain: &str) {
.arg("-U")
.arg(po_path.to_str().unwrap())
.arg(pot_path.to_str().unwrap())
.spawn()
.status()
.map(|s| if !s.success() { panic!("Couldn't update PO file") })
.expect("Couldn't update PO file");
} else {
println!("Creating {}", lang.clone());
@ -171,7 +172,8 @@ pub fn update_po(domain: &str) {
.arg("-l")
.arg(lang)
.arg("--no-translator")
.spawn()
.status()
.map(|s| if !s.success() { panic!("Couldn't init PO file") })
.expect("Couldn't init PO file");
}
}
@ -191,7 +193,8 @@ fn compile_po() {
Command::new("msgfmt")
.arg(format!("--output-file={}", mo_path.to_str().unwrap()))
.arg(po_path)
.spawn()
.status()
.map(|s| if !s.success() { panic!("Couldn't compile translations") })
.expect("Couldn't compile translations");
}
}