2017-09-02 19 views
11

在几乎每个使用本地化文件的Microsoft项目中,在资源字符串块之前和之后都有文本###PSLOC 。下面是一个例子:### PSLOC在PSD1本地化文件中的含义

ConvertFrom-StringData @' 
###PSLOC 
MyString=This is a string. 
###PSLOC 
'@ 

PowerShellGet回购Here is an example

我无法找到任何的帮助文件对这个任何引用。我查看了about_Data_SectionsConvertFrom-StringDataabout_Script_Internationalization。并且在 中的###PSLOC的唯一实例PowerShell源位于如上所示的资源文件中。

更具体地说我很想知道:

  1. 这是什么的存在与否告诉PowerShell引擎
  2. 还优选其中PowerShell的源被处理
+0

一如既往在PoSh代码中'''表示一个评论。 – LotPings

+1

@LotPings并不总是,例如'require'声明。我不认为这只是一个评论,或者如果它是,那么我很好奇它是什么意思传达。 –

+0

即使这个需求被包装/隐藏在注释中,也不会影响早期的PowerShell版本。国际海事组织'### PSLOC'是一些自动化的残余。 – LotPings

回答

3

###PSLOC在构建Windows时由内部本地化工具使用。以任何方式评论对于PowerShell引擎都不是特别的。

本地化工具是可扩展的,以支持许多不同的文件解析器来提取资源以进行进一步的本地化处理。

PowerShell扩展基于ini文件解析器,注释用于告诉解析器何时忽略行。这允许psd1文件的作者混合适当的PowerShell和ini文件解析器不会有问题的行。

+0

奇妙的是,它完美地清除了它。谢谢贾森! –

5

我有搜索了一会儿,来到了结论,###PSLOC只是惯例,并没有特殊的含义,即使我无法找到一个正式文件。

我发现了一些微软的文档,导致我得出这个结论。例如:“Microsoft基准配置分析器型号创作指南”显示,第20页此示例:

示例内容文件
下面的是防病毒模型的内容文件的例子: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 
    '@ 

注意,后跟一个附加说明,更简单的评论###PSLOC并没有结束###PSLOC

由Bryan P. Cafferky撰写的书“用于数据库开发人员的Pro PowerShell” 140 ConvertFrom-StringData部分根本不包含###PSLOC块/标签。

另一条线索来自于我自己的Windows 10系统。
我grepped所有* .psd1文件,并了解到一些没有适当的关闭###PSLOC - 块/标签,但###PSCLOCC insead,例如。 C:\ WINDOWS \ WinSxS文件\ Amd64_microsoft窗口 - pnpdevice-powershell_31bf3856ad364e35_10.0.15063.0_none_e99b05a055a1e6c4 \ PnpDevice.Resource.psd1(这可能是一个错误以及)。

最后,我搜索了Powershell(核心)回购,但找不到###PSLOC的任何处理。

因此,案件不是100%清楚。但可以说我找到了一些很好的证据表明它没有特别的意义。