/** * Translate text (simple form) with a context. * * @param string $context A context, useful for translators to better understand the meaning of the text to be translated. * @param string $text The text to be translated. * @param mixed ... Unlimited optional number of arguments: if specified they'll be used for printf. * @return string Returns the translated text. * @example tc('Recipient', 'To %s') will return translation for 'To %s' (example for Italian 'A %s'). * @example tc('End date', 'To %s') will return translation for 'To %s' (example for Italian 'Fino al %s'). * @example tc('Recipient', 'To %s', 'John') will return translation for 'To %s' (example: 'A %s'), using 'John' for printf (so the final result will be 'A John' for Italian). * @example tc('End date', 'To %s', '01/01/2000') will return translation for 'To %s' (example: 'Fino al %s'), using '01/01/2000' for printf (so the final result will be 'Fino al 01/01/2000' for Italian). */ function tc($context, $text) { $zt = Localization::getTranslate(); if (is_object($zt)) { $msgid = $context . "" . $text; $msgtxt = $zt->translate($msgid); if ($msgtxt != $msgid) { $text = $msgtxt; } } if (func_num_args() == 2) { return $text; } $arg = array(); for ($i = 2; $i < func_num_args(); $i++) { $arg[] = func_get_arg($i); } return vsprintf($text, $arg); }