Sunday, 22 January 2012

Show-ChineeseParentCulture.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script displays the parent culture of each  
  4.     specific culture using the Chinese language. 
  5. .DESCRIPTION 
  6.     This script looks at each Chineese culture and displays 
  7.     the culture name and the parent.  
  8. .NOTES 
  9.     File Name  : Show-ChineeseParentCulture.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell Version 2.0 
  12. .LINK 
  13.     This script posted to: 
  14.         http://www.pshscripts.blogspot.com 
  15.     MSDN sample posted to: 
  16.          http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx    
  17. .EXAMPLE 
  18.     C:\foo> .\Show-ChineeseParentCulture.ps1 
  19.     SPECIFIC CULTURE                                     PARENT CULTURE 
  20.     0x0804 zh-CN Chinese (Simplified, PRC)               0x0004 zh-CHS Chinese (Simplified) Legacy 
  21.     0x0C04 zh-HK Chinese (Traditional, Hong Kong S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) Legacy 
  22.     0x1404 zh-MO Chinese (Traditional, Macao S.A.R.)     0x7C04 zh-CHT Chinese (Traditional) Legacy 
  23.     0x1004 zh-SG Chinese (Simplified, Singapore)         0x0004 zh-CHS Chinese (Simplified) Legacy 
  24.     0x0404 zh-TW Chinese (Traditional, Taiwan)           0x7C04 zh-CHT Chinese (Traditional) Legacy     
  25. #> 
  26.  
  27. # Display a header 
  28. "SPECIFIC CULTURE                                     PARENT CULTURE" 
  29.  
  30. # Determine the specific cultures that use the Chinese language, and displays the parent culture 
  31.  
  32. ForEach ($ci in [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]::SpecificCultures))  { 
  33.   if ($ci.TwoLetterISOLanguageName -eq "zh"
  34.    { 
  35.     $s1 = "0x{0} {1} {2,-40}" -f $ci.LCID.ToString("X4"), $ci.Name, $ci.EnglishName 
  36.     $s2 = "0x{0} {1} {2}" -f $ci.Parent.LCID.ToString("X4"), $ci.Parent.Name, $ci.Parent.EnglishName 
  37.     "{0}{1}" -f $s1, $s2 
  38.   } 

No comments: