File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -8,3 +8,28 @@ applyTo: "source/**/*.ps1"
88All message strings for Write-Debug, Write-Verbose, Write-Error, Write-Warning
99and other error messages in classes, public commands and private functions should
1010be localized using localized string keys.
11+
12+ ## String File Format
13+ ``` powershell
14+ # Localized resources for <ResourceName>
15+ ConvertFrom-StringData @'
16+ KeyName = Message with {0} placeholder. (PREFIX0001)
17+ '@
18+ ```
19+
20+ ## String ID Format
21+ Use unique IDs: ` (PREFIX####) `
22+ - PREFIX: First letter of each word in resource name or function name
23+ - ####: Sequential number starting 0001
24+ - Examples: SqlSetup → SS0001, SqlAGDatabase → SAGD0001, Get-SqlDscSqlDatabase → GSDSD0001
25+
26+ ## Usage Patterns
27+ ``` powershell
28+ # Verbose/Warning messages
29+ Write-Verbose -Message ($script:localizedData.KeyName -f $value)
30+ Write-Warning -Message ($script:localizedData.KeyName -f $value)
31+
32+ # Error messages
33+ New-InvalidOperationException -Message ($script:localizedData.KeyName -f $value1, $value2)
34+ New-InvalidOperationException -ErrorRecord $_ -Message ($script:localizedData.KeyName -f $value1)
35+ ```
You can’t perform that action at this time.
0 commit comments