Read the old starter's key descriptions in code page 1250 too

Its language files are code page 1250 as often as UTF-8. Read as UTF-8 only,
Czech and Polish descriptions came out with replacement characters.
This commit is contained in:
maj00r
2026-11-03 21:51:55 +01:00
parent cf1ba319c1
commit 71c32c5b9a
2 changed files with 17 additions and 2 deletions

View File

@@ -190,6 +190,20 @@ public class LocalizationTests
Assert.Equal(string.Empty, loc.Opt("Cmd.z"));
}
[Fact]
public void An_old_starters_key_descriptions_are_read_in_its_own_code_page()
{
using var folders = new Folders();
File.WriteAllText(Path.Combine(folders.Bundled, "en.xml"), English);
File.WriteAllBytes(Path.Combine(folders.OldStarter, "lang-cz.txt"), LegacyText.CodePage1250.GetBytes(
"[labels]\r\n<eu07_input-keyboard.ini\r\nhornhighactivate=Houkačka výšková\r\n\r\n"));
var loc = folders.Service();
loc.Load("cz");
Assert.Equal("Houkačka výšková", loc.Opt("Cmd.hornhighactivate"));
}
[Fact]
public void Of_the_simulators_files_only_a_language_code_counts()
{

View File

@@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using StarterNG.Application.Abstractions;
using StarterNG.Infrastructure.Adapters;
namespace StarterNG.Services;
@@ -286,8 +286,9 @@ public class LocalizationService : INotifyPropertyChanged, ILocalizedStrings
if (path is null)
return;
// The old starter's own files are code page 1250 as often as UTF-8.
bool inDescriptions = false;
foreach (string line in File.ReadLines(path, Encoding.UTF8))
foreach (string line in LegacyText.Decode(File.ReadAllBytes(path)).ReplaceLineEndings("\n").Split('\n'))
{
if (line.Contains("<eu07_input-keyboard.ini", StringComparison.Ordinal))
{