Keep SQUID settings usable with unknown metadata and preserve translations

This commit is contained in:
Дмитрий committed 2026-10-05 18:09:36 +05:00
1 parent f8301d7394
commit 654b7cddd3
6 files changed
+60 -16

No files matched your search

+7
View File
@@ -72,3 +72,10 @@ const upstream = squidSettingsView([{ key: "AiPlayerbot.FutureOption", value: "2
const future = upstream.settings[0];
if (future.title !== "Future option" || future.description !== "From the release JSON" || future.type !== "float" || future.min !== 0 || future.max !== 3 || future.advanced || future.category !== "squid.new-group" || upstream.categories.find(c=>c.id===future.category)?.title !== "New activity") throw new Error("New upstream JSON options must appear without handwritten definitions");
console.log("Upstream metadata: new fields, titles, ranges and arbitrary groups verified");
const localized = moduleField("AiPlayerbot.MaxRandomBots", "ru", { key:"AiPlayerbot.MaxRandomBots", type:"int", title:"Upstream English title", description:"Upstream English description", group:"population", min:10, max:1234 });
const original = moduleField("AiPlayerbot.MaxRandomBots", "ru");
if (localized.title !== original.title || localized.description !== original.description || localized.max !== 1234) throw new Error("Existing translations must survive upstream metadata while ranges stay current");
const localizedGroup = squidSettingsView([{key:"AiPlayerbot.MaxRandomBots",value:"100",default:"500",doc:"",field:{key:"AiPlayerbot.MaxRandomBots",type:"int",title:"English",description:"English",group:"population",group_title:"English population"}}],"ru");
if (localizedGroup.categories.find(c=>c.id==="squid.population")?.title !== "Население мира") throw new Error("Known groups must retain translated captions");
console.log("Existing setting/group translations retained with upstream English fallback");