Title: Import-LocalizedData implicit Localization fallback · Issue #19923 · PowerShell/PowerShell · GitHub
Open Graph Title: Import-LocalizedData implicit Localization fallback · Issue #19923 · PowerShell/PowerShell
X Title: Import-LocalizedData implicit Localization fallback · Issue #19923 · PowerShell/PowerShell
Description: Summary of the new feature / enhancement Import-LocalizedData should implement a default culture fallback when -UICulture is not specified to simulate the functionality of the command in Windows PowerShell. PR: #19896 Proposed technical ...
Open Graph Description: Summary of the new feature / enhancement Import-LocalizedData should implement a default culture fallback when -UICulture is not specified to simulate the functionality of the command in Windows Po...
X Description: Summary of the new feature / enhancement Import-LocalizedData should implement a default culture fallback when -UICulture is not specified to simulate the functionality of the command in Windows Po...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/19923
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Import-LocalizedData implicit Localization fallback","articleBody":"### Summary of the new feature / enhancement\n\n`Import-LocalizedData` should implement a default culture fallback when `-UICulture` is not specified to simulate the functionality of the command in Windows PowerShell.\r\n\r\nPR: #19896\n\n### Proposed technical implementation details (optional)\n\n`Import-LocalizedData` is used by several of the modules released by other teams in Microsoft, most of which as cdxml with a small amount of other code.\r\n\r\nFor example, in PowerShell 7, attempting to import the SmbShare module will result in an error:\r\n\r\n```powershell\r\nPS\u003e Import-Module SmbShare\r\nImport-LocalizedData: Cannot find the PowerShell data file 'SmbLocalization.psd1' in directory\r\n'C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\SmbShare\\en-GB', or in any parent culture directories.\r\n```\r\n\r\nOr more directly:\r\n\r\n```powershell\r\nPush-Location C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\smbshare\r\nImport-LocalizedData -BindingVariable _system_translations -fileName SmbLocalization.psd1 -ea stop\r\n$_system_translations\r\nPop-Location\r\n```\r\n\r\nThis error is not present in Windows PowerShell.\r\n\r\nThis error is caused by a difference in how .NET Core+ and .NET Framework handle the `CurrentUICulture` static property\r\nIn .NET Core and higher, the values in the parent list are arguably correct:\r\n\r\n```powershell\r\n$culture = [System.Globalization.CultureInfo]::CurrentUICulture\r\ndo { $culture.Name; $culture = $culture.Parent } while ($culture.Name)\r\n```\r\n\r\nFor my culture of en-GB results in the following list:\r\n\r\n```\r\nen-GB\r\nen\r\n# \u003cInvariant\u003e\r\n```\r\n\r\nHowever, if the same test is repeated in Windows PowerShell `en-US` is implicitly added to the bottom of the list. This only happens when the culture is found using the static property `CultureInfo.CurrentUICulture` .\r\n\r\nThe result in Windows PowerShell is shown below.\r\n\r\n```powershell\r\nPS\u003e $culture = [System.Globalization.CultureInfo]::CurrentUICulture\r\nPS\u003e do { $culture.Name; $culture = $culture.Parent } while ($culture.Name)\r\nen-GB\r\nen\r\nen-US\r\nen\r\n# \u003cInvariant\u003e\r\n```\r\n\r\nA spot check of a few other non-en-US UI cultures shows similar results, but I haven't looked hard enough to find a simple way to change the current UI culture (in Windows PowerShell) to really prove that.\r\n\r\nFor `Import-LocalizedData` this represents an implicit fallback culture in Windows PowerShell. While this is arguably caused by a bug in .NET, the result is that modules were released with content that worked based on the presence of this bug.\r\n\r\n`Import-LocalizedData` is used by a fairly broad set of modules in the `system32` directory, including:\r\n\r\n```\r\nAppx\r\nAssignedAccess\r\nBitLocker\r\nDhcpServer\r\nFailoverClusters\r\nHgsClient\r\nIpamServer\r\nIscsiTarget\r\nMicrosoft.PowerShell.Archive\r\nMicrosoft.PowerShell.ODataUtils\r\nMsDtc\r\nNetworkSwitchManager\r\nRemoteDesktop\r\nServerManager\r\nSmbShare\r\nStorageQoS\r\nStorageReplica\r\n```\r\n\r\nI propose that when the `-UICulture` parameter is not supplied, that `en-US` should be added to the bottom of the list of parent cultures to search. This restores the behaviour of the command as it was in 5.1.","author":{"url":"https://github.com/chrisdent-de","@type":"Person","name":"chrisdent-de"},"datePublished":"2023-07-11T08:19:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/19923/PowerShell/issues/19923"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c6142efe-2457-8e8d-0967-6a93c6d3f362 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E1DC:13D9C3:1FBABD:2ADD5D:6A581641 |
| html-safe-nonce | 038161d874ded6d9dcf1a8251bdd51f2f115fcd83a7849fe3cbfacb8576b4205 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMURDOjEzRDlDMzoxRkJBQkQ6MkFERDVEOjZBNTgxNjQxIiwidmlzaXRvcl9pZCI6IjE3NDU0MTMzODczMzU1MDU0NzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6873c43b8a1d1a0a7b3c686ea05bbcba3c1b775174216365a8056808e8c14590 |
| hovercard-subject-tag | issue:1798386658 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/19923/issue_layout |
| twitter:image | https://opengraph.githubassets.com/35f1901f4a063eab7b5fc8d0c33afe576c64a57fac930b9ece57d47662659cc8/PowerShell/PowerShell/issues/19923 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/35f1901f4a063eab7b5fc8d0c33afe576c64a57fac930b9ece57d47662659cc8/PowerShell/PowerShell/issues/19923 |
| og:image:alt | Summary of the new feature / enhancement Import-LocalizedData should implement a default culture fallback when -UICulture is not specified to simulate the functionality of the command in Windows Po... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chrisdent-de |
| hostname | github.com |
| expected-hostname | github.com |
| None | 49c8c15fabcbf356d607a90ca115c13b273e42ff8b74155de050fd229a9b0121 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3fb1f684e7a833eb1b2d01d39875a2b52cb4fe9b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width