feat(i18n): seed en.json and wire locale copy to app output

This commit is contained in:
mika kuns
2026-06-03 11:41:51 +02:00
parent d95d55e6b8
commit 3c40bb5ea3
5 changed files with 60 additions and 0 deletions

View File

@@ -28,5 +28,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\ClaudeDo.Ui\ClaudeDo.Ui.csproj" /> <ProjectReference Include="..\ClaudeDo.Ui\ClaudeDo.Ui.csproj" />
<ProjectReference Include="..\ClaudeDo.Localization\ClaudeDo.Localization.csproj" />
</ItemGroup> </ItemGroup>
<Import Project="..\ClaudeDo.Localization\Locales.targets" />
</Project> </Project>

View File

@@ -7,4 +7,5 @@
<ItemGroup> <ItemGroup>
<InternalsVisibleTo Include="ClaudeDo.Localization.Tests" /> <InternalsVisibleTo Include="ClaudeDo.Localization.Tests" />
</ItemGroup> </ItemGroup>
<Import Project="Locales.targets" />
</Project> </Project>

View File

@@ -0,0 +1,7 @@
<Project>
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)locales\*.json"
Link="locales\%(Filename)%(Extension)"
CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,13 @@
{
"metadata": { "code": "en", "name": "English" },
"settings": {
"title": "SETTINGS",
"save": "Save",
"cancel": "Cancel",
"language": "Language",
"tabGeneral": "General",
"tabWorktrees": "Worktrees",
"tabFiles": "Files",
"tabPrime": "Prime Claude"
}
}

View File

@@ -0,0 +1,37 @@
using ClaudeDo.Localization;
namespace ClaudeDo.Localization.Tests;
public class EnJsonCoverageTests
{
private static string LocalesDir()
{
var dir = AppContext.BaseDirectory;
while (dir is not null)
{
var candidate = Path.Combine(dir, "src", "ClaudeDo.Localization", "locales");
if (Directory.Exists(candidate)) return candidate;
dir = Path.GetDirectoryName(dir);
}
throw new DirectoryNotFoundException("Could not locate src/ClaudeDo.Localization/locales");
}
[Fact]
public void Every_locale_has_same_keys_as_english()
{
var store = LocaleStore.Load(LocalesDir());
Assert.True(store.TryGet("en", out var en));
var enKeys = en!.Strings.Keys.ToHashSet();
foreach (var locale in store.Available)
{
var keys = locale.Strings.Keys.ToHashSet();
var missing = enKeys.Except(keys).OrderBy(k => k).ToList();
var extra = keys.Except(enKeys).OrderBy(k => k).ToList();
Assert.True(missing.Count == 0,
$"Locale '{locale.Code}' missing keys: {string.Join(", ", missing)}");
Assert.True(extra.Count == 0,
$"Locale '{locale.Code}' has extra keys not in en.json: {string.Join(", ", extra)}");
}
}
}