<?php /* * --- * array str_translate() - Translating words with INTERIA.pl online dictionary * (c) 2007 tiraeth * --- * string sQuery: Word to translate (en, de or pl) * string sLanguage: Translate language (e.g. EN for en-pl and pl-en dict) [addit.] * string sEncoding: Encoding for return HTML structure of translation [addit.] * */ function str_translate( $sQuery, $sLanguage = 'en', $sEncoding = 'utf-8' ) { { $sEncoding = 'utf-8'; } if ( $sLanguage == 'de' ) { $file = file('http://tlumacz.interia.pl/niemiecki/szukaj/?utf8=1&q=' . $sQuery . '&jezyk=ni%7C13%7C-'); if ( $sEncoding != 'utf-8' && function_exist('iconv') ) { iconv ( 'utf-8', $sEncoding, $file ); } { $data = $data[0]; { $aReturn['pl-de'] = $data[1]; } } } else { $file = file('http://tlumacz.interia.pl/angielski/szukaj/?utf8=1&q=' . $sQuery . '&jezyk=an%7C12%7C-'); if ( $sEncoding != 'utf-8' && function_exist('iconv') ) { iconv ( 'utf-8', $sEncoding, $file ); } { $data = $data[0]; { $aReturn['pl-en'] = $data[1]; } } } return $aReturn; } ?>
Jak używać? Wszystko w komentarzu. Funkcja zwraca nad array z kodem "HTML" z tłumaczeniami słówka.
Tam gdzie mamy 't', 'r', 'n' powinno być oczywiście '\t', '\r', '\n'
Ktoś niech kurde naprawi ten kod php, bo się zawsze rozsypują znaki \t, poza tym cudzysłowia też nie działają dobrze!!