diff --git a/composer.json b/composer.json index 80b5aca..f6f4066 100644 --- a/composer.json +++ b/composer.json @@ -18,11 +18,13 @@ "require": { "php": ">=8.1", "hyperf/collection": "~3.1.0", + "hyperf/config": "~3.1.0", "hyperf/contract": "~3.1.0", "hyperf/coroutine": "~3.1.0", "hyperf/stringable": "~3.1.0", "hyperf/support": "~3.1.0", - "hyperf/tappable": "~3.1.0" + "hyperf/tappable": "~3.1.0", + "hyperf/translation": "~3.1.0" }, "autoload": { "files": [ diff --git a/src/Functions.php b/src/Functions.php index a39c9ea..14d14fe 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -310,3 +310,34 @@ function wait(Closure $closure, ?float $timeout = null) return \Hyperf\Coroutine\wait($closure, $timeout); } } + +if (! function_exists('__')) { + function __(string $key, array $replace = [], ?string $locale = null) + { + return \Hyperf\Translation\__($key, $replace, $locale); + } +} + +if (! function_exists('trans')) { + function trans(string $key, array $replace = [], ?string $locale = null) + { + return \Hyperf\Translation\__($key, $replace, $locale); + } +} + +if (! function_exists('trans_choice')) { + function trans_choice(string $key, $number, array $replace = [], ?string $locale = null): string + { + return \Hyperf\Translation\trans_choice($key, $number, $replace, $locale); + } +} + +if (! function_exists('config')) { + /** + * @param null|mixed $default + */ + function config(string $key, $default = null) + { + return \Hyperf\Config\config($key, $default); + } +}