OneLogin_Saml2_Utils::t PHP Method

t() public static method

Translates any string. Accepts args
public static t ( string $msg, array | null $args = [] ) : string
$msg string Message to be translated
$args array | null Arguments
return string $translatedMsg Translated text
    public static function t($msg, $args = array())
    {
        assert('is_string($msg)');
        if (extension_loaded('gettext')) {
            bindtextdomain("phptoolkit", dirname(dirname(dirname(__FILE__))) . '/locale');
            textdomain('phptoolkit');
            $translatedMsg = gettext($msg);
        } else {
            $translatedMsg = $msg;
        }
        if (!empty($args)) {
            $params = array_merge(array($translatedMsg), $args);
            $translatedMsg = call_user_func_array('sprintf', $params);
        }
        return $translatedMsg;
    }

Usage Example

Example #1
0
File: Error.php Project: DbyD/cruk
 /**
  * Constructor
  *
  * @param string  $msg  Describes the error.
  * @param integer $code The code error (defined in the error class).
  * @param array   $args Arguments used in the message that describes the error.
  */
 public function __construct($msg, $code = 0, $args = null)
 {
     assert('is_string($msg)');
     assert('is_int($code)');
     $message = OneLogin_Saml2_Utils::t($msg, $args);
     parent::__construct($message, $code);
 }