From b41f3ab6bf5e112eacb3fba79bf4ac951a1358b0 Mon Sep 17 00:00:00 2001 From: Anatolij Vasilev Date: Thu, 2 Nov 2023 10:35:33 +0100 Subject: [PATCH 1/2] added arabic file --- src/translations/ar.rs | 81 +++++++++++++++++++++++++++++++++++++++++ src/translations/mod.rs | 5 ++- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 src/translations/ar.rs diff --git a/src/translations/ar.rs b/src/translations/ar.rs new file mode 100644 index 0000000..60dc9f9 --- /dev/null +++ b/src/translations/ar.rs @@ -0,0 +1,81 @@ +pub struct Arabic; + +/* + * Author: Anatolij "tolik518" Vasilev + * Created: 2023-10-26 + */ +impl super::Translation for Arabic +{ + fn help_usage(&self) -> &'static str { + "Usage:\n\ + \u{20} If your font already has a configuration file: \n\ + \u{20} bitmap_type_tracer \n\n\ + \u{20} If you want to generate a configuration file: \n\ + \u{20} bitmap_type_tracer [--top VALUE] [--bottom VALUE] [--left VALUE] [--right VALUE] [--threshold VALUE] [--save-json] [--lang en|it|fr|tr|...]" + } + + fn help_parameters(&self) -> &'static str { + "\n\ + \u{20}\u{20} path_to_bitmap_font literally the path to the bitmap.png containing the characters\n\ + \u{20}\u{20} sequence the sequence of characters that you see in the bitmap font e.x 'ABCDEF...'\n\ + \u{20}\u{20} text the text you want to write with the provided bitmap font\n\ + \u{20}\u{20} chars_per_row how many characters are in a row in the provided bitmap font\n" + } + + fn help_margins(&self) -> &'static str { + "Margins:\n\ + \u{20}\u{20} --top VALUE the number of pixels to crop from the top of the image\n\ + \u{20}\u{20} --bottom VALUE the number of pixels to crop from the bottom of the image\n\ + \u{20}\u{20} --left VALUE the number of pixels to crop from the left of the image\n\ + \u{20}\u{20} --right VALUE the number of pixels to crop from the right of the image" + } + + fn help_other_options(&self) -> &'static str { + "Other options:\n\ + \u{20}\u{20} --threshold VALUE the value to determine the threshold for making the background transparent (0-255)\n\ + \u{20}\u{20} --save-json save the configuration to a json file\n\ + \u{20}\u{20} --help print this help message\n\ + \u{20}\u{20} --version print the version of the program\n\ + \u{20}\u{20} --lang Specify the language (en|it|fr|tr|...) of the application. Default is your system lang or en" + } + + fn help_example_usage(&self) -> &'static str {"For examples usage check out the README.md in the repository"} + + fn help(&self) -> String { + format!( + "{}\n\n{}\n\n{}\n\n{}\n", + self.help_usage(), self.help_margins(), self.help_other_options(), self.help_example_usage() + ) + } + + fn version(&self) -> &'static str {env!("CARGO_PKG_VERSION")} + fn repository(&self) -> &'static str {env!("CARGO_PKG_REPOSITORY")} + fn name(&self) -> &'static str {env!("CARGO_PKG_NAME")} + fn author(&self) -> &'static str {env!("CARGO_PKG_AUTHORS")} + fn full_help(&self) -> String { + format!( + "{} by {}\nVersion: {}\nRepository: {}\n{}", + self.name(), self.author(), self.version(), self.repository(), self.help() + ) + } + fn warn_character_not_found(&self, character: char) -> String { + format!("Character '{}' not found in sequence. Trying to use the background-color instead.", character) + } + + fn err_invalid_num_of_chars(&self) -> &'static str {"You need to provide a valid number of characters per row."} + fn err_invalid_threshold(&self) -> &'static str {"You need to provide a valid threshold value (0-255)."} + fn err_invalid_left_margin(&self) -> &'static str {"Failed to read the right margin argument. Please provide a valid value."} + fn err_invalid_right_margin(&self) -> &'static str {"Failed to read the right margin argument. Please provide a valid value."} + fn err_invalid_top_margin(&self) -> &'static str {"Failed to read the top margin argument. Please provide a valid value."} + fn err_invalid_bottom_margin(&self) -> &'static str {"Failed to read the bottom margin argument. Please provide a valid value."} + + fn err_failed_to_read_config(&self) -> &'static str {"Failed to read the font config (json) file."} + fn err_failed_to_parse_config(&self) -> &'static str {"Failed to parse the font config (json) file."} + fn err_failed_to_open_config(&self) -> &'static str {"Failed to open the font config (json) file."} + fn err_failed_to_serialize_config(&self) -> &'static str {"Failed to serialize the font config (json) file."} + fn err_failed_to_save_config(&self) -> &'static str {"Failed to save the font config (json) file."} + fn err_invalid_font_path(&self) -> &'static str {"Invalid font path"} + + fn err_failed_to_save_output_image(&self) -> &'static str {"Failed to save output image"} + fn err_failed_to_open_font_image(&self) -> &'static str {"Failed to open font image"} +} \ No newline at end of file diff --git a/src/translations/mod.rs b/src/translations/mod.rs index 5a7d36a..32c8884 100644 --- a/src/translations/mod.rs +++ b/src/translations/mod.rs @@ -2,13 +2,15 @@ use crate::translations::{ tr::Turkish, en::English, it::Italian, - fr::French + fr::French, + ar::Arabic }; mod en; mod tr; mod it; mod fr; +mod ar; pub fn get_translation_for_locale(locale: &str) -> Box { match locale { @@ -16,6 +18,7 @@ pub fn get_translation_for_locale(locale: &str) -> Box { "tr" => Box::new(Turkish), "it" => Box::new(Italian), "en" => Box::new(English), + "ar" => Box::new(Arabic), _ => Box::new(English), } } From 391518a210d5d98415924d51c5d728ac05d2984a Mon Sep 17 00:00:00 2001 From: Anatolij Vasilev Date: Mon, 27 Nov 2023 16:51:20 +0100 Subject: [PATCH 2/2] added arabic translation --- src/translations/ar.rs | 82 +++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/translations/ar.rs b/src/translations/ar.rs index 60dc9f9..45a13c4 100644 --- a/src/translations/ar.rs +++ b/src/translations/ar.rs @@ -7,39 +7,39 @@ pub struct Arabic; impl super::Translation for Arabic { fn help_usage(&self) -> &'static str { - "Usage:\n\ - \u{20} If your font already has a configuration file: \n\ - \u{20} bitmap_type_tracer \n\n\ - \u{20} If you want to generate a configuration file: \n\ - \u{20} bitmap_type_tracer [--top VALUE] [--bottom VALUE] [--left VALUE] [--right VALUE] [--threshold VALUE] [--save-json] [--lang en|it|fr|tr|...]" + "الاستخدام:\n\ + \u{20} إذا كان للخط النقطي ملف تكوين مسبق: \n\ + \u{20} bitmap_type_tracer <مسار_خط_البتماب> <النص>\n\n\ + \u{20} إذا أردت إنشاء ملف تكوين: \n\ + \u{20} bitmap_type_tracer <مسار_خط_البتماب> <التسلسل> <النص> <عدد_الأحرف_في_الصف> [--top VALUE] [--bottom VALUE] [--left VALUE] [--right VALUE] [--threshold VALUE] [--save-json] [--lang en|it|fr|tr|...]" } fn help_parameters(&self) -> &'static str { "\n\ - \u{20}\u{20} path_to_bitmap_font literally the path to the bitmap.png containing the characters\n\ - \u{20}\u{20} sequence the sequence of characters that you see in the bitmap font e.x 'ABCDEF...'\n\ - \u{20}\u{20} text the text you want to write with the provided bitmap font\n\ - \u{20}\u{20} chars_per_row how many characters are in a row in the provided bitmap font\n" + \u{20}\u{20} مسار_خط_البتماب حرفيًا المسار إلى ملف bitmap.png الذي يحتوي الأحرف\n\ + \u{20}\u{20} التسلسل تسلسل الأحرف التي تراها في خط البتماب مثل 'ABCDEF...'\n\ + \u{20}\u{20} النص النص الذي ترغب في كتابته باستخدام خط البتماب المتوفر\n\ + \u{20}\u{20} عدد_الأحرف_في_الصف كم عدد الأحرف في صف في خط البتماب المتوفر\n" } fn help_margins(&self) -> &'static str { - "Margins:\n\ - \u{20}\u{20} --top VALUE the number of pixels to crop from the top of the image\n\ - \u{20}\u{20} --bottom VALUE the number of pixels to crop from the bottom of the image\n\ - \u{20}\u{20} --left VALUE the number of pixels to crop from the left of the image\n\ - \u{20}\u{20} --right VALUE the number of pixels to crop from the right of the image" + "الهوامش:\n\ + \u{20}\u{20} --top VALUE عدد البكسلات التي يتم قصها من أعلى الصورة\n\ + \u{20}\u{20} --bottom VALUE عدد البكسلات التي يتم قصها من أسفل الصورة\n\ + \u{20}\u{20} --left VALUE عدد البكسلات التي يتم قصها من يسار الصورة\n\ + \u{20}\u{20} --right VALUE عدد البكسلات التي يتم قصها من يمين الصورة" } fn help_other_options(&self) -> &'static str { - "Other options:\n\ - \u{20}\u{20} --threshold VALUE the value to determine the threshold for making the background transparent (0-255)\n\ - \u{20}\u{20} --save-json save the configuration to a json file\n\ - \u{20}\u{20} --help print this help message\n\ - \u{20}\u{20} --version print the version of the program\n\ - \u{20}\u{20} --lang Specify the language (en|it|fr|tr|...) of the application. Default is your system lang or en" + "خيارات أخرى:\n\ + \u{20}\u{20} --threshold VALUE القيمة لتحديد العتبة لجعل الخلفية شفافة (0-255)\n\ + \u{20}\u{20} --save-json حفظ التكوين إلى ملف json\n\ + \u{20}\u{20} --help طباعة رسالة المساعدة هذه\n\ + \u{20}\u{20} --version طباعة إصدار البرنامج\n\ + \u{20}\u{20} --lang حدد لغة التطبيق (en|it|fr|tr|...) الافتراضية هي لغة النظام أو en" } - fn help_example_usage(&self) -> &'static str {"For examples usage check out the README.md in the repository"} + fn help_example_usage(&self) -> &'static str { "لأمثلة الاستخدام اطلع على ملف README.md في المستودع" } fn help(&self) -> String { format!( @@ -48,34 +48,34 @@ impl super::Translation for Arabic ) } - fn version(&self) -> &'static str {env!("CARGO_PKG_VERSION")} - fn repository(&self) -> &'static str {env!("CARGO_PKG_REPOSITORY")} - fn name(&self) -> &'static str {env!("CARGO_PKG_NAME")} - fn author(&self) -> &'static str {env!("CARGO_PKG_AUTHORS")} + fn version(&self) -> &'static str { env!("CARGO_PKG_VERSION") } + fn repository(&self) -> &'static str { env!("CARGO_PKG_REPOSITORY") } + fn name(&self) -> &'static str { env!("CARGO_PKG_NAME") } + fn author(&self) -> &'static str { env!("CARGO_PKG_AUTHORS") } fn full_help(&self) -> String { format!( - "{} by {}\nVersion: {}\nRepository: {}\n{}", + "{} بواسطة {}\nالإصدار: {}\nالمستودع: {}\n{}", self.name(), self.author(), self.version(), self.repository(), self.help() ) } fn warn_character_not_found(&self, character: char) -> String { - format!("Character '{}' not found in sequence. Trying to use the background-color instead.", character) + format!("لم يتم العثور على الحرف '{}' في التسلسل. يتم محاولة استخدام لون الخلفية بدلاً من ذلك.", character) } - fn err_invalid_num_of_chars(&self) -> &'static str {"You need to provide a valid number of characters per row."} - fn err_invalid_threshold(&self) -> &'static str {"You need to provide a valid threshold value (0-255)."} - fn err_invalid_left_margin(&self) -> &'static str {"Failed to read the right margin argument. Please provide a valid value."} - fn err_invalid_right_margin(&self) -> &'static str {"Failed to read the right margin argument. Please provide a valid value."} - fn err_invalid_top_margin(&self) -> &'static str {"Failed to read the top margin argument. Please provide a valid value."} - fn err_invalid_bottom_margin(&self) -> &'static str {"Failed to read the bottom margin argument. Please provide a valid value."} + fn err_invalid_num_of_chars(&self) -> &'static str { "يجب أن تقدم عددًا صحيحًا من الأحرف لكل صف." } + fn err_invalid_threshold(&self) -> &'static str { "يجب أن تقدم قيمة عتبة صحيحة (0-255)." } + fn err_invalid_left_margin(&self) -> &'static str { "فشل في قراءة وسيط هامش اليسار. يرجى تقديم قيمة صحيحة." } + fn err_invalid_right_margin(&self) -> &'static str { "فشل في قراءة وسيط هامش اليمين. يرجى تقديم قيمة صحيحة." } + fn err_invalid_top_margin(&self) -> &'static str { "فشل في قراءة وسيط هامش الأعلى. يرجى تقديم قيمة صحيحة." } + fn err_invalid_bottom_margin(&self) -> &'static str { "فشل في قراءة وسيط هامش الأسفل. يرجى تقديم قيمة صحيحة." } - fn err_failed_to_read_config(&self) -> &'static str {"Failed to read the font config (json) file."} - fn err_failed_to_parse_config(&self) -> &'static str {"Failed to parse the font config (json) file."} - fn err_failed_to_open_config(&self) -> &'static str {"Failed to open the font config (json) file."} - fn err_failed_to_serialize_config(&self) -> &'static str {"Failed to serialize the font config (json) file."} - fn err_failed_to_save_config(&self) -> &'static str {"Failed to save the font config (json) file."} - fn err_invalid_font_path(&self) -> &'static str {"Invalid font path"} + fn err_failed_to_read_config(&self) -> &'static str { "فشل في قراءة ملف تكوين الخط (json)." } + fn err_failed_to_parse_config(&self) -> &'static str { "فشل في تحليل ملف تكوين الخط (json)." } + fn err_failed_to_open_config(&self) -> &'static str { "فشل في فتح ملف تكوين الخط (json)." } + fn err_failed_to_serialize_config(&self) -> &'static str { "فشل في تسلسل ملف تكوين الخط (json)." } + fn err_failed_to_save_config(&self) -> &'static str { "فشل في حفظ ملف تكوين الخط (json)." } + fn err_invalid_font_path(&self) -> &'static str { "مسار الخط غير صالح" } - fn err_failed_to_save_output_image(&self) -> &'static str {"Failed to save output image"} - fn err_failed_to_open_font_image(&self) -> &'static str {"Failed to open font image"} + fn err_failed_to_save_output_image(&self) -> &'static str { "فشل في حفظ صورة الإخراج" } + fn err_failed_to_open_font_image(&self) -> &'static str { "فشل في فتح صورة الخط" } } \ No newline at end of file