Files
DeepTutor/web/scripts/compact-locale-loader.cjs
Bingxi Zhao (Frank) da856ad670 release: v1.6.9
Ship folder-based workspaces and data migration, daily practice, redesigned
provider and model settings, and streaming conversation improvements.
Synchronize README translations and document the archive/permanent-delete
upgrade behavior in assets/releases/ver1-6-9.md.

Reduce initial JavaScript by deduplicating English resources and loading
animation features after hydration. Keep the existing route size budgets.
Update regression fixtures and browser audits for scoped URLs and the new
settings and learning interfaces.
2026-09-21 02:30:40 +08:00

17 lines
667 B
JavaScript

// English uses the displayed copy as most translation keys. Store those
// strings once in the bundle, while keeping the authored JSON and the runtime
// resource dictionary unchanged (including explicit translations).
module.exports = function compactLocaleLoader(source) {
this.cacheable?.();
const identities = [];
const translations = [];
for (const [key, value] of Object.entries(JSON.parse(source))) {
if (key === value) identities.push(key);
else translations.push([key, value]);
}
return `module.exports = Object.fromEntries([
...${JSON.stringify(identities)}.map(key => [key, key]),
...${JSON.stringify(translations)}
]);`;
};