src/FileTranslator.php
public function translate(string $key, array $data = []): string
    {
        if (!array_key_exists($key, $this->texts)) {
            return '{{' . $key . '}}';
        }

        if (empty($data)) {
            return $this->texts[$key];
        }

        return call_user_func_array('sprintf', array_merge([$this->texts[$key]], $data));
    }
public function translate(string $key, array $data = []): string
    {
        if (!array_key_exists($key, $this->texts)) {
            return '{{' . $key . '}}';
        }

        if (empty($data)) {
            return $this->texts[$key];
        }

        return call_user_func_array('sprintf', array_merge([$this->texts[$key]], $data));
    }
public function translate ( string $ key , array $ data = [ ] ) : string { if ( ! array_key_exists ( $ key , $ this -> texts ) ) { return '{{' . $ key . '}}' ; } if ( empty ( $ data ) ) { return $ this -> texts [ $ key ] ; } return call_user_func_array ( 'sprintf' , array_merge ( [ $ this -> texts [ $ key ] ] , $ data ) ) ; }
Gets the translation by key if any or a placeholder otherwise

@param string $key  The translation key for which to find the translation
@param array  $data Extra data to use in the translated string as variables

@return string The translation or a placeholder when no translation is available
Gets the translation by key if any or a placeholder otherwise