pub mod i18n;
pub mod repository;
pub mod hashmap;

pub use i18n::*;
pub use repository::*;
pub use hashmap::*;

#[macro_export]
macro_rules! t8x {
    ($text_language:expr, $text:literal, $language:expr, $uniq:literal) => {{
        let uniq = $crate::i18n::Uniq::Manual($uniq);
        let text: String = indoc::indoc! {$text}.into();
        $crate::i18n::trans(text, uniq, $text_language, $language)
    }};
    ($text:literal, $language:expr, $uniq:literal) => {{
        let uniq = $crate::i18n::Uniq::Manual($uniq);
        let text: String = indoc::indoc! {$text}.into();
        $crate::i18n::trans(text, uniq, $crate::i18n::Language::En, $language)
    }};
    ($text_language:expr, $text:literal, $language:expr) => {{
        let uniq = $crate::i18n::Uniq::Module({
            let module_path = module_path!();
            module_path.splitn(3, ':').nth(2).unwrap_or(module_path)
        });
        let text: String = indoc::indoc! {$text}.into();
        $crate::i18n::trans(text, uniq, $text_language, $language)
    }};
    ($text:literal, $language:expr) => {{
        let uniq = $crate::i18n::Uniq::Module({
            let module_path = module_path!();
            module_path.splitn(3, ':').nth(2).unwrap_or(module_path)
        });
        let text: String = indoc::indoc! {$text}.into();
        $crate::i18n::trans(text, uniq, $crate::i18n::Language::En, $language)
    }};
}

#[macro_export]
macro_rules! t8x_string {
    ($text_language:expr, $text:literal, $language:expr, $uniq:literal) => {{
        t8x!($text_language, $text, $language, $uniq).to_string()
    }};
    ($text:literal, $language:expr, $uniq:literal) => {{
        t8x!($text, $language, $uniq).to_string()
    }};
    ($text_language:expr, $text:literal, $language:expr) => {{
        t8x!($text_language, $text, $language).to_string()
    }};
    ($text:literal, $language:expr) => {{
        t8x!($text, $language).to_string()
    }};
}


#[macro_export]
macro_rules! t8r {
    ($text_language:expr, $text:literal, $uniq:literal) => {{
        let language = $crate::i18n::get_current_language();
        $crate::t8x!($text_language, $text, &language, $uniq)
    }};
    ($text:literal, $uniq:literal) => {{
        let language = $crate::i18n::get_current_language();
        $crate::t8x!($text, &language, $uniq)
    }};
    ($text_language:expr, $text:literal) => {{
        let language = $crate::i18n::get_current_language();
        $crate::t8x!($text_language, $text, &language)
    }};
    ($text:literal) => {{
        let language = $crate::i18n::get_current_language();
        $crate::t8x!($text, &language)
    }};
}

#[macro_export]
macro_rules! t8r_string {
    ($text_language:expr, $text:literal, $uniq:literal) => {{
        t8r!($text_language, $text, $uniq).to_string()
    }};
    ($text:literal, $uniq:literal) => {{
        t8r!($text, $uniq).to_string()
    }};
    ($text_language:expr, $text:literal) => {{
        t8r!($text_language, $text).to_string()
    }};
    ($text:literal) => {{
        t8r!($text).to_string()
    }};
}

