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
}
Zveřejněno 04 prosince 06 01:00 by jachymko
Vedeno pod: ,

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í RSS

Komentář

# sam said on prosince 4, 2006 9:19:

toto je pekne :)

# Lee said on prosince 14, 2006 17:57:

Did tebe vŘdŘt aby tebe pocínovat zevrubně udat člen určitý Úřad regenta doplňkové příslušenství inline ,

a ne mít až k cvičení člen určitý explicit, označení konce ve starých rukopisech Úřad regenta budovatel?

Například:

[C:\temp]

PS:16 > "Hello`nWorld" -match "H.*world"

False

[C:\temp]

PS:17 > "Hello`nWorld" -match "(?s)H.*world"

True

Did you know that you can specify the Regex options inline, and not have to use the explicit Regex constructor?

For example:

[C:\temp]

PS:16 > "Hello`nWorld" -match "H.*world"

False

[C:\temp]

PS:17 > "Hello`nWorld" -match "(?s)H.*world"

True

Vytvoření nového komentáře

(povinný) 
(nepovinný)
(povinný) 
Opiš čísla, která vidíš na obrázku: