WIP: refractor of existing logic & addition of language selection

This commit is contained in:
MyDrift 2024-09-03 11:52:09 +02:00
parent 4b9a9b2ef6
commit 6dbdfa67cd
3 changed files with 17 additions and 68 deletions

View File

@ -25,56 +25,6 @@ function Test-CompatibleImage() {
}
}
function Get-FidoLangFromCulture {
param (
[Parameter(Mandatory, Position = 0)] [string] $langName
)
switch -Wildcard ($langName)
{
"ar*" { return "Arabic" }
"pt-BR" { return "Brazilian Portuguese" }
"bg*" { return "Bulgarian" }
{($_ -eq "zh-CH") -or ($_ -like "zh-Hans*") -or ($_ -eq "zh-SG") -or ($_ -eq "zh-CHS")} { return "Chinese (Simplified)" }
{($_ -eq "zh") -or ($_ -eq "zh-Hant") -or ($_ -eq "zh-HK") -or ($_ -eq "zh-MO") -or ($_ -eq "zh-TW") -or ($_ -eq "zh-CHT")} { return "Chinese (Traditional)" }
"hr*" { return "Croatian" }
"cs*" { return "Czech" }
"da*" { return "Danish" }
"nl*" { return "Dutch" }
"en-US" { return "English" }
{($_ -like "en*") -and ($_ -ne "en-US")} { return "English International" }
"et*" { return "Estonian" }
"fi*" { return "Finnish" }
{($_ -like "fr*") -and ($_ -ne "fr-CA")} { return "French" }
"fr-CA" { return "French Canadian" }
"de*" { return "German" }
"el*" { return "Greek" }
"he*" { return "Hebrew" }
"hu*" { return "Hungarian" }
"it*" { return "Italian" }
"ja*" { return "Japanese" }
"ko*" { return "Korean" }
"lv*" { return "Latvian" }
"lt*" { return "Lituanian" }
"nb*" { return "Norwegian" }
"pl*" { return "Polish" }
{($_ -like "pt*") -and ($_ -ne "pt-BR")} { return "Portuguese" }
"ro*" { return "Romanian" }
"ru*" { return "Russian" }
"sr-Latn*" { return "Serbian Latin" }
"sk*" { return "Slovak" }
"sl*" { return "Slovenian" }
{($_ -like "es*") -and ($_ -ne "es-MX")} { return "Spanish" }
"es-MX" { return "Spanish (Mexico)" }
"sv*" { return "Swedish" }
"th*" { return "Thai" }
"tr*" { return "Turkish" }
"uk*" { return "Ukrainian" }
default { return "English" }
}
}
function Remove-Features() {
<#
.SYNOPSIS

View File

@ -84,11 +84,26 @@ function Invoke-WPFGetIso {
Invoke-WebRequest "https://github.com/pbatard/Fido/raw/master/Fido.ps1" -OutFile $fidopath
# TODO: Have to correct the language to actually be a working one
# TODO: on get iso, script gets downloaded and function is taken & called to get & display languages. after selection user can press proceed, which will start the fido process and select the output iso for further processing
Set-Location -Path $env:temp
& $fidopath -Win 'Windows 11' -Rel $sync["ISORelease"].SelectedItem -Arch "x64" -Lang "$(Get-FidoLangFromCulture -langName `"$($sync.ISOLanguage.SelectedItem)`")"
& $fidopath -Win 'Windows 11' -Rel $sync["ISORelease"].SelectedItem -Arch "x64" -Lang $sync["ISOLanguage"].SelectedItem
Set-Location $originalLocation
$filePath = Get-ChildItem -Path "$env:temp" -Filter "Win11*.iso" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
# WIP positioning, wont work as expected currently
$sync["ISOLanguage"].Items.Add($locale)
if ($locale -ne "en-US") {
$sync["ISOLanguage"].Items.Add("en-US")
}
$sync["ISOLanguage"].SelectedItem = $locale
if ($sync["ISOoption1"].IsChecked) {
$sync["ISORelease"].Visibility = [System.Windows.Visibility]::Visible
$sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Visible
} else {
$sync["ISORelease"].Visibility = [System.Windows.Visibility]::Collapsed
$sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Collapsed
}
}
Write-Host "File path $($filePath)"

View File

@ -375,27 +375,11 @@ Add-Type @"
})
$locale = (Get-Culture).Name
$sync["ISORelease"].Items.Add("23H2")
$sync["ISORelease"].Items.Add("22H2")
$sync["ISORelease"].Items.Add("21H2")
$sync["ISORelease"].SelectedItem = "23H2"
$sync["ISOLanguage"].Items.Add($locale)
if ($locale -ne "en-US") {
$sync["ISOLanguage"].Items.Add("en-US")
}
$sync["ISOLanguage"].SelectedItem = $locale
if ($sync["ISOoption1"].IsChecked) {
$sync["ISORelease"].Visibility = [System.Windows.Visibility]::Visible
$sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Visible
} else {
$sync["ISORelease"].Visibility = [System.Windows.Visibility]::Collapsed
$sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Collapsed
}
# Load Checkboxes and Labels outside of the Filter function only once on startup for performance reasons
$filter = Get-WinUtilVariables -Type CheckBox
$CheckBoxes = ($sync.GetEnumerator()).where{ $psitem.Key -in $filter }