Delete Scripts/Get-GoogleTranslate.psm1
This commit is contained in:
parent
16132c92a9
commit
aaf946c992
1 changed files with 0 additions and 21 deletions
|
|
@ -1,21 +0,0 @@
|
|||
function Get-Translate {
|
||||
param (
|
||||
$data,
|
||||
$key = "KEY" # Get https://cloud.google.com/translate/docs/reference/rest
|
||||
)
|
||||
$url = "https://translation.googleapis.com/language/translate/v2?key=$key"
|
||||
$body = @{
|
||||
q = $data
|
||||
target = "ru"
|
||||
source = "en"
|
||||
} | ConvertTo-Json
|
||||
try {
|
||||
$response = Invoke-RestMethod -Uri $url -Method POST -ContentType "application/json" -Body $body
|
||||
$translation = $response.data.translations[0].translatedText
|
||||
return $translation
|
||||
} catch {
|
||||
Write-Output "Error: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
# Get-Translate -data "What is your name"
|
||||
Loading…
Add table
Add a link
Reference in a new issue