Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 42 additions & 7 deletions .github/actions/build-windows-x64/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,58 @@ runs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
dotnet-version: '10.0.x'

- name: Restore
shell: cmd
run: dotnet restore BSPLocalizationTools.sln
run: dotnet restore BSPLocalizationTools.slnx

- name: Test
shell: cmd
run: dotnet test BSPLocalizationTools.sln -c Release --no-restore
run: dotnet test BSPLocalizationTools.slnx -c Release --no-restore

- name: Publish GUI (single file)
- name: Publish GUI (Native AOT)
shell: cmd
run: dotnet publish src\BSPLocalizationTools\BSPLocalizationTools.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true -o BSPLocalizationTools-Output\GUI
run: dotnet publish src\BSPLocalizationTools\BSPLocalizationTools.csproj -c Release -r win-x64 -o BSPLocalizationTools-Output\GUI

- name: Publish CLI (single file)
- name: Publish CLI (Native AOT)
shell: cmd
run: dotnet publish src\BSPLocalizationToolsCLI\BSPLocalizationToolsCLI.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true -o BSPLocalizationTools-Output\CLI
run: dotnet publish src\BSPLocalizationToolsCLI\BSPLocalizationToolsCLI.csproj -c Release -r win-x64 -o BSPLocalizationTools-Output\CLI

- name: Verify publish output
shell: pwsh
run: |
# Native AOT discards PDBs; the release payload never ships them.
Get-ChildItem -LiteralPath 'BSPLocalizationTools-Output' -Filter *.pdb -Recurse | Remove-Item -Force

$cliDirectory = 'BSPLocalizationTools-Output\CLI'
$cliFiles = @(Get-ChildItem -LiteralPath $cliDirectory -Recurse -File)
if ($cliFiles.Count -ne 1 -or $cliFiles[0].Name -ne 'BSPLocalizationToolsCLI.exe') {
throw 'CLI publish must contain exactly one self-contained executable.'
}

# Native AOT cannot fold Avalonia's native backends into the executable, and
# satellite resource assemblies are still emitted for localized strings. The
# set is exact: anything else means an unintended payload crept in.
$exeName = 'BSPLocalizationTools.exe'
$nativeDlls = @('av_libglesv2.dll', 'libSkiaSharp.dll', 'libHarfBuzzSharp.dll')
$guiDirectory = 'BSPLocalizationTools-Output\GUI'
$guiFiles = @(Get-ChildItem -LiteralPath $guiDirectory -Recurse -File)
$unexpected = @($guiFiles | Where-Object {
$_.Name -ne $exeName -and $nativeDlls -notcontains $_.Name -and
$_.Name -ne 'BSPLocalizationTools.resources.dll'
})
if ($unexpected.Count -gt 0) {
throw "GUI publish contains unexpected files: $($unexpected.Name -join ', ')"
}
if (!(Test-Path -LiteralPath (Join-Path $guiDirectory $exeName) -PathType Leaf)) {
throw "GUI publish is missing its executable: $exeName"
}
foreach ($nativeDll in $nativeDlls) {
if (!(Test-Path -LiteralPath (Join-Path $guiDirectory $nativeDll) -PathType Leaf)) {
throw "GUI publish is missing its native backend library: $nativeDll"
}
}

- name: Copy README to output
shell: cmd
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
.vs/
.env
**/.env
/BSPLocalizationTools-Output/
/build/

# Generated at build time by Microsoft.CodeAnalysis.ResxSourceGenerator
**/Resources.Designer.cs
84 changes: 0 additions & 84 deletions BSPLocalizationTools.sln

This file was deleted.

15 changes: 15 additions & 0 deletions BSPLocalizationTools.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Solution>
<Configurations>
<Platform Name="Any CPU" />
<Platform Name="x64" />
<Platform Name="x86" />
</Configurations>
<Folder Name="/src/">
<Project Path="src/BSPLocalizationTools/BSPLocalizationTools.csproj" />
<Project Path="src/BSPLocalizationToolsCLI/BSPLocalizationToolsCLI.csproj" />
<Project Path="src/BSPLocalizationToolsCore/BSPLocalizationToolsCore.csproj" />
</Folder>
<Folder Name="/tests/">
<Project Path="tests/BSPLocalizationTools.Tests/BSPLocalizationTools.Tests.csproj" />
</Folder>
</Solution>
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,28 @@ The **Settings** tab loads and saves LLM and prompt path settings to `.env`.
## Encodings

CSV output is always written as UTF-8 with BOM.

## Build

Use Windows x64 with the **.NET 10 SDK**. Publishing the GUI and CLI as Native
AOT additionally requires the Visual Studio 2022 **Desktop development with C++**
workload (MSVC linker) and a Windows SDK.

From the repository root:

```powershell
dotnet restore BSPLocalizationTools.slnx
dotnet test BSPLocalizationTools.slnx -c Release
dotnet run --project src\BSPLocalizationTools # Avalonia GUI
dotnet run --project src\BSPLocalizationToolsCLI -- "-bsp=path\to\map.bsp" # CLI
```

Both executables are published as self-contained Native AOT programs, so the
target machine does not need the .NET runtime. Native AOT cannot fold Avalonia's
native backends into the executable, so the GUI ships as the executable plus its
native libraries:

```powershell
dotnet publish src\BSPLocalizationTools\BSPLocalizationTools.csproj -c Release -r win-x64 -o out\GUI
dotnet publish src\BSPLocalizationToolsCLI\BSPLocalizationToolsCLI.csproj -c Release -r win-x64 -o out\CLI
```
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "10.0.100",
"rollForward": "latestFeature"
}
}
22 changes: 15 additions & 7 deletions src/BSPLocalizationTools/BSPLocalizationTools.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
<TargetFramework>net10.0-windows10.0.17763.0</TargetFramework>
<RootNamespace>BSPLocalizationTools.GUI</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand All @@ -10,15 +10,23 @@
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<PlatformTarget>x64</PlatformTarget>
<PublishTrimmed>true</PublishTrimmed>
<PublishAot>true</PublishAot>
<!--Native AOT size settings; kept here so they apply to every publish, profile or not.-->
<TrimMode>full</TrimMode>
<StripSymbols>true</StripSymbols>
<StackTraceSupport>false</StackTraceSupport>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.3.8" />
<PackageReference Include="Avalonia.Desktop" Version="11.3.8" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.8" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.8" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.8" />
<PackageReference Include="ReactiveUI.Avalonia" Version="11.3.0" />
<PackageReference Include="Avalonia" Version="12.1.3" />
<PackageReference Include="Avalonia.Desktop" Version="12.1.3" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="12.1.3" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="12.1.3" />
<PackageReference Include="ReactiveUI.Avalonia" Version="12.1.6" />
<!--No longer transitive via ReactiveUI.Avalonia 12; used for System.Reactive.Linq.-->
<PackageReference Include="System.Reactive" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/BSPLocalizationTools/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public static AppBuilder BuildAvaloniaApp()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace()
.UseReactiveUI();
.UseReactiveUI(_ => { });
}
}
16 changes: 8 additions & 8 deletions src/BSPLocalizationTools/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<TabItem Header="{Binding Strings.TranslateTab}">
<Grid RowDefinitions="Auto,*,Auto,160" RowSpacing="12">
<Grid ColumnDefinitions="*,Auto,Auto,Auto" ColumnSpacing="8">
<TextBox Text="{Binding OutLang}" Watermark="{Binding Strings.TargetLanguage}" />
<TextBox Text="{Binding OutLang}" PlaceholderText="{Binding Strings.TargetLanguage}" />
<Button Grid.Column="1" Content="{Binding Strings.AddBsp}" Click="AddBspButton_Click" />
<Button Grid.Column="2" Content="{Binding Strings.ClearCompletedTasks}" Command="{Binding ClearCompletedItemsCommand}" />
<Button Grid.Column="3" Content="{Binding Strings.Clear}" Command="{Binding ClearAllItemsCommand}" />
Expand All @@ -35,7 +35,7 @@
<DataTemplate x:DataType="vm:TranslationItemViewModel">
<Grid ColumnDefinitions="4*,200,2*,2*" ColumnSpacing="8" MinHeight="30" Background="Transparent" HorizontalAlignment="Stretch">
<Grid.ContextMenu>
<ContextMenu x:CompileBindings="False">
<ContextMenu>
<MenuItem
Header="{Binding #Root.DataContext.Strings.RemoveTask}"
Command="{Binding #Root.DataContext.RemoveItemCommand}"
Expand Down Expand Up @@ -87,7 +87,7 @@

<TextBlock Grid.Row="2" Text="{Binding Strings.PromptFile}" FontWeight="SemiBold" />
<Grid Grid.Row="3" ColumnDefinitions="*,120" ColumnSpacing="8">
<TextBox Text="{Binding PromptFilePath}" Watermark="{Binding Strings.PromptFileWatermark}" />
<TextBox Text="{Binding PromptFilePath}" PlaceholderText="{Binding Strings.PromptFileWatermark}" />
<Button Grid.Column="1" Content="{Binding Strings.Browse}" Click="BrowsePromptButton_Click" />
</Grid>

Expand All @@ -106,23 +106,23 @@
TextWrapping="Wrap"
MinHeight="140"
VerticalContentAlignment="Top"
Watermark="{Binding Strings.PromptEditorWatermark}" />
PlaceholderText="{Binding Strings.PromptEditorWatermark}" />
</Grid>

<TextBlock Grid.Row="6" Text="{Binding Strings.Llm}" FontWeight="SemiBold" />
<Grid Grid.Row="7" ColumnDefinitions="160,*" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto" RowSpacing="8" ColumnSpacing="8">
<TextBlock Text="{Binding Strings.Model}" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Text="{Binding LlmModel}" Watermark="gpt-5.5" />
<TextBox Grid.Column="1" Text="{Binding LlmModel}" PlaceholderText="gpt-5.5" />
<TextBlock Grid.Row="1" Text="{Binding Strings.ApiKey}" VerticalAlignment="Center" />
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding LlmApiKey}" PasswordChar="*" />
<TextBlock Grid.Row="2" Text="{Binding Strings.BaseUrl}" VerticalAlignment="Center" />
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding LlmBaseUrl}" Watermark="https://api.openai.com/v1" />
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding LlmBaseUrl}" PlaceholderText="https://api.openai.com/v1" />
<TextBlock Grid.Row="3" Text="{Binding Strings.Temperature}" VerticalAlignment="Center" />
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding LlmTemperature}" Watermark="optional" />
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding LlmTemperature}" PlaceholderText="optional" />
<TextBlock Grid.Row="4" Text="{Binding Strings.ReasoningEffort}" VerticalAlignment="Center" />
<ComboBox Grid.Row="4" Grid.Column="1" ItemsSource="{Binding EffortOptions}" SelectedItem="{Binding LlmEffort}" />
<TextBlock Grid.Row="5" Text="{Binding Strings.FakeAs}" VerticalAlignment="Center" />
<TextBox Grid.Row="5" Grid.Column="1" Text="{Binding LlmFakeAs}" Watermark="codex" />
<TextBox Grid.Row="5" Grid.Column="1" Text="{Binding LlmFakeAs}" PlaceholderText="codex" />
</Grid>

<TextBlock Grid.Row="8" Text="{Binding Strings.Defaults}" FontWeight="SemiBold" />
Expand Down
4 changes: 3 additions & 1 deletion src/BSPLocalizationToolsCLI/BSPLocalizationToolsCLI.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<PublishAot>true</PublishAot>
<StripSymbols>true</StripSymbols>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions src/BSPLocalizationToolsCore/BSPLocalizationToolsCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand All @@ -10,6 +10,5 @@
<PackageReference Include="CsvHelper" Version="33.1.0" />
<PackageReference Include="DotNetEnv" Version="3.2.0" />
<PackageReference Include="Sledge.Formats.Bsp" Version="1.0.17" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>
</Project>
Loading
Loading