In every almost every Microsoft project that uses localization files there is the text ###PSLOC
before and after the block of resource strings. Here is an example:
ConvertFrom-StringData @'
###PSLOC
MyString=This is a string.
###PSLOC
'@
Here is an example from the PowerShellGet repo.
I can't find any reference to this in any of the help files. I've looked in about_Data_Sections, ConvertFrom-StringData and about_Script_Internationalization. And the only instances of ###PSLOC
in
the PowerShell source is in resource files like shown above.
More specifically I'd love to know:
###PSLOC
is used by an internal localization tool when building Windows. The comment is not special to the PowerShell engine in any way.
The localization tool is extensible to support many different file parsers to extract the resources for further localization processing.
The extension for PowerShell is based on an ini file parser and the comments are used to tell the parser when to ignore lines. This allows authors of the psd1 file to mix proper PowerShell and lines the ini file parser won't have problems with.
I have searched a while and came to the conclusion that ###PSLOC
is just convention and has no special meaning, even though I could not find an official document.
I found some Microsoft documents that led me to this conclusion. For instance: "Microsoft Baseline Configuration Analyzer Model Authoring Guide" shows this sample on page 20:
Sample of content file
The following is an example of the content file of the Antivirus model: Antivirus.psd1# Only add new (name,value) pairs to the end of this table # Do not remove, insert or re-arrange entries ConvertFrom-StringData @' ###PSLOC start localizing # # helpID="ScanBootSector" # ScanBootSector_title = Boot Sector Scan (Indicator Setting {0}) ScanBootSector_problem = tbd: Problem for Constant name issue-1 ScanBootSector_impact = tbd: Impact for Constant name issue-1 ScanBootSector_resolution = tbd: Resolution for Constant name issue-1 ScanBootSector_compliant = tbd: Compliant for Constant name issue-1 # # helpID="AutoUpdateStatus" # AutoUpdateStatus_title = Auto Update Status (Indicator Setting {0}) AutoUpdateStatus_problem = tbd: Problem for Constant name issue-2 AutoUpdateStatus_impact = tbd: Impact for Constant name issue-2 AutoUpdateStatus_resolution = tbd: Resolution for Constant name issue-2 AutoUpdateStatus_compliant = tbd: Compliant for Constant name issue-2 '@
Notice that ###PSLOC
followed by a additional description and more simple comments and there is no closing ###PSLOC
.
The book "Pro PowerShell for Database Developers" by Bryan P. Cafferky shows on p. 140 ConvertFrom-StringData sections that do not include ###PSLOC
blocks/tags at all.
Another clue comes from my very own Windows 10 system.
I grepped all *.psd1 files and learned that some do not have a proper closing ###PSLOC
-block/tag but ###PSCLOCC
insead, e.g. c:\windows\WinSxS\amd64_microsoft-windows-pnpdevice-powershell_31bf3856ad364e35_10.0.15063.0_none_e99b05a055a1e6c4\PnpDevice.Resource.psd1 (this could be a bug as well).
Finally, I searched the Powershell (core) repo, but could not find any treatment for ###PSLOC
.
So, the case is not 100% clear. But arguably I have found some good evidence that it has no special meaning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With