Use Import-LocalizedData to Internationalize your Scripts
Whether you’re working with an enterprise client with a global presence or building a tool that you want to share with the world, you may find yourself wanting to build support for multiple languages into your scripts. The Import-LocalizedData Cmdlet is a simple and powerful way to achieve this. I put up a pair of posts about my recent experience with a globalization effort and how we were able to get a lot of functionality with only a few lines of code.
The first post, Internationalization with Import-LocalizedData, describes the Cmdlet itself, how it works, and how to use it to automatically detect and load the correct language files for display at runtime. This is based on the regional settings of the user under which the PowerShell session is running.
The second post, Internationalization with Import-LocalizedData: Part 2, goes into more detail about some research we had to do into what exact regional settings control the language that PowerShell will attempt to use.
Even if you’re not planning to localize your scripts into other languages right now, you should still think about globalizing your code so that it’s easy to do if you change your mind, or if someone is kind enough to want to contribute some translations.
Related Articles
The Ternary Cometh
Developers are likely to be familiar with ternary conditional operators as they’re legal in many languages (Ruby, Python, C++, etc). They’re also often used in coding interviews to test an applicant as they can be a familiar source of code errors. While some developers couldn’t care less about ternary operators, there’s been a cult following waiting for them to show up in Powershell. That day is almost upon us. Any Powershell developer can easily be forgiven for scratching their heads and wondering what a ternary is.
Learn To Use Verbose Output Streams In Your Pester Tests
I’m going to file this under “Either I’m a genius, or there’s a much better way and everyone knows it except for me.” I recently began adding a suite of Pester tests to one of my projects and I found myself needing to mock some unit tests against a particular function that would modify a variable based on the parameter specified. Since all the functions I write nowadays are considered advanced functions (and yours should be too, they’re free!
Secure Your Powershell Session with JEA and Constrained Endpoints
Index What is a Constrained Endpoint and Why Would I Need One? Setup and Configuration Using our Endpoint What is a constrained endpoint and why would I need one? Powershell constrained endpoints are a means of interacting with powershell in a manner consistent with the principal of least privilege. In Powershell terms, this is referred to as Just-Enough-Administration, or JEA. JEA is very well documented, so this won’t simply be repeating everything those references detail.