1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
Function PrepareFRString()
{
$FR.Main = "Bonjour <XXX>, vous avez choisi le Français"
$FR.Question = "Comment t'appelles-tu ?"
$FR.Console = "Terminé"
$FR.End = "Au revoir"
}
Function PrepareENString()
{
$EN.Main = "Hello <XXX>, youve choose English"
$EN.Question = "Whats your name ?"
$EN.Console = "Over"
$EN.End = "See You"
}
Function PrepareITString()
{
$IT.Main = "Buongiorno <XXX>, avete scelto Italiano"
$IT.Question = "Come ti chiami ?"
$IT.Console = "Finito"
$IT.End = "Ciao"
}
Function PrintText($id)
{
# récupérer la chaîne $id en Français, en Anglais ou en Italien
Switch($Lang){
"FR"{$text = $FR.$id }
"EN"{$text = $EN.$id }
"IT"{$text = $IT.$id }
Default {Return ("ERROR")}}
#Remplacer les placeholders par le texte attendu
$regexp = [regex]'<XXX>'
foreach ($arg in $args)
{ $text = $regexp.Replace($text, [String]$arg,1) }
return $text}
Function WriteToFile($text,$space)
{
if($space -eq "before"){Write-Output "" $text | Out-File $ReportFile -Encoding utf8 -append}
elseif($space -eq "after"){Write-Output $text "" | Out-File $ReportFile -Encoding utf8 -append}
elseif($space -eq "both"){Write-Output "" $text "" | Out-File $ReportFile -Encoding utf8 -append}
else{Write-Output $text | Out-File $ReportFile -Encoding utf8 -append}
}
Function NameFile
{
$computerName = [system.environment]::MachineName
$date = Get-date -format "dd_MM_yyyy"
$hour = Get-Date -Format "HH_mm_ss"
$fileName = "$computerName-$Lang-$hour-$date.txt" #nom du fichier
return $FileName
}
Function AskName
{
Write-Host (PrintText Question)
$name = Read-Host
return $name
}
$FR = @{}
$EN = @{}
$IT = @{}
Write-Host @"
===============================
| Welcome/Bienvenue/Benvenuti |
===============================
"@ -ForegroundColor Yellow
Do{
Write-Host "`nPlease select your Language :" -ForegroundColor Yellow
Write-Host "`n1. Francais`n2. English`n3. Italiano`n4. Exit`n"
$Language = Read-Host
switch ($Language){
1 {$Lang = "FR"
PrepareFRString}
2 {$Lang = "EN"
PrepareENString}
3 {$Lang = "IT"
PrepareITString}
4 {Read-Host "See You/Au revoir/Ciao"
Exit}}}
While ($Language -notin 1..4)
$Name = AskName
$reportFile = NameFile
WriteToFile (PrintText Main $Name) "after"
WriteToFile (PrintText End)
Write-Host (PrintText Console) |
Partager