diff --git a/.travis.yml b/.travis.yml index cd53568..a037667 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: rust +sudo: required +cache: cargo rust: - stable - beta @@ -16,4 +18,20 @@ matrix: allow_failures: - rust: nightly fast_finish: true -cache: cargo +addons: + apt: + packages: + - libcurl4-openssl-dev + - libelf-dev + - libdw-dev + - binutils-dev + - cmake + sources: + - kalakris-cmake + +cache: + directories: + - /home/travis/.cargo + +before_cache: + - rm -rf /home/travis/.cargo/registry diff --git a/src/lib.rs b/src/lib.rs index ba290e0..4385b23 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,6 +44,19 @@ //! assert_eq!("You are not allowed to do this", res); //! } //! ``` +//! +//! If the key is missing, your code will not compile + +//! ```rust,compile_fail +//! use internationalization::t; +//! +//! fn main() { +//! let lang = "en"; +//! let res = t!("missing key", lang); + +//! // Code will not compile +//! } +//! ``` //! ## Installation @@ -80,6 +93,15 @@ mod tests { #[test] fn it_translates() { assert_eq!(t!("key.test", "en"), "This is a test"); + assert_eq!(t!("key.test", "fr"), "C'est un test"); + assert_eq!( + t!("err.not_allowed", "fr"), + "Vous n'êtes pas autorisé à faire cela" + ); + assert_eq!( + t!("err.not_allowed", "en"), + "You are not allowed to do this" + ); } #[test] #[should_panic]