Skip to content

Commit 8391fad

Browse files
authored
Get-LocalizedDataRecursive: Use localized strings (#13)
1 parent a19ca99 commit 8391fad

File tree

8 files changed

+21
-15
lines changed

8 files changed

+21
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
- DscResource.Base
1818
- Move code coverage task in the pipeline to use task `PublishCodeCoverageResults@2`.
19+
- `Get-LocalizedDataRecursive`
20+
- Move strings to localized versions ([issue #7](https://github.com/dsccommunity/DscResource.Base/issues/7)).
21+
- Fix various formatting issues
1922

2023
## [1.1.0] - 2023-02-26
2124

source/Classes/010.ResourceBase.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class ResourceBase
4747

4848
<#
4949
TODO: When this fails, for example when the localized string file is missing
50-
the LCM returns the error 'Failed to create an object of PowerShell
51-
class SqlDatabasePermission' instead of the actual error that occurred.
50+
the LCM returns the error 'Failed to create an object of PowerShell
51+
class SqlDatabasePermission' instead of the actual error that occurred.
5252
#>
5353
$this.localizedData = Get-LocalizedDataRecursive @getLocalizedDataRecursiveParameters
5454
}

source/Private/ConvertFrom-CompareResult.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Returns a hashtable with property name and their expected value.
77
88
.PARAMETER CompareResult
9-
The result from Compare-DscParameterState.
9+
The result from Compare-DscParameterState.
1010
1111
.EXAMPLE
1212
ConvertFrom-CompareResult -CompareResult (Compare-DscParameterState)

source/Private/ConvertFrom-Reason.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
that can be returned as the value of a DSC resource's property **Reasons**.
99
1010
.PARAMETER Reason
11-
Specifies an array of `[Reason]`. Normally the result from the command `Resolve-Reason`.
11+
Specifies an array of `[Reason]`. Normally the result from the command `Resolve-Reason`.
1212
1313
.EXAMPLE
1414
Resolve-Reason -Reason (Resolve-Reason) -ResourceName 'MyResource'

source/Private/Get-ClassName.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
all inherited classes
99
1010
.PARAMETER InputObject
11-
The object to be evaluated.
11+
The object to be evaluated.
1212
1313
.PARAMETER Recurse
14-
Specifies if the class name of inherited classes shall be returned. The
15-
recursive stops when the first object of the type `[System.Object]` is
16-
found.
14+
Specifies if the class name of inherited classes shall be returned. The
15+
recursive stops when the first object of the type `[System.Object]` is
16+
found.
1717
1818
.EXAMPLE
1919
Get-ClassName -InputObject $this -Recurse

source/Private/Get-LocalizedDataRecursive.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
instance.
3131
3232
.EXAMPLE
33-
Get-LocalizedDataRecursive -ClassName (Get-ClassNamn -InputObject $this -Recurse)
33+
Get-LocalizedDataRecursive -ClassName (Get-ClassName -InputObject $this -Recurse)
3434
3535
Returns a hashtable containing all the localized strings for the current
3636
instance and any inherited (parent) classes.
@@ -73,7 +73,7 @@ function Get-LocalizedDataRecursive
7373
$localizationFileName = '{0}.strings' -f $name
7474
}
7575

76-
Write-Debug -Message ('Importing localization data from {0}' -f $localizationFileName)
76+
Write-Debug -Message ($script:localizedData.DebugImportingLocalizationData -f $localizationFileName)
7777

7878
if ($name -eq 'ResourceBase')
7979
{
@@ -88,7 +88,7 @@ function Get-LocalizedDataRecursive
8888
else
8989
{
9090
# Assuming derived class that is not part of this module.
91-
throw 'The class ''{0}'' is not part of module DscResource.Base and no BaseDirectory was passed. Please provide BaseDirectory.'
91+
throw ($script:localizedData.ThrowClassIsNotPartOfModule -f $name)
9292
}
9393

9494
# Get localized data for the class
@@ -107,7 +107,7 @@ function Get-LocalizedDataRecursive
107107

108108
end
109109
{
110-
Write-Debug -Message ('Localization data: {0}' -f ($localizedData | ConvertTo-JSON))
110+
Write-Debug -Message ($script:localizedData.DebugShowAllLocalizationData -f ($localizedData | ConvertTo-JSON))
111111

112112
return $localizedData
113113
}

source/Private/Resolve-Reason.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
`Compare-DscParameterState`. The result is an array of the type `[Reason]`.
88
99
.PARAMETER Property
10-
The result from the command Compare-DscParameterState.
10+
The result from the command Compare-DscParameterState.
1111
1212
.PARAMETER ResourceName
13-
The name of the resource. Will be used to populate the property Code with
14-
the correct value.
13+
The name of the resource. Will be used to populate the property Code with
14+
the correct value.
1515
1616
.EXAMPLE
1717
Resolve-Reason -Property (Compare-DscParameterState) -ResourceName 'MyResource'

source/en-US/DscResource.Base.strings.psd1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
#>
77

88
ConvertFrom-StringData @'
9+
DebugImportingLocalizationData = Importing localization data from '{0}' (DRB0001)
10+
ThrowClassIsNotPartOfModule = The class '{0}' is not part of module DscResource.Base and no BaseDirectory was passed. Please provide BaseDirectory. (DRB0002)
11+
DebugShowAllLocalizationData = Localization data: '{0}' (DRB0003)
912
'@

0 commit comments

Comments
 (0)