Files
breadcrumb-the-shire/lib/Service/I18n/ServiceTranslator.php

20 lines
412 B
PHP

<?php
namespace MintyPHP\Service\I18n;
final class ServiceTranslator
{
public static function translate(string $text, mixed ...$args): string
{
if (function_exists('t')) {
return t($text, ...$args);
}
if ($args === []) {
return $text;
}
return vsprintf($text, array_map(static fn (mixed $arg): string => (string) $arg, $args));
}
}