/** * Translate a message alias. * * @param string $string message alias * @param array $tokens parameters for translation * @param array $options options * @return string message to display */ function t($string, $tokens = array(), $options = array()) { if (method_exists('SC_Helper_Locale_Ex', 'get_locale')) { // Get a string of specified language which corresponds to the message alias. $translated = SC_Helper_Locale_Ex::get_locale($string, $options); } else { $translated = $string; } // If parameters are set, translate a message. if (empty($tokens)) { return $translated; } else { return strtr($translated, $tokens); } }
/** * Return a string which corresponding with message alias. * * @param string $single message alias (single) * @param string $plural message alias (plural) * @param array $options options * @return array */ public static function get_locale_plural($single, $plural, &$options) { // Plural strings are coupled with a null character. $key = $single . chr(0) . $plural; // Get a string of specified language which corresponds to the message alias. $translated = SC_Helper_Locale_Ex::get_locale($key, $options); // Divide with a null character. return explode(chr(0), $translated); }