<?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));
    }
}
