FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore: write resource files without a BOM to match the repo format · purelogiccode/SimpleLauncher@0e54a80 · GitHub

Commit 0e54a80

Browse files
chore: write resource files without a BOM to match the repo format
1 parent b920092 commit 0e54a80

11 files changed

Lines changed: 17 additions & 17 deletions

‎SimpleLauncher.Avalonia.Tests/DetectMissingResourceStringsTests.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private static string Unescape(string text)
166166
/// Parses strings.en.json, appends the missing entries, sorts everything
167167
/// case-insensitively by key, and rewrites the file.
168168
/// Mirrors the output format of the SimpleLauncher.ResourceTranslator JSON writer
169-
/// (2-space indented, UTF-8 with BOM, OrdinalIgnoreCase sort).
169+
/// (2-space indented, UTF-8 without BOM, OrdinalIgnoreCase sort).
170170
/// </summary>
171171
private static void AppendMissingEntries(string filePath, Dictionary<string, string> missingEntries)
172172
{
@@ -182,7 +182,7 @@ private static void AppendMissingEntries(string filePath, Dictionary<string, str
182182
foreach (var kvp in existingEntries) sorted[kvp.Key] = kvp.Value;
183183

184184
var json = JsonSerializer.Serialize(sorted, JsonOptions);
185-
File.WriteAllText(filePath, json, new UTF8Encoding(true));
185+
File.WriteAllText(filePath, json + Environment.NewLine, new UTF8Encoding(false));
186186
}
187187

188188
private static Dictionary<string, string> LoadKeys(string filePath)

‎SimpleLauncher.ResourceTranslator/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ SimpleLauncher.ResourceTranslator/
7676
├── JsonResourceAnalyzer.cs # Reads English JSON keys and diffs other JSON languages
7777
├── OpenRouterTranslationService.cs # HTTP client for OpenRouter API batch translation
7878
├── XamlResourceWriter.cs # Writes updated XAML, removes duplicates, sorts keys
79-
└── JsonResourceWriter.cs # Writes updated JSON (UTF-8 BOM, 2-space indent, readable)
79+
└── JsonResourceWriter.cs # Writes updated JSON (UTF-8 without BOM, 2-space indent, readable)
8080
```
8181

8282
## Configuration
@@ -98,4 +98,4 @@ The LLM receives each batch as a flat list of `Key|Value` lines and must answer
9898
- If a translation batch fails (network error, rate limit, etc.), the app **skips that batch** and does not add empty strings to the resource file. Run the app again later to retry.
9999
- The app is safe to run multiple times; it only processes keys that are actually missing.
100100
- Empty English values are intentionally preserved as empty entries so translators can fill them in later.
101-
- JSON files are written with a UTF-8 BOM, 2-space indentation and `StringComparer.OrdinalIgnoreCase` key order — matching what the Avalonia tests expect.
101+
- JSON files are written as UTF-8 without a BOM, with 2-space indentation and `StringComparer.OrdinalIgnoreCase` key order — matching the committed Avalonia resource files.

‎SimpleLauncher.ResourceTranslator/Services/JsonResourceWriter.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public static void UpdateResourceFile(
4545
foreach (var kvp in newTranslations)
4646
existingEntries[kvp.Key] = kvp.Value;
4747

48-
// Write back as UTF-8 with BOM
49-
var output = JsonSerializer.Serialize(existingEntries, JsonOptions);
50-
var encoding = new UTF8Encoding(true);
48+
// Write back as UTF-8 without BOM, matching the committed resource files.
49+
var output = JsonSerializer.Serialize(existingEntries, JsonOptions) + Environment.NewLine;
50+
var encoding = new UTF8Encoding(false);
5151
File.WriteAllText(filePath, output, encoding);
5252
}
5353
}

‎SimpleLauncher.ResourceTranslator/Services/XamlResourceWriter.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static void UpdateResourceFile(
7070

7171
sb.AppendLine("</ResourceDictionary>");
7272

73-
var encoding = new UTF8Encoding(true);
73+
var encoding = new UTF8Encoding(false);
7474
File.WriteAllText(filePath, sb.ToString(), encoding);
7575
}
7676
}

‎SimpleLauncher.Tests/DetectAlphabeticalOrderingTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void AllResourceFilesShouldBeSortedAlphabeticallyByKey()
6969
.ToList();
7070
var footer = new List<string> { "</ResourceDictionary>" };
7171

72-
var encoding = new UTF8Encoding(true);
72+
var encoding = new UTF8Encoding(false);
7373
File.WriteAllLines(file, header.Concat(sortedEntries).Concat(footer), encoding);
7474
}
7575
}

‎SimpleLauncher.Tests/DetectDuplicateResourceKeysTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void AllResourceFilesShouldHaveNoDuplicateKeys()
122122

123123
lines.Add("</ResourceDictionary>");
124124

125-
var encoding = new UTF8Encoding(true);
125+
var encoding = new UTF8Encoding(false);
126126
File.WriteAllLines(file, lines, encoding);
127127
}
128128
}

‎SimpleLauncher.Tests/DetectEmptyResourceValuesAndAutoRemoveTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void AllResourceFilesShouldHaveNoEmptyValuesAndAutoRemove()
9696

9797
lines.Add("</ResourceDictionary>");
9898

99-
var encoding = new UTF8Encoding(true);
99+
var encoding = new UTF8Encoding(false);
100100
File.WriteAllLines(file, lines, encoding);
101101
}
102102
}

‎SimpleLauncher.Tests/DetectMissingResourceProviderKeysTests.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ private static void AppendMissingEntries(string filePath, Dictionary<string, str
297297
lines.Add("</ResourceDictionary>");
298298

299299
// Write the file with proper encoding.
300-
var encoding = new UTF8Encoding(true);
300+
var encoding = new UTF8Encoding(false);
301301
File.WriteAllLines(filePath, lines, encoding);
302302
}
303303

@@ -343,7 +343,7 @@ private static void WriteXamlFile(XDocument doc, string filePath)
343343
lines.Add("</ResourceDictionary>");
344344

345345
// Write the file with proper encoding.
346-
var encoding = new UTF8Encoding(true);
346+
var encoding = new UTF8Encoding(false);
347347
File.WriteAllLines(filePath, lines, encoding);
348348
}
349349

‎SimpleLauncher.Tests/DetectMissingResourceStringsTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private static void AppendMissingEntries(string filePath, Dictionary<string, str
167167
.ToList();
168168
var footer = new List<string> { "</ResourceDictionary>" };
169169

170-
var encoding = new UTF8Encoding(true);
170+
var encoding = new UTF8Encoding(false);
171171
File.WriteAllLines(filePath, header.Concat(sortedEntries).Concat(footer), encoding);
172172
}
173173

‎docs/01-overview.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Three code projects implement it:
4343

4444
18 languages are shipped as WPF resource dictionaries: `SimpleLauncher\resources\strings.{code}.xaml`. Switching language restarts the app (`App.ChangeLanguage`). See [08 — UI Layer](08-ui-layer.md#themes--language).
4545

46-
The Avalonia port ships the same 18 languages as JSON resources: `SimpleLauncher.Avalonia\Resources\strings.{code}.json` (2661 keys per file, UTF-8 with BOM, key-sorted). `SimpleLauncher.ResourceTranslator` (OpenRouter API, default `z-ai/glm-5.3-flash`) propagates missing keys from `strings.en.{xaml,json}` to all other languages; see its [README](../SimpleLauncher.ResourceTranslator/README.md).
46+
The Avalonia port ships the same 18 languages as JSON resources: `SimpleLauncher.Avalonia\Resources\strings.{code}.json` (2669 keys per file, UTF-8 without BOM, key-sorted). `SimpleLauncher.ResourceTranslator` (OpenRouter API, default `z-ai/glm-5.3-flash`) propagates missing keys from `strings.en.{xaml,json}` to all other languages; see its [README](../SimpleLauncher.ResourceTranslator/README.md).
4747

4848
## Version & license
4949

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL