| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b920092 commit 0e54a80
11 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -166,7 +166,7 @@ private static string Unescape(string text) | |||
| 166 | 166 | /// Parses strings.en.json, appends the missing entries, sorts everything | |
| 167 | 167 | /// case-insensitively by key, and rewrites the file. | |
| 168 | 168 | /// 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). | ||
| 170 | 170 | /// </summary> | |
| 171 | 171 | private static void AppendMissingEntries(string filePath, Dictionary<string, string> missingEntries) | |
| 172 | 172 | { | |
@@ -182,7 +182,7 @@ private static void AppendMissingEntries(string filePath, Dictionary<string, str | |||
| 182 | 182 | foreach (var kvp in existingEntries) sorted[kvp.Key] = kvp.Value; | |
| 183 | 183 | ||
| 184 | 184 | var json = JsonSerializer.Serialize(sorted, JsonOptions); | |
| 185 | - File.WriteAllText(filePath, json, new UTF8Encoding(true)); | ||
| 185 | + File.WriteAllText(filePath, json + Environment.NewLine, new UTF8Encoding(false)); | ||
| 186 | 186 | } | |
| 187 | 187 | ||
| 188 | 188 | private static Dictionary<string, string> LoadKeys(string filePath) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,7 +76,7 @@ SimpleLauncher.ResourceTranslator/ | |||
| 76 | 76 | ├── JsonResourceAnalyzer.cs # Reads English JSON keys and diffs other JSON languages | |
| 77 | 77 | ├── OpenRouterTranslationService.cs # HTTP client for OpenRouter API batch translation | |
| 78 | 78 | ├── 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) | ||
| 80 | 80 | ``` | |
| 81 | 81 | ||
| 82 | 82 | ## Configuration | |
@@ -98,4 +98,4 @@ The LLM receives each batch as a flat list of `Key|Value` lines and must answer | |||
| 98 | 98 | - 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. | |
| 99 | 99 | - The app is safe to run multiple times; it only processes keys that are actually missing. | |
| 100 | 100 | - 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. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,9 +45,9 @@ public static void UpdateResourceFile( | |||
| 45 | 45 | foreach (var kvp in newTranslations) | |
| 46 | 46 | existingEntries[kvp.Key] = kvp.Value; | |
| 47 | 47 | ||
| 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); | ||
| 51 | 51 | File.WriteAllText(filePath, output, encoding); | |
| 52 | 52 | } | |
| 53 | 53 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,7 +70,7 @@ public static void UpdateResourceFile( | |||
| 70 | 70 | ||
| 71 | 71 | sb.AppendLine("</ResourceDictionary>"); | |
| 72 | 72 | ||
| 73 | - var encoding = new UTF8Encoding(true); | ||
| 73 | + var encoding = new UTF8Encoding(false); | ||
| 74 | 74 | File.WriteAllText(filePath, sb.ToString(), encoding); | |
| 75 | 75 | } | |
| 76 | 76 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,7 +69,7 @@ public void AllResourceFilesShouldBeSortedAlphabeticallyByKey() | |||
| 69 | 69 | .ToList(); | |
| 70 | 70 | var footer = new List<string> { "</ResourceDictionary>" }; | |
| 71 | 71 | ||
| 72 | - var encoding = new UTF8Encoding(true); | ||
| 72 | + var encoding = new UTF8Encoding(false); | ||
| 73 | 73 | File.WriteAllLines(file, header.Concat(sortedEntries).Concat(footer), encoding); | |
| 74 | 74 | } | |
| 75 | 75 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -122,7 +122,7 @@ public void AllResourceFilesShouldHaveNoDuplicateKeys() | |||
| 122 | 122 | ||
| 123 | 123 | lines.Add("</ResourceDictionary>"); | |
| 124 | 124 | ||
| 125 | - var encoding = new UTF8Encoding(true); | ||
| 125 | + var encoding = new UTF8Encoding(false); | ||
| 126 | 126 | File.WriteAllLines(file, lines, encoding); | |
| 127 | 127 | } | |
| 128 | 128 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -96,7 +96,7 @@ public void AllResourceFilesShouldHaveNoEmptyValuesAndAutoRemove() | |||
| 96 | 96 | ||
| 97 | 97 | lines.Add("</ResourceDictionary>"); | |
| 98 | 98 | ||
| 99 | - var encoding = new UTF8Encoding(true); | ||
| 99 | + var encoding = new UTF8Encoding(false); | ||
| 100 | 100 | File.WriteAllLines(file, lines, encoding); | |
| 101 | 101 | } | |
| 102 | 102 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -297,7 +297,7 @@ private static void AppendMissingEntries(string filePath, Dictionary<string, str | |||
| 297 | 297 | lines.Add("</ResourceDictionary>"); | |
| 298 | 298 | ||
| 299 | 299 | // Write the file with proper encoding. | |
| 300 | - var encoding = new UTF8Encoding(true); | ||
| 300 | + var encoding = new UTF8Encoding(false); | ||
| 301 | 301 | File.WriteAllLines(filePath, lines, encoding); | |
| 302 | 302 | } | |
| 303 | 303 | ||
@@ -343,7 +343,7 @@ private static void WriteXamlFile(XDocument doc, string filePath) | |||
| 343 | 343 | lines.Add("</ResourceDictionary>"); | |
| 344 | 344 | ||
| 345 | 345 | // Write the file with proper encoding. | |
| 346 | - var encoding = new UTF8Encoding(true); | ||
| 346 | + var encoding = new UTF8Encoding(false); | ||
| 347 | 347 | File.WriteAllLines(filePath, lines, encoding); | |
| 348 | 348 | } | |
| 349 | 349 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -167,7 +167,7 @@ private static void AppendMissingEntries(string filePath, Dictionary<string, str | |||
| 167 | 167 | .ToList(); | |
| 168 | 168 | var footer = new List<string> { "</ResourceDictionary>" }; | |
| 169 | 169 | ||
| 170 | - var encoding = new UTF8Encoding(true); | ||
| 170 | + var encoding = new UTF8Encoding(false); | ||
| 171 | 171 | File.WriteAllLines(filePath, header.Concat(sortedEntries).Concat(footer), encoding); | |
| 172 | 172 | } | |
| 173 | 173 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,7 +43,7 @@ Three code projects implement it: | |||
| 43 | 43 | ||
| 44 | 44 | 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). | |
| 45 | 45 | ||
| 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). | ||
| 47 | 47 | ||
| 48 | 48 | ## Version & license | |
| 49 | 49 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments