From 33c38d3595ec32634a507e102920d63313174fbe Mon Sep 17 00:00:00 2001 From: xiangyu <3170102889@zju.edu.cn> Date: Tue, 10 Jan 2023 20:20:48 +0800 Subject: [PATCH] fix: prefs table locale bug on Zotero 6 --- src/modules/preferenceScript.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/preferenceScript.ts b/src/modules/preferenceScript.ts index b35c5b8..021a1ea 100644 --- a/src/modules/preferenceScript.ts +++ b/src/modules/preferenceScript.ts @@ -47,15 +47,19 @@ async function updatePrefsUI() { const tableHelper = new ztoolkit.VirtualizedTabel(addon.data.prefs?.window!) .setContainerId(`${config.addonRef}-table-container`) // Add locale for table columns + // Object.fromEntries is only available on firefox 62+, .setLocale( - Object.fromEntries( + Array.from( new Map( addon.data.prefs?.columns.map((column) => [ column.label, getString(column.label), ]) ) - ) + ).reduce((obj, [key, value]) => { + obj[key] = value; + return obj; + }, {} as { [k: string]: string }) ) // id and getRowCount are required, others are optional. .setProp({