public function translate($key, $data = null)
    {
        $rs = isset($this->data[$key]) ? $this->data[$key] : $key;
        if ($rs && !empty($data)) {
            $names = array_keys($data);
            $names = array_map(function($pkey){ return '{' . $pkey . '}'; }, $names);
            $rs = str_replace($names, array_values($data), $rs);
        }
        return $rs;
    }
public function translate($key, $data = null)
    {
        $rs = isset($this->data[$key]) ? $this->data[$key] : $key;
        if ($rs && !empty($data)) {
            $names = array_keys($data);
            $names = array_map(function($pkey){ return '{' . $pkey . '}'; }, $names);
            $rs = str_replace($names, array_values($data), $rs);
        }
        return $rs;
    }
public function translate ( $ key , $ data = null ) { $ rs = isset ( $ this -> data [ $ key ] ) ? $ this -> data [ $ key ] : $ key ; if ( $ rs && ! empty ( $ data ) ) { $ names = array_keys ( $ data ) ; $ names = array_map ( function ( $ pkey ) { return '{' . $ pkey . '}' ; } , $ names ) ; $ rs = str_replace ( $ names , array_values ( $ data ) , $ rs ) ; } return $ rs ; }
Translate and return the string

@param  string       $key
@param  string|array $data
@return string
Translate and return the string