schon/scripts/Windows/export-environment-file.ps1
Egor fureunoir Gorbunov b92e7e28f1 Features: 1) Add new email content translations for ru_RU, zh_Hans, and ro_RO locales; 2) Update "balance deposit" and general email-related translations across multiple languages;
Fixes: 1) Correct inconsistent formatting in translation strings; 2) Fix placeholders in email templates for better accuracy;

Extra: Update `.gitignore` to include `.env` file exclusion.
2025-06-22 20:18:19 +03:00

53 lines
1.1 KiB
PowerShell

#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
.\scripts\Windows\starter.ps1
$envFile = '.env'
if (-not (Test-Path $envFile))
{
Write-Error ".env file not found in the current directory."
exit 1
}
$envVars = @{ }
Get-Content $envFile | ForEach-Object {
$line = $_.Trim()
if ($line -eq '' -or $line.StartsWith('#'))
{
return
}
if ($line -notmatch '=')
{
return
}
$m = [Regex]::Match($line, '^\s*([^=]+?)\s*=\s*(.*)$')
if (-not $m.Success)
{
return
}
$key = $m.Groups[1].Value
$value = $m.Groups[2].Value
if (( $value.StartsWith('"') -and $value.EndsWith('"')) -or
( $value.StartsWith("'") -and $value.EndsWith("'")))
{
$value = $value.Substring(1, $value.Length - 2)
}
New-Item -Force -Path Env:\$key -Value $value | Out-Null
$envVars[$key] = $value
}
if ($envVars.Count -gt 0)
{
$formatted = ($envVars.GetEnumerator() | Sort-Object Name | ForEach-Object {
"$( $_.Key )=$( $_.Value )"
}) -join ';'
Write-Host $formatted
}