Skip to content

Commit 1b30f58

Browse files
committed
Add detailed guidelines for localization string formatting and usage patterns
1 parent d94db30 commit 1b30f58

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

.github/instructions/dsc-community-style-guidelines-localization.instructions.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,28 @@ applyTo: "source/**/*.ps1"
88
All message strings for Write-Debug, Write-Verbose, Write-Error, Write-Warning
99
and other error messages in classes, public commands and private functions should
1010
be 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+
```

0 commit comments

Comments
 (0)