mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'xMAC94x/translation_tests' into 'master'
add a translation test that verifys that all language RON files are parseable... See merge request veloren/veloren!1271
This commit is contained in:
commit
150b5b48c5
@ -388,5 +388,9 @@ Siła woli
|
|||||||
"esc_menu.quit_game": "Opuść gre",
|
"esc_menu.quit_game": "Opuść gre",
|
||||||
/// End Escape Menu Section
|
/// End Escape Menu Section
|
||||||
/// Koniec sekcji Menu pauzy
|
/// Koniec sekcji Menu pauzy
|
||||||
}
|
},
|
||||||
|
|
||||||
|
vector_map: {
|
||||||
|
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
@ -17,6 +17,13 @@ VoxygenLocalization(
|
|||||||
language_identifier: "sv",
|
language_identifier: "sv",
|
||||||
),
|
),
|
||||||
convert_utf8_to_ascii: false,
|
convert_utf8_to_ascii: false,
|
||||||
|
// Make sure that fonts contain all swedisch characters
|
||||||
|
fonts: {
|
||||||
|
"opensans": Font (
|
||||||
|
asset_key: "voxygen.font.OpenSans-Regular",
|
||||||
|
scale_ratio: 1.0,
|
||||||
|
),
|
||||||
|
},
|
||||||
string_map: {
|
string_map: {
|
||||||
/// Start Common section
|
/// Start Common section
|
||||||
// Texts used in multiple locations with the same formatting
|
// Texts used in multiple locations with the same formatting
|
||||||
@ -332,5 +339,9 @@ Willpower
|
|||||||
"esc_menu.logout": "Logout",
|
"esc_menu.logout": "Logout",
|
||||||
"esc_menu.quit_game": "Quit Game",
|
"esc_menu.quit_game": "Quit Game",
|
||||||
/// End Escape Menu Section
|
/// End Escape Menu Section
|
||||||
}
|
},
|
||||||
|
|
||||||
|
vector_map: {
|
||||||
|
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
@ -377,5 +377,9 @@ Veloren 半夜會特別暗。
|
|||||||
"esc_menu.logout": "登出",
|
"esc_menu.logout": "登出",
|
||||||
"esc_menu.quit_game": "退出遊戲",
|
"esc_menu.quit_game": "退出遊戲",
|
||||||
/// End Escape Menu Section
|
/// End Escape Menu Section
|
||||||
}
|
},
|
||||||
|
|
||||||
|
vector_map: {
|
||||||
|
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
@ -180,7 +180,7 @@ pub fn i18n_asset_key(language_id: &str) -> String { "voxygen.i18n.".to_string()
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::VoxygenLocalization;
|
use super::VoxygenLocalization;
|
||||||
use git2::Repository;
|
use git2::Repository;
|
||||||
use ron::de::from_bytes;
|
use ron::de::{from_bytes, from_reader};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
fs,
|
fs,
|
||||||
@ -325,10 +325,49 @@ mod tests {
|
|||||||
keys
|
keys
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test to verify all languages that they are VALID and loadable, without
|
||||||
|
// need of git just on the local assets folder
|
||||||
|
#[test]
|
||||||
|
fn verify_all_localizations() {
|
||||||
|
// Generate paths
|
||||||
|
let i18n_asset_path = Path::new("assets/voxygen/i18n/");
|
||||||
|
let en_i18n_path = i18n_asset_path.join("en.ron");
|
||||||
|
let root_dir = std::env::current_dir()
|
||||||
|
.map(|p| p.parent().expect("").to_owned())
|
||||||
|
.unwrap();
|
||||||
|
assert!(
|
||||||
|
root_dir.join(&en_i18n_path).is_file(),
|
||||||
|
"en reference files doesn't exist, something is wrong!"
|
||||||
|
);
|
||||||
|
let i18n_files = i18n_files(&root_dir.join(i18n_asset_path));
|
||||||
|
// This simple check ONLY guarantees that an arbitrary minimum of translation
|
||||||
|
// files exists. It's just to notice unintentional deletion of all
|
||||||
|
// files, or modifying the paths. In case you want to delete all
|
||||||
|
// language you have to adjust this number:
|
||||||
|
assert!(
|
||||||
|
i18n_files.len() > 5,
|
||||||
|
"have less than 5 translation files, arbitrary minimum check failed. Maybe the i18n \
|
||||||
|
folder is empty?"
|
||||||
|
);
|
||||||
|
for path in i18n_files {
|
||||||
|
let f = fs::File::open(&path).expect("Failed opening file");
|
||||||
|
let _: VoxygenLocalization = match from_reader(f) {
|
||||||
|
Ok(v) => v,
|
||||||
|
Err(e) => {
|
||||||
|
panic!(
|
||||||
|
"Could not parse {} RON file, error: {}",
|
||||||
|
path.to_string_lossy(),
|
||||||
|
e
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test to verify all languages and print missing and faulty localisation
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
#[allow(clippy::expect_fun_call)]
|
#[allow(clippy::expect_fun_call)]
|
||||||
/// Test to verify all languages and print missing and faulty localisation
|
|
||||||
fn test_all_localizations() {
|
fn test_all_localizations() {
|
||||||
// Generate paths
|
// Generate paths
|
||||||
let i18n_asset_path = Path::new("assets/voxygen/i18n/");
|
let i18n_asset_path = Path::new("assets/voxygen/i18n/");
|
||||||
|
Loading…
Reference in New Issue
Block a user