Skip to content

Extend Get-Culture with a -Name parameter to allow retrieving a specific culture #3832

Closed

Description

Get-Culture currently supports returning information about the current culture.

It would be helpful if it supported a -Name switch to allow retrieving information about a specified culture.

(This would be analogous to existing Get-Date behavior, which by default returns the current date and optionally supports operating on a specified date via -Date.)

Also, as Ilya (@iSazonov) suggests, listing available cultures should be supported: -ListAvailable, supplemented by an optional -Type parameter that defaults to SpecificCultures - (see https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx for permissible values, though not all of them may make sense).

Desired behavior

# Should be the equivalent of: [cultureinfo]::GetCultureInfo('fr-FR')
> Get-Culture fr-FR      # assumes that -Name is the 1st positional param

LCID             Name             DisplayName                                                                                                                                      
----             ----             -----------                                                                                                                                      
1036             fr-FR            French (France)                                                                                                                                  

# Should be the equivalent of [cultureinfo]::GetCultures('SpecificCultures')
> Get-Culture -ListAvailable

LCID             Name             DisplayName                                                                                                                                      
----             ----             -----------                                                                                                                                      
4096             af-NA            Afrikaans (Namibië)                                                                                                                              
1078             af-ZA            Afrikaans (South Africa)                                                                                                                         
# ....

Environment data

PowerShell Core v6.0.0-beta (v6.0.0-beta.1)

Activity

  1. added
    Issue-Discussion
    on May 20, 2017
  2. iSazonov commented on May 20, 2017

    @iSazonov
    Collaborator

    What is the benefit we get from getting the CultureInfo instance ?

  3. mklement0 commented on May 20, 2017

    @mklement0
    ContributorAuthor

    If there's value in getting the current culture's [System.Globalization.CultureInfo] instance - which is currently the sole purpose of Get-Culture - then there's obviously value in getting a different culture's information.

    For instance, if you wanted to get a given culture's list-separator character, you could then do

    (Get-Culture it-IT).TextInfo.ListSeparator  # assuming -Name is the 1st positional param

    instead of

    [cultureinfo]::GetCultureInfo('it-IT').TextInfo.ListSeparator
  4. iSazonov commented on May 20, 2017

    @iSazonov
    Collaborator

    Then needed -ListAvailable

  5. mklement0 commented on May 20, 2017

    @mklement0
    ContributorAuthor

    Ilya (@iSazonov): Good idea - initial post updated.

  6. changed the title [-]Extend Get-Culture with a -Name parameter to allow targeting a given culture[/-] [+]Extend Get-Culture with a -Name parameter to allow retrieving a specific culture[/+] on Aug 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-DiscussionResolution-FixedWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions