Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] add simplify translation funtion #169

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions config/function.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* Copyright (c) 2023. Wepesi.
*/

use Wepesi\Core\I18n;
use Wepesi\Core\Session;

/**
* @param string $dir
* @return array
Expand Down Expand Up @@ -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);
}
Loading