Repository: microsoft/terminal
File: tools/ConvertTo-PseudoLocalization.ps1 (PowerShell)

Code before:
$mapping['r'[0]] = 'ŕŗřяѓґгř'
$mapping['R'[0]] = 'ŔŖŘЯΓЃҐГ'
$mapping['s'[0]] = 'śŝşѕš'
$mapping['S'[0]] = 'ŚŜŞЅŠ'
$mapping['t'[0]] = 'ţťŧτт'
$mapping['T'[0]] = 'ŢŤŦΤТ'
$mapping['u'[0]] = 'µùúûüũūŭůűųΰυϋύцμџ'
$mapping['U'[0]] = 'ÙÚÛÜŨŪŬŮŰŲЏЦ'
$mapping['v'[0]] = 'ν'
$mapping['w'[0]] = 'ŵωώшщẁẃẅ'
$mapping['W'[0]] = 'ŴШЩẀẂẄ'
$mapping['x'[0]] = '×хж'
$mapping['X'[0]] = 'ΧχХЖ'
$mapping['y'[0]] = 'ýÿŷγўỳу'
$mapping['Y'[0]] = '¥ÝŶΎΥΫỲЎ'
$mapping['z'[0]] = 'źżž'
$mapping['Z'[0]] = 'ŹŻΖŽ'

$content = [System.Xml.XmlDocument]::new()
$content.PreserveWhitespace = $true
$content.Load($Path)

function GetPseudoLocalization([string]$key, [string]$value, [string]$comment) {
    $placeholders = @{}

    if ($comment -match '.*\{Locked=?([^}]*)\}.*') {
        $locked = $Matches[1] ?? ''

        # Skip {Locked} and {Locked=qps-ploc} entries
        if ((($locked -eq '') -or $locked.Contains('qps-ploc'))) {
            return $value
        }

        $lockedList = $locked -split ','
        $placeholderChar = 0xE000

        # Replaced all locked words with placeholders from the Unicode Private Use Area
        foreach ($locked in $lockedList) {
            if ($locked.StartsWith('"') -and $locked.EndsWith('"')) {
                $locked = $locked.Substring(1, $locked.Length - 2)
                $locked = $locked.Replace('\"', '"')
            }

            $placeholder = "$([char]$placeholderChar)"
            $placeholderChar++

            $placeholders[$placeholder] = $locked
            $value = $value.Replace($locked, $placeholder)
        }
    }


Review comment (suggestion):
Unless you are trying to capture the explicit text *around* `{Locked...}`, you should drop the `.*` at the beginning and end of this regex.

Code after:
$mapping['r'[0]] = 'ŕŗřяѓґгř'
$mapping['R'[0]] = 'ŔŖŘЯΓЃҐГ'
$mapping['s'[0]] = 'śŝşѕš'
$mapping['S'[0]] = 'ŚŜŞЅŠ'
$mapping['t'[0]] = 'ţťŧτт'
$mapping['T'[0]] = 'ŢŤŦΤТ'
$mapping['u'[0]] = 'µùúûüũūŭůűųΰυϋύцμџ'
$mapping['U'[0]] = 'ÙÚÛÜŨŪŬŮŰŲЏЦ'
$mapping['v'[0]] = 'ν'
$mapping['w'[0]] = 'ŵωώшщẁẃẅ'
$mapping['W'[0]] = 'ŴШЩẀẂẄ'
$mapping['x'[0]] = '×хж'
$mapping['X'[0]] = 'ΧχХЖ'
$mapping['y'[0]] = 'ýÿŷγўỳу'
$mapping['Y'[0]] = '¥ÝŶΎΥΫỲЎ'
$mapping['z'[0]] = 'źżž'
$mapping['Z'[0]] = 'ŹŻΖŽ'

$content = [System.Xml.XmlDocument]::new()
$content.PreserveWhitespace = $true
$content.Load($Path)

function GetPseudoLocalization([string]$key, [string]$value, [string]$comment) {
    $placeholders = @{}
    $placeholderChar = 0xE000

    # Iterate through all {Locked=...} comments and replace locked
    # words with placeholders from the Unicode Private Use Area.
    foreach ($m in [regex]::Matches($comment, '\{Locked=?([^}]*)\}')) {
        $locked = $m.Groups[1].Value

        # Skip {Locked} and {Locked=qps-ploc} entries
        if (($locked -eq '') -or $locked.Contains('qps-ploc')) {
            return $value
        }

        $lockedList = $locked -split ','

        foreach ($locked in $lockedList) {
            if ($locked.StartsWith('"') -and $locked.EndsWith('"')) {
                $locked = $locked.Substring(1, $locked.Length - 2)
                $locked = $locked.Replace('\"', '"')
            }

            $placeholder = "$([char]$placeholderChar)"
            $placeholderChar++

            $placeholders[$placeholder] = $locked
            $value = $value.Replace($locked, $placeholder)
        }
    }