Skip to content

Commit

Permalink
xIisModule: Move localization strings to strings.psd1 (#521)
Browse files Browse the repository at this point in the history
- Changes to xIisModule entry
  - Moved xIisModule localization strings to strings.psd1 (issue #466).
  • Loading branch information
Outek authored and johlju committed Oct 6, 2019
1 parent 10338a1 commit 6ded0de
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Changes to xIisModule entry
- Moved xIisModule localization strings to strings.psd1 ([issue #466](https://github.com/PowerShell/xWebAdministration/issues/466)).
- Changes to xIisMimeTypeMapping
- Moved MSFT_xIisMimeTypeMapping localization strings to strings.psd1 ([issue #465](https://github.com/PowerShell/xWebAdministration/issues/465)).
- Changes to xWebVirtualDirectory
Expand Down
54 changes: 18 additions & 36 deletions DSCResources/MSFT_xIisModule/MSFT_xIisModule.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,9 @@ $script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -Chil

Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'xWebAdministration.Common.psm1')

# Localized messages
data LocalizedData
{
# culture="en-US"
ConvertFrom-StringData -StringData @'
VerboseGetTargetResource = Get-TargetResource has been run.
VerboseSetTargetRemoveHandler = Removing handler
VerboseSetTargetAddHandler = Adding handler.
VerboseSetTargetAddfastCgi = Adding fastCgi.
VerboseTestTargetResource = Get-TargetResource has been run.
VerboseGetIisHandler = Getting Handler for {0} in Site {1}
VerboseTestTargetResourceImplVerb = Matched Verb {0}
VerboseTestTargetResourceImplExtraVerb = Extra Verb {0}
VerboseTestTargetResourceImplRequestPath = RequestPath is {0}
VerboseTestTargetResourceImplPath = Path is {0}
VerboseTestTargetResourceImplresourceStatusRequestPath = StatusRequestPath is {0}
VerboseTestTargetResourceImplresourceStatusPath = StatusPath is {0}
VerboseTestTargetResourceImplModulePresent = Module present is {0}
VerboseTestTargetResourceImplModuleConfigured = ModuleConfigured is {0}
'@
}
# Import Localization Strings
$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xIisModule'

function Get-TargetResource
{
<#
Expand Down Expand Up @@ -90,7 +72,7 @@ function Get-TargetResource
}
}

Write-Verbose -Message $LocalizedData.VerboseGetTargetResource
Write-Verbose -Message $script:localizedData.VerboseGetTargetResource

$returnValue = @{
Path = $handler.ScriptProcessor
Expand Down Expand Up @@ -153,13 +135,13 @@ function Set-TargetResource
{
if ($resourceTests.ModulePresent -and -not $resourceTests.ModuleConfigured)
{
Write-Verbose -Message $LocalizedData.VerboseSetTargetRemoveHandler
Write-Verbose -Message $script:localizedData.VerboseSetTargetRemoveHandler
Remove-IisHandler
}

if (-not $resourceTests.ModulePresent -or -not $resourceTests.ModuleConfigured)
{
Write-Verbose -Message $LocalizedData.VerboseSetTargetAddHandler
Write-Verbose -Message $script:localizedData.VerboseSetTargetAddHandler
Add-webconfiguration /system.webServer/handlers iis:\ -Value @{
Name = $Name
Path = $RequestPath
Expand All @@ -171,15 +153,15 @@ function Set-TargetResource

if (-not $resourceTests.EndPointSetup)
{
Write-Verbose -Message $LocalizedData.VerboseSetTargetAddfastCgi
Write-Verbose -Message $script:localizedData.VerboseSetTargetAddfastCgi
Add-WebConfiguration /system.webServer/fastCgi iis:\ -Value @{
FullPath = $Path
}
}
}
else
{
Write-Verbose -Message $LocalizedData.VerboseSetTargetRemoveHandler
Write-Verbose -Message $script:localizedData.VerboseSetTargetRemoveHandler
Remove-IisHandler
}
}
Expand Down Expand Up @@ -223,7 +205,7 @@ function Test-TargetResource
$getParameters = Get-PSBoundParameters -FunctionParameters $PSBoundParameters
$resourceStatus = Get-TargetResource @GetParameters

Write-Verbose -Message $LocalizedData.VerboseTestTargetResource
Write-Verbose -Message $script:localizedData.VerboseTestTargetResource

return (Test-TargetResourceImpl @PSBoundParameters -ResourceStatus $resourceStatus).Result
}
Expand Down Expand Up @@ -289,7 +271,7 @@ function Get-IisHandler
[String] $SiteName
)

Write-Verbose -Message ($LocalizedData.VerboseGetIisHandler -f $Name,$SiteName)
Write-Verbose -Message ($script:localizedData.VerboseGetIisHandler -f $Name,$SiteName)
return Get-Webconfiguration -Filter 'System.WebServer/handlers/*' `
-PSPath (Get-IisSitePath `
-SiteName $SiteName) | `
Expand Down Expand Up @@ -364,13 +346,13 @@ function Test-TargetResourceImpl
{
if ($Verb -icontains $thisVerb)
{
Write-Verbose -Message ($LocalizedData.VerboseTestTargetResourceImplVerb `
Write-Verbose -Message ($script:localizedData.VerboseTestTargetResourceImplVerb `
-f $Verb)
$matchedVerbs += $thisVerb
}
else
{
Write-Verbose -Message ($LocalizedData.VerboseTestTargetResourceImplExtraVerb `
Write-Verbose -Message ($script:localizedData.VerboseTestTargetResourceImplExtraVerb `
-f $Verb)
$mismatchVerbs += $thisVerb
}
Expand All @@ -382,13 +364,13 @@ function Test-TargetResourceImpl
$modulePresent = $true
}

Write-Verbose -Message ($LocalizedData.VerboseTestTargetResourceImplRequestPath `
Write-Verbose -Message ($script:localizedData.VerboseTestTargetResourceImplRequestPath `
-f $RequestPath)
Write-Verbose -Message ($LocalizedData.VerboseTestTargetResourceImplPath `
Write-Verbose -Message ($script:localizedData.VerboseTestTargetResourceImplPath `
-f $Path)
Write-Verbose -Message ($LocalizedData.VerboseTestTargetResourceImplresourceStatusRequestPath `
Write-Verbose -Message ($script:localizedData.VerboseTestTargetResourceImplresourceStatusRequestPath `
-f $($resourceStatus.RequestPath))
Write-Verbose -Message ($LocalizedData.VerboseTestTargetResourceImplresourceStatusPath `
Write-Verbose -Message ($script:localizedData.VerboseTestTargetResourceImplresourceStatusPath `
-f $($resourceStatus.Path))

$moduleConfigured = $false
Expand All @@ -401,9 +383,9 @@ function Test-TargetResourceImpl
$moduleConfigured = $true
}

Write-Verbose -Message ($LocalizedData.VerboseTestTargetResourceImplModulePresent `
Write-Verbose -Message ($script:localizedData.VerboseTestTargetResourceImplModulePresent `
-f $ModulePresent)
Write-Verbose -Message ($LocalizedData.VerboseTestTargetResourceImplModuleConfigured `
Write-Verbose -Message ($script:localizedData.VerboseTestTargetResourceImplModuleConfigured `
-f $ModuleConfigured)
if ($moduleConfigured -and ($ModuleType -ne 'FastCgiModule' -or $resourceStatus.EndPointSetup))
{
Expand Down
16 changes: 16 additions & 0 deletions DSCResources/MSFT_xIisModule/en-US/MSFT_xIisModule.strings.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ConvertFrom-StringData @'
VerboseGetTargetResource = Get-TargetResource has been run.
VerboseSetTargetRemoveHandler = Removing handler.
VerboseSetTargetAddHandler = Adding handler.
VerboseSetTargetAddfastCgi = Adding fastCgi.
VerboseTestTargetResource = Get-TargetResource has been run.
VerboseGetIisHandler = Getting Handler for '{0}' in Site '{1}'.
VerboseTestTargetResourceImplVerb = Matched Verb '{0}'.
VerboseTestTargetResourceImplExtraVerb = Extra Verb '{0}'.
VerboseTestTargetResourceImplRequestPath = RequestPath is '{0}'.
VerboseTestTargetResourceImplPath = Path is '{0}'.
VerboseTestTargetResourceImplresourceStatusRequestPath = StatusRequestPath is '{0}'.
VerboseTestTargetResourceImplresourceStatusPath = StatusPath is '{0}'.
VerboseTestTargetResourceImplModulePresent = Module present is '{0}'.
VerboseTestTargetResourceImplModuleConfigured = ModuleConfigured is '{0}'.
'@

0 comments on commit 6ded0de

Please sign in to comment.