TranslateTo-Czech
Jelikoz cas od casu pouzivam slovniky na atlasu, rikal jsem si ze by nebylo marne mit je pristupne i na prikazove radce. Vznikla z toho nasledujici funkce; je to docela cviceni z regularnich vyrazu. Doufam ze mi nekdo v komentarich reknete ze to bylo zbytecne a ze atlas ma nejake pekne XML/SOAP rozhrani :) Ale zatim to funguje, a jestli budu mit stesti tak na atlase nebudou to html moc menit. Skript zatim podporuje jenom preklad z anglictiny, nemciny a francouzstiny. Dalsi jazyky, pripadne opacny smer necham na vas :)
function TranslateTo-Czech(
[string]$English,
[string]$Deutsch,
[string]$Francais) {
$lang = 0; $word = $English
if($Deutsch) { $lang = 2; $word = $Deutsch }
elseif($Francais) { $lang = 6; $word = $Francais }
$webclient = (new Net.WebClient)
$webclient.Encoding = [Text.Encoding]::UTF8
$word = [Web.HttpUtility]::UrlEncode($word)
$response = $webclient.DownloadString("http://slovnik.atlas.cz/?utf=y&lang=$lang&word=$word")
$regex = new regex 'id="results">.*<ul>(.*)</ul>', 'Singleline,IgnoreCase'
$definitions = $regex.Match($response).Groups[1].Value
$regex = new regex '<li><strong>(.*):</strong>(.*)</li>', 'Multiline,IgnoreCase'
$match = $regex.Match($definitions)
$result = new PSObject
while($match.Success) {
$result | add-member NoteProperty ($match.Groups[1]) ($match.Groups[2])
$match = $match.NextMatch()
}
$result
}
Upozornění na nové komentáře
Pokud chčeš dostávat upozornění emailem na změny u toho příspěvku,tak se zaregistruj zde.zde
Odebírat komentáře k tomuto příspěvku pomocí