diff --git a/locales/readme.yml b/locales/readme.yml new file mode 100644 index 0000000..f5d84df --- /dev/null +++ b/locales/readme.yml @@ -0,0 +1,37 @@ +_version: 2 +dir: + en: Dir + zh_CN: 目录 + zh_TW: 目錄 + fr: Rép + ja: ディレクトリ + es: Dir + de: Verz + ru: Дир + it: Dir + pt: Dir + ko: 디렉토리 + no: Mappe + is: Mappa + uk: Тека + th: ไดเรกทอรี + el: Φάκελος + da: Bibliotek +file: + en: File + zh_CN: 文件 + zh_TW: 檔案 + fr: Fichier + ja: ファイル + es: Archivo + de: Datei + ru: Файл + it: File + pt: Arquivo + ko: 파일 + no: Fil + is: Skrá + uk: Файл + th: ไฟล์ + el: Αρχείο + da: Fil \ No newline at end of file diff --git a/src/utils/directory2md.rs b/src/utils/directory2md.rs index 2e648bc..37f532b 100644 --- a/src/utils/directory2md.rs +++ b/src/utils/directory2md.rs @@ -1,3 +1,4 @@ +use rust_i18n::t; use std::fs::{self, File}; use std::io::{Result, Write}; use std::path::Path; @@ -5,7 +6,13 @@ use walkdir::WalkDir; pub fn write_directory_contents_to_markdown(output_file: &Path) -> Result<()> { let mut file = File::create(output_file)?; - writeln!(file, "# Directory Contents\n")?; + let project_name = output_file + .parent() + .unwrap() + .file_name() + .unwrap_or_default() + .to_string_lossy(); + writeln!(file, "# {}", project_name)?; for entry in WalkDir::new(output_file.parent().unwrap()) .into_iter() .filter_map(|e| e.ok()) @@ -21,10 +28,10 @@ pub fn write_directory_contents_to_markdown(output_file: &Path) -> Result<()> { let file_name = file_name.to_string_lossy(); if metadata.is_dir() { // Use `**Dir:**` to denote directories - writeln!(file, "{}- **Dir:** {}", indent, file_name)?; + writeln!(file, "{}- **{}:** {}", indent, t!("dir"), file_name)?; } else { // Use `*File:*` to denote files - writeln!(file, "{}- *File:* {}", indent, file_name)?; + writeln!(file, "{}- *{}:* {}", indent, t!("file"), file_name)?; } } }