< Summary - Kestrun — Combined Coverage

Information
Class: Public.Localization.Get-KrLocalizedString
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Localization/Get-KrLocalizedString.ps1
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
0%
Covered lines: 0
Uncovered lines: 16
Coverable lines: 16
Total lines: 56
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 01/24/2026 - 19:35:59 Line coverage: 0% (0/16) Total lines: 56 Tag: Kestrun/Kestrun@f59dcba478ea75f69584d696e5f1fb1cfa40aa51

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Localization/Get-KrLocalizedString.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Returns a localized string for the current request culture.
 4    .DESCRIPTION
 5        Looks up a key in the request-local string table exposed by Kestrun localization middleware.
 6        The current culture is determined by middleware and is not passed explicitly.
 7    .PARAMETER Key
 8        The localization key to retrieve.
 9    .PARAMETER Default
 10        Optional default value to return when the key is not present.
 11    .EXAMPLE
 12        Get-KrLocalizedString -Key 'Labels.Save'
 13    .EXAMPLE
 14        Get-KrLocalizedString -Key 'Labels.Save' -Default 'Save'
 15    .OUTPUTS
 16        System.String
 17#>
 18function Get-KrLocalizedString {
 19    [KestrunRuntimeApi('Route')]
 20    [CmdletBinding()]
 21    [OutputType([string])]
 22    param(
 23        [Parameter(Mandatory)]
 24        [string]$Key,
 25
 26        [Parameter()]
 27        [string]$Default
 28    )
 29
 030    $strings = $null
 031    if ($null -ne $Context) {
 032        $localizedProp = $Context.PSObject.Properties['LocalizedStrings']
 033        if ($null -ne $localizedProp) {
 034            $strings = $localizedProp.Value
 035        } elseif ($Context.PSObject.Properties['Strings']) {
 036            $strings = $Context.Strings
 37        }
 38    }
 39
 040    if ($null -eq $strings) {
 041        if ($PSBoundParameters.ContainsKey('Default')) {
 042            return $Default
 43        }
 044        return $null
 45    }
 46
 047    if ($strings.ContainsKey($Key)) {
 048        return $strings[$Key]
 49    }
 50
 051    if ($PSBoundParameters.ContainsKey('Default')) {
 052        return $Default
 53    }
 54
 055    return $null
 56}

Methods/Properties

Get-KrLocalizedString()