Thursday, September 14, 2017

What does ###PSLOC signify in PSD1 localization files

Leave a Comment

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:

  1. What does it's presence or absence tell the PowerShell engine
  2. Preferably also where in the PowerShell source it is processed

1 Answers

Answers 1

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).

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 Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment