fix: prefs table locale bug on Zotero 6

This commit is contained in:
xiangyu 2023-01-10 20:20:48 +08:00
parent 3ea8520d60
commit 33c38d3595

View File

@ -47,15 +47,19 @@ async function updatePrefsUI() {
const tableHelper = new ztoolkit.VirtualizedTabel(addon.data.prefs?.window!) const tableHelper = new ztoolkit.VirtualizedTabel(addon.data.prefs?.window!)
.setContainerId(`${config.addonRef}-table-container`) .setContainerId(`${config.addonRef}-table-container`)
// Add locale for table columns // Add locale for table columns
// Object.fromEntries is only available on firefox 62+,
.setLocale( .setLocale(
Object.fromEntries( Array.from(
new Map( new Map(
addon.data.prefs?.columns.map((column) => [ addon.data.prefs?.columns.map((column) => [
column.label, column.label,
getString(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. // id and getRowCount are required, others are optional.
.setProp({ .setProp({