From d42f8f53a93b61e883f8bc080abb80b48d996bd8 Mon Sep 17 00:00:00 2001 From: bim-g Date: Sun, 25 Feb 2024 21:59:03 +0200 Subject: [PATCH] [ENH] add simplify translation funtion --- config/function.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/config/function.php b/config/function.php index b3b03db..8d42063 100644 --- a/config/function.php +++ b/config/function.php @@ -3,6 +3,9 @@ * Copyright (c) 2023. Wepesi. */ +use Wepesi\Core\I18n; +use Wepesi\Core\Session; + /** * @param string $dir * @return array @@ -104,3 +107,16 @@ function appDirSeparator(string $path): string if ((substr(PHP_OS, 0, 3)) === 'WIN') $new_path = str_replace("\\", '/', $path); return $new_path; } + +/** + * translate your text + * @param string $message + * @param string|array $value + * @return string + */ +function tra(string $message, $value = null): string +{ + $i18n = new i18n(Session::get('lang')); + $translate_value = !is_array($value) ? [$value] : $value; + return $i18n->translate($message, $translate_value); +} \ No newline at end of file