From c9c32eea65fc723d8c90ef54dec59b1b8e6bceb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Fri, 23 Jul 2021 12:25:59 +0200 Subject: [PATCH] add a argument for i18n to enable csv generation --- voxygen/i18n/src/analysis.rs | 9 ++++++++- voxygen/i18n/src/bin/i18n-check.rs | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/voxygen/i18n/src/analysis.rs b/voxygen/i18n/src/analysis.rs index dcf8ec3f11..d0328e63a7 100644 --- a/voxygen/i18n/src/analysis.rs +++ b/voxygen/i18n/src/analysis.rs @@ -291,6 +291,7 @@ fn test_localization_directory( ref_manifest: &Path, i18n_references: &HashMap, be_verbose: bool, + csv_enabled: bool, repo: &git2::Repository, head_ref: &git2::Reference, ) -> Option { @@ -494,11 +495,14 @@ fn print_translation_stats( /// `root_dir` - absolute path to main repo /// `assets_path` - relative path to asset directory (right now it is /// 'assets/voxygen/i18n') +/// be_verbose - +/// csv_enabled - generate csv files in target folder pub fn test_specific_localization( code: &str, root_dir: &Path, assets_path: &Path, be_verbose: bool, + csv_enabled: bool, ) { // Relative paths from root of repo to assets let ref_lang_dir = assets_path.join(REFERENCE_LANG); @@ -533,6 +537,7 @@ pub fn test_specific_localization( &ref_manifest, &reference_i18n, be_verbose, + csv_enabled, &repo, &head_ref, ); @@ -542,7 +547,8 @@ pub fn test_specific_localization( /// `root_dir` - absolute path to main repo /// `assets_path` - relative path to asset directory (right now it is /// 'assets/voxygen/i18n') -pub fn test_all_localizations(root_dir: &Path, assets_path: &Path, be_verbose: bool) { +/// csv_enabled - generate csv files in target folder +pub fn test_all_localizations(root_dir: &Path, assets_path: &Path, be_verbose: bool, csv_enabled: bool) { let ref_lang_dir = assets_path.join(REFERENCE_LANG); let ref_manifest = ref_lang_dir.join(LANG_MANIFEST_FILE.to_string() + ".ron"); @@ -585,6 +591,7 @@ pub fn test_all_localizations(root_dir: &Path, assets_path: &Path, be_verbose: b &ref_manifest, &reference_i18n, be_verbose, + csv_enabled, &repo, &head_ref, ); diff --git a/voxygen/i18n/src/bin/i18n-check.rs b/voxygen/i18n/src/bin/i18n-check.rs index cc45d256bb..6af88157e7 100644 --- a/voxygen/i18n/src/bin/i18n-check.rs +++ b/voxygen/i18n/src/bin/i18n-check.rs @@ -28,11 +28,17 @@ fn main() { .long("verbose") .help("print additional information"), ) + .arg( + Arg::with_name("csv") + .long("csv") + .help("generate csv files per language in target folder"), + ) .get_matches(); // Generate paths let root = common_assets::find_root().expect("Failed to find root of repository"); let asset_path = Path::new("assets/voxygen/i18n/"); + let csv_enabled = matches.is_present("csv"); if let Some(code) = matches.value_of("CODE") { analysis::test_specific_localization( @@ -40,10 +46,11 @@ fn main() { &root, &asset_path, matches.is_present("verbose"), + csv_enabled, ); } if matches.is_present("test") { - analysis::test_all_localizations(&root, &asset_path, matches.is_present("verbose")); + analysis::test_all_localizations(&root, &asset_path, matches.is_present("verbose"), csv_enabled); } if matches.is_present("verify") { verification::verify_all_localizations(&root, &asset_path);