fix(i18n): replace resx files atomically on import

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 16:48:49 +00:00
1 parent 8dec8fb969
commit 445b45a953
1 file changed
+4 -1
+4 -1
View File
@@ -209,7 +209,10 @@ internal sealed partial class I18nCommand : ICommand
foreach (var (key, value) in values)
sb.Append($" <data name=\"{Escape(key)}\" xml:space=\"preserve\"><value>{Escape(value)}</value></data>\n");
sb.Append("</root>\n");
File.WriteAllText(path, sb.ToString(), new UTF8Encoding(false));
// Atomic replace: other translators may be running `i18n check` over the same tree.
var temp = path + ".tmp";
File.WriteAllText(temp, sb.ToString(), new UTF8Encoding(false));
File.Move(temp, path, overwrite: true);
}
private static string Escape(string s) => s.Replace("&", "&amp;", StringComparison.Ordinal).Replace("<", "&lt;", StringComparison.Ordinal)