mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-02 04:39:14 +01:00
Keep a language code the starter cannot display in eu07.ini
Matches the old starter: lower case, and an unknown code is left alone.
This commit is contained in:
@@ -70,6 +70,18 @@ public class SettingsStoreTests
|
|||||||
Assert.Contains("lang en", installation.Files.ReadAllText(UserIni));
|
Assert.Contains("lang en", installation.Files.ReadAllText(UserIni));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void The_language_code_is_written_in_lower_case()
|
||||||
|
{
|
||||||
|
var installation = WithHome();
|
||||||
|
installation.SettingsStore.Load();
|
||||||
|
installation.SettingsStore.Settings.LanguageCode = "ZH";
|
||||||
|
|
||||||
|
installation.SettingsStore.Save();
|
||||||
|
|
||||||
|
Assert.Contains("lang zh", installation.Files.ReadAllText(UserIni));
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void A_first_run_falls_back_to_the_ini_shipped_with_the_installation()
|
public void A_first_run_falls_back_to_the_ini_shipped_with_the_installation()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,7 +44,18 @@ public partial class App : Avalonia.Application
|
|||||||
};
|
};
|
||||||
AppServices.Current.Settings.Language = langName;
|
AppServices.Current.Settings.Language = langName;
|
||||||
|
|
||||||
|
// What eu07.ini asked for, before the starter picks a language it can
|
||||||
|
// actually display.
|
||||||
|
string requestedCode = AppServices.Current.Settings.LanguageCode;
|
||||||
|
|
||||||
ApplyLanguage(langName);
|
ApplyLanguage(langName);
|
||||||
|
|
||||||
|
// The starter ships no translation for this code, so its own interface
|
||||||
|
// falls back - but the simulator has one and keeps it. Overwriting the key
|
||||||
|
// here would silently move eu07.exe to English on the next save.
|
||||||
|
if (!string.IsNullOrWhiteSpace(requestedCode) &&
|
||||||
|
!string.Equals(requestedCode, Loc.CurrentLangCode, StringComparison.OrdinalIgnoreCase))
|
||||||
|
AppServices.Current.Settings.LanguageCode = requestedCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ApplyLanguage(string langNameOrCode)
|
public static void ApplyLanguage(string langNameOrCode)
|
||||||
|
|||||||
@@ -171,7 +171,10 @@ public sealed class SettingsSerializer
|
|||||||
foreach (string key in ObsoleteKeys)
|
foreach (string key in ObsoleteKeys)
|
||||||
c.Remove(key);
|
c.Remove(key);
|
||||||
|
|
||||||
c.Set("lang", string.IsNullOrWhiteSpace(s.LanguageCode) ? "en" : s.LanguageCode);
|
// Lower case, as the simulator expects and as the old starter wrote it.
|
||||||
|
c.Set("lang", string.IsNullOrWhiteSpace(s.LanguageCode)
|
||||||
|
? "en"
|
||||||
|
: s.LanguageCode.Trim().ToLowerInvariant());
|
||||||
c.SetBool("fullscreen", s.Fullscreen);
|
c.SetBool("fullscreen", s.Fullscreen);
|
||||||
c.SetBool("inactivepause", s.PauseWhenInactive);
|
c.SetBool("inactivepause", s.PauseWhenInactive);
|
||||||
c.SetBool("pause", s.PauseOnStart);
|
c.SetBool("pause", s.PauseOnStart);
|
||||||
|
|||||||
Reference in New Issue
Block a user