Added t!() macro

This commit is contained in:
ElBe
2023-10-06 07:39:56 +02:00
parent a8fd02158b
commit 163e31bb45
9 changed files with 154 additions and 31 deletions
+25 -1
View File
@@ -1,5 +1,5 @@
// localizer-rs tests
// Version: 1.1.1
// Version: 1.2.0
// Copyright (c) 2023-present ElBe Development.
@@ -80,6 +80,18 @@ mod tests {
#[test]
fn test_translate() {
let config: localizer_rs::Config = localizer_rs::Config::new("examples/translations", "en");
let translation: String =
config.translate("error", vec![("details", "Something went wrong")]);
assert_eq!(
translation.as_str(),
"\x1b[31m\x1b[1mError:\x1b[0m Something went wrong"
);
}
#[test]
fn test_translate_t() {
let config: localizer_rs::Config = localizer_rs::Config::new("examples/translations", "en");
let translation: String = config.t("error", vec![("details", "Something went wrong")]);
@@ -88,4 +100,16 @@ mod tests {
"\x1b[31m\x1b[1mError:\x1b[0m Something went wrong"
);
}
#[test]
fn test_translate_macro() {
let config: localizer_rs::Config = localizer_rs::Config::new("examples/translations", "en");
let translation: String =
localizer_rs::t!(config, "error", "details" = "Something went wrong");
assert_eq!(
translation.as_str(),
"\x1b[31m\x1b[1mError:\x1b[0m Something went wrong"
);
}
}