i18n: the five spots the smoke test found, and a BOM in the export
Reported from a real pass through the window. The theme categories were a static readonly array, so the five names froze at whatever language the plugin started in and a runtime switch relabelled the entire window except them. Same shape as the layout labels earlier in this cycle; this one got missed because replacing the literals with resource lookups looks finished until you actually switch. The status bar built its counts from English literals -- tab, tabs, msg, tell, tells -- and the privacy pill said "Privacy-First" in all 25 files. The thousands separator follows the user's culture now too, so German reads 1,2k rather than 1.2k. The live preview claims to show what the window will look like. It was showing English channel names next to a translated placeholder, which is worse than either. Channel labels come from ChatType.Name() now and the status slots share the strings with the real status bar. The four mock chat lines stay English on the earlier decision. And the export wrote a byte order mark. Encoding.UTF8 emits one, and a leading U+FEFF makes the JSON invalid for every strict parser -- confirmed against a real export from the game, where python's json.load refused the file. CSV keeps its BOM, because without one Excel guesses the codepage and mangles every non-ASCII name. The self-test that was supposed to catch that read the file with File.ReadAllText, which strips a BOM while detecting the encoding. It reads bytes now. The status bar tests asserted English literals and started failing on a German machine -- they pin a fixed culture now instead of inheriting the locale of whoever runs them.
This commit is contained in:
@@ -49,6 +49,8 @@ internal static class ExportFormatExt
|
||||
// substring is applied here.
|
||||
internal static class MessageExporter
|
||||
{
|
||||
private static readonly UTF8Encoding Utf8NoBom = new(encoderShouldEmitUTF8Identifier: false);
|
||||
|
||||
internal record FilterDescription(
|
||||
IReadOnlyCollection<int>? ChatTypes,
|
||||
DateTimeOffset? From,
|
||||
@@ -82,7 +84,14 @@ internal static class MessageExporter
|
||||
int written;
|
||||
try
|
||||
{
|
||||
using (var writer = new StreamWriter(temp, append: false, encoding: Encoding.UTF8))
|
||||
// Encoding.UTF8 writes a byte order mark, and that is not a
|
||||
// cosmetic detail here: a leading U+FEFF makes the JSON invalid for
|
||||
// every strict parser, Python's json.load included. CSV is the one
|
||||
// format that wants it -- without a BOM Excel guesses the codepage
|
||||
// and mangles every non-ASCII name in the file.
|
||||
var encoding = format == ExportFormat.Csv ? Encoding.UTF8 : Utf8NoBom;
|
||||
|
||||
using (var writer = new StreamWriter(temp, append: false, encoding))
|
||||
{
|
||||
written = format switch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user