Skip to content

Instantly share code, notes, and snippets.

@SteveL-MSFT
Created October 24, 2022 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SteveL-MSFT/3f19e0ce0f5b4db453f94e5e66e90620 to your computer and use it in GitHub Desktop.
Save SteveL-MSFT/3f19e0ce0f5b4db453f94e5e66e90620 to your computer and use it in GitHub Desktop.
param(
[string]$include = "*.resx"
)
$filesToExclude = @(
'FlashExtractStrings.resx'
'*Xaml*.resx'
'TabCompletionStrings.resx'
'*UICultureResources.resx'
'ComputerResources.resx'
'ClipboardResources.resx'
'ScheduledJobErrorStrings.resx'
'ConvertFromStringResources.resx'
'ConvertStringResources.resx'
'CredUI.resx'
'Logging.resx'
'Microsoft.PowerShell.LocalAccounts.Strings.resx'
'RemotingErrorIdStrings.resx'
)
$resx = dir -r $include -Exclude $filesToExclude
$names = @{}
write-progress -id 1 -Activity "Finding resx files"
foreach ($file in $resx) {
$xml = [System.Xml.XmlDocument]::new()
$xml.load($file)
foreach ($name in $xml.root.data.name) {
$names[$name] = $file
}
}
$sources = [System.Collections.Generic.List[string]]::new()
write-progress -id 1 -Activity "Finding source files"
$sourceFiles = dir -r *.cs,*.xaml -exclude *strings.cs
foreach ($file in $sourceFiles) {
$content = get-content $file -raw
$sources.Add($content)
}
$i = 0
foreach ($name in $names.Keys) {
$percent = [int32]([double]$i / [double]($names.Count) * 100)
write-progress -id 1 -Activity "Searching" -PercentComplete $percent -Status "$key $i of $($names.Count)"
$found = $false
foreach ($source in $sources) {
# if ($source.contains(".$name") -or $source.contains("Resourcetext(`"$name`")") -or $source.contains("`"$name`"") -or $source.contains("$name = ")) {
if ($source.contains($name)) {
$found = $true
break
}
}
$i++
if ($found) {
continue
}
else {
Write-Host "$name not found from $($names[$name])"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment