setCachePrefix( $cache_prefix ); if( $source_lang ) { $DeepLApiTranslate->setLangFrom( $source_lang ); } //var_dump($target_lang); die('ok'); if( !$DeepLApiTranslate->setLangTo( $target_lang ) ) { return new WP_Error( sprintf( __( "Target language '%s' not valid", 'wpdeepl' ), $target_lang ) ); } $DeepLApiTranslate->setTagHandling( 'xml' ); $DeepLApiTranslate->setFormality( DeepLConfiguration::getFormalityLevel() ); //plouf($DeepLApiTranslate); die('ok'); $translations = $DeepLApiTranslate->getTranslations( $strings ); if( is_wp_error( $translations ) ) { return $translations; } $request = array( 'cached' => $DeepLApiTranslate->wasItCached(), 'time' => $DeepLApiTranslate->getTimeElapsed(), 'cache_file_request' => $DeepLApiTranslate->getCacheFile( 'request' ), 'cache_file_response' => $DeepLApiTranslate->getCacheFile( 'response' ), ); $return = compact( 'request', 'translations' ); return apply_filters( 'deepl_translate', $return, $source_lang, $target_lang, $strings, $cache_prefix ); } function deepl_show_usage() { ?>
request(); //plouf($usage); plouf($DeepLApiUsage); if( $usage && is_array( $usage ) && array_key_exists( 'character_count', $usage ) && array_key_exists( 'character_limit', $usage )) : $ratio = round( 100 * ( $usage['character_count'] / $usage['character_limit'] ), 3 ); $left_chars = $usage['character_limit'] - $usage['character_count']; ?> '; printf(__('Did you select the right server ? If yes, check your plan on DeepL Pro website. "DeepL API" should be included in it.', 'wpdeepl' ), 'https://www.deepl.com/pro-account/plan' ); endif; }