Skip to content

Commit

Permalink
local: 更新中文和英文,设置界面,弹窗信息等. fixed #187
Browse files Browse the repository at this point in the history
  • Loading branch information
l0o0 committed Aug 12, 2023
1 parent 28e0dde commit fa4c501
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 73 deletions.
9 changes: 0 additions & 9 deletions addon/chrome/content/preferences.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@
</menupopup>
</menulist>
</hbox>

<hbox>
<label class='jasminum-label' data-l10n-id="cnkicite-label" />
<menulist editable="true" id="jasminum.citefield" preference="extensions.zotero.jasminum.citefield" native="true">
<menupopup>
<menuitem data-l10n-id="cnkicite-field-extra" value="extra" />
</menupopup>
</menulist>
</hbox>
</groupbox>
<groupbox>
<label>
Expand Down
41 changes: 30 additions & 11 deletions addon/locale/en-US/addon.ftl
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
startup-begin = Addon is loading
startup-finish = Addon is ready
menuitem-label = Addon Template: Helper Examples
menupopup-label = Addon Template: Menupopup
menuitem-submenulabel = Addon Template
menuitem-filemenulabel = Addon Template: File Menuitem
prefs-title = Template
prefs-table-title = Title
prefs-table-detail = Detail
tabpanel-lib-tab-label = Lib Tab
tabpanel-reader-tab-label = Reader Tab
prefs-title = Jasminum
pdftk-picker-header = Select pdftk execute file
translator-download = translator downloaded
translator-updated = translator updated
menu-CNKI-label = CNKI
menu-CNKI-update-label = CNKI metadata
menu-CNKI-updateCiteCSSCI-label = CNKI Cite&CSSCI
menu-CNKI-attachment-label = Find attachments
menu-CNKI-addBookmark-label = Add bookmark
menu-tools-label = Tools
menu-tools-namesplit-label = Split name
menu-tools-namemerge-label = Concat name
menu-tools-semicolonNamesSplit-label = Splie Name by semicolon
menu-tools-removeDot-label = Remove comma in filename
menu-tools-bacthsetlanguage-label = Auto:Language detect
menu-tools-manualsetlanguage-label = Manual:Language detect
menu-tools-dateformatter-label = Format datetime
# customed fields
cnkicite-field-label = Cite(CNKI)
cssci-field-label = Type(Journal)
# popup
cnkimetadata-success = CNKI metadata success
cnkimetadata-fail = CNKI metadata fail, Author: { $author } ,Title: { $title }
cnki-capatch-warning = Found capatch in CNKI webpage
filename-parse-fail = Filename parsing error. Please check the filename and patent., filename: { $filename },filename patent: { $patent }
reference-trans-fail = No data found in CNKI reference result
unmatched-itemtype-fail = { $itemType } item is not a target item
nonchinese-item = Not a Chinese item
cssci-success = { $title }, Citations: { $cite }, Journal type: { $cssci }
url-missing = Missing URL
79 changes: 75 additions & 4 deletions addon/locale/en-US/preferences.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,75 @@
pref-title = Addon Template Example
pref-enable =
.label = Enable
pref-help = { $name } Build { $version } { $time }
addon-info = { $name } Version { $version } Build at { $time }
pdftkpath-label =
.label = PDFtk Service install path
autoupdate-label =
.label = Update CNKI metadata when add Chinese PDF/CAJ item
autolanguage-label =
.label = Auto set language:
autolanguagefunc-label =
.label = Language detecy by:
autolanguage-auto =
.label = Auto
autolanguage-manual =
.label = Manual
tools = Tools
translators-caption = Chinese Translators
check = Check
chinese-caption = CNKI settings
namepatent-caption = Filename patent
attachment-caption = Attachment settings
attachment-type-info = Attachment file type
attachment-cookie-info = Update CNKI cookies
toolbox-caption = Tools settings
toolbox-ennamesplit-label =
.label = Split/Concat foreign names
# toolbox-bacthsetlanguage-info = 智能识别语言(用','隔开)
# toolbox-bacthsetlanguage-desc =
# .tooltiptext = 智能识别语言基于nlp-js,通过识别标题文字来填充语言栏。该功能由算法自动识别,不能保证完全正确。设置常用语言,可以提高该语言出现的优先级,填写内容需遵循ISO 639‑1标准。识别结果不会局限于所填写的语言类别,输入框为空表示不做任何限制。'设置默认语言',仅对选中项目设置一种语言,该语言为 '默认中文语言' 的值。
toolbox-manualsetlanguage-info = Manual set language
toolbox-manualsetlanguage-desc =
.tooltiptext = Set language field with this value
toolbox-dateformatter-info = Datetime format
toolbox-dateformatter-iso = Year-Month-Day
toolbox-dateformatter-short = Day/Month/Year
toolbox-dateformatter-shortreverse = Year/Month/Day
toolbox-dateformatter-yearonly = Year Only(Can not revert to previous value)
toolbox-dateformatterfill =
.label = Padded with 0
open-cnki = Open CNKI
get-cookie = Click to update CNKI cookies
cookie-endtime = Cookies expire before: =
pdftk-caption = PDFtk Server Settings
choose = Choose
pdftk-info = The bookmark adding feature requires the correct installation of PDFtk server. Please selecte correct installation folder
pdftk-path-check-ok =
.tooltiptext = PDFtk Server install folder found
pdftk-path-check-error =
.tooltiptext = pdftk execute file not found
namepatent-desc =
.tooltiptext = Extracting CNKI metadata based on the filename,name patent format:{"{"}%t{"}"}=title,{"{"}%g{"}"}=author,{"{"}%y{"}"}=year,{"{"}%j{"}"}=other information(the information listed above);The delimiter is specified according to the actual situation and can be used continuously with multiple instances. Ignore file extension。Default is {"{"}%t{"}"}_{"{"}%g{"}"} and cover the majority of cases,including cases where the filename only consists of the title without any delimiter symbols.
namepatent-desc-tg =
.label = {"{"}%t{"}"}_{"{"}%g{"}"}
.tooltiptext =「title_author」patent,see「无人机多余度航空电子系统设计与应用_杨璐.caj」
namepatent-desc-t =
.label = {"{"}%t{"}"}
.tooltiptext =「title」patent,see「无人机多余度航空电子系统设计与应用.caj」
namepatent-desc-info = Select or input name patent:
zhnamesplit-label =
.label = Split name when Chinese item added
rename-label =
.label = Rename attahcment filename after retrive CNKI metadata(require Zotfile)
autobookmark-label =
.label = Add bookmark after CNKI thesis item added
# zhnamedot-label = 当拉取知网元数据时去除 Zotfile 重命名文件名中的逗号(, )
# translator-notiice = 点击下方刷新按钮更新数据,在刷新窗口中点击对应转换器的Update按键进行下载
translator-tab-column1 = Name
translator-tab-column2 = Local updatetime
translator-tab-column3 = Latest updatetime
translator-tab-column4 = Download
refresh-label = Update
updateall-label = Update all
refreshInfo-label = Update translators_CN data
# update-translator = 更新之后还需要在浏览器Zotero Connector中更新转换器信息
about = About
# about-desc = 首先非常感谢各位使用茉莉花插件🌹因能力和时间限制,难免会有一些不足。如果使用中遇到一些问题或者建议,欢迎发送反馈到邮箱:linxzh1989@gmail-com。最后也欢迎大家加入 Zotero中文插件 QQ群 1群 913637964, 2群 617148016, 3群 962963257, 4群 893963769一起学习交流。
25 changes: 14 additions & 11 deletions addon/locale/zh-CN/addon.ftl
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
startup-begin = 插件加载中
startup-finish = 插件已就绪
menuitem-label = 插件模板: 帮助工具样例
menupopup-label = 插件模板: 弹出菜单
menuitem-submenulabel = 插件模板:子菜单
menuitem-filemenulabel = 插件模板: 文件菜单
prefs-title = 茉莉花
prefs-table-title = 标题
prefs-table-detail = 详情
tabpanel-lib-tab-label = 库标签
tabpanel-reader-tab-label = 阅读器标签
pdftk-picker-header = 选择pdftk可执行文件
translator-download = 该转换器可下载
translator-updated = 该转换器已更新
Expand All @@ -24,4 +14,17 @@ menu-tools-semicolonNamesSplit-label = 从分号拆分名字
menu-tools-removeDot-label = 去除文件名中逗号
menu-tools-bacthsetlanguage-label = Auto:智能识别语言
menu-tools-manualsetlanguage-label = Manual:手动设置语言
menu-tools-dateformatter-label = 统一日期格式
menu-tools-dateformatter-label = 统一日期格式
# 自定义栏
cnkicite-field-label = 知网引用数
cssci-field-label = 期刊等级
# 弹窗信息
cnkimetadata-success = 抓取知网元数据成功
cnkimetadata-fail = 抓取知网元数据失败, 作者: { $author } ,标题: { $title }
cnki-capatch-warning = 知网网页出现验证码
filename-parse-fail = 文件名识别出错,请检查文件名识别模板与实际抓取文件名。文件名: { $filename },识别模板为: { $patent }
reference-trans-fail = 知网引文导出结果中未发现可用信息
unmatched-itemtype-fail = { $itemType } 类型条目不需要抓取
nonchinese-item = 非中文条目
cssci-success = { $title }, 引用数: { $cite }, 期刊类型: { $cssci }
url-missing = 缺失条目 URL 信息
31 changes: 8 additions & 23 deletions addon/locale/zh-CN/preferences.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addon-info = { $name } 版本 { $version } Build { $time }
addon-info = { $name } 版本 { $version } 创建于 { $time }
pdftkpath-label =
.label = PDFtk Service 安装路径
Expand All @@ -12,10 +12,6 @@ autolanguage-auto =
.label = 自动
autolanguage-manual =
.label = 手动
cnkicite-label = 知网引用数存放字段(英文名):
cnkicite-field-extra =
.label = 其他
chinese = 中文插件设置
tools = 小工具
translators-caption = 非官方维护中文转换器
check = 检查
Expand All @@ -27,9 +23,9 @@ attachment-cookie-info = 获取知网用户数据
toolbox-caption = 小工具设置
toolbox-ennamesplit-label =
.label = 拆分/合并英文名
toolbox-bacthsetlanguage-info = 智能识别语言(用','隔开)
toolbox-bacthsetlanguage-desc =
.tooltiptext = 智能识别语言基于nlp-js,通过识别标题文字来填充语言栏。该功能由算法自动识别,不能保证完全正确。设置常用语言,可以提高该语言出现的优先级,填写内容需遵循ISO 639‑1标准。识别结果不会局限于所填写的语言类别,输入框为空表示不做任何限制。'设置默认语言',仅对选中项目设置一种语言,该语言为 '默认中文语言' 的值。
# toolbox-bacthsetlanguage-info = 智能识别语言(用','隔开)
# toolbox-bacthsetlanguage-desc =
# .tooltiptext = 智能识别语言基于nlp-js,通过识别标题文字来填充语言栏。该功能由算法自动识别,不能保证完全正确。设置常用语言,可以提高该语言出现的优先级,填写内容需遵循ISO 639‑1标准。识别结果不会局限于所填写的语言类别,输入框为空表示不做任何限制。'设置默认语言',仅对选中项目设置一种语言,该语言为 '默认中文语言' 的值。
toolbox-manualsetlanguage-info = 手动设置语言
toolbox-manualsetlanguage-desc =
.tooltiptext = 使用设置的语言信息填充条目的语言栏
Expand All @@ -45,7 +41,6 @@ get-cookie = 点击获取用户信息
cookie-endtime = 用户信息失效时间: =
pdftk-caption = PDFtk Server 路径设置
choose = 选择
jasminum = 茉莉花
pdftk-info = 添加书签功能依赖于PDFtk server,正确安装并设置好安装目录才能实现书签添加功能,请选择PDFtk可执行文件所在目录
pdftk-path-check-ok =
.tooltiptext = PDFtk Server安装目录检查通过
Expand All @@ -66,25 +61,15 @@ rename-label =
.label = 拉取知网元数据后调用Zotfile重命名附件(需安装Zotfile)
autobookmark-label =
.label = 从知网添加学位论文时自动添加书签
zhnamedot-label = 当拉取知网元数据时去除 Zotfile 重命名文件名中的逗号(, )
translator-notiice = 点击下方刷新按钮更新数据,在刷新窗口中点击对应转换器的Update按键进行下载
# zhnamedot-label = 当拉取知网元数据时去除 Zotfile 重命名文件名中的逗号(, )
# translator-notiice = 点击下方刷新按钮更新数据,在刷新窗口中点击对应转换器的Update按键进行下载
translator-tab-column1 = 名称
translator-tab-column2 = 本地更新时间
translator-tab-column3 = 最新更新时间
translator-tab-column4 = 操作
refresh-label = 刷新
updateall-label = 更新全部
updateT-label = 更新
refreshInfo-label = 获取TranslatorCN更新信息
updateallInfo-label = 更新全部TranslatorsCN(慎点)
update-translator = 更新之后还需要在浏览器Zotero Connector中更新转换器信息
init-label = 获取更新信息
initInfo-label = 从Translators CN 中获取转换器信息
# update-translator = 更新之后还需要在浏览器Zotero Connector中更新转换器信息
about = 关于
about-desc = 首先非常感谢各位使用茉莉花插件🌹因能力和时间限制,难免会有一些不足。如果使用中遇到一些问题或者建议,欢迎发送反馈到邮箱:linxzh1989@gmail-com。最后也欢迎大家加入 Zotero中文插件 QQ群 1群 913637964, 2群 617148016, 3群 962963257, 4群 893963769一起学习交流。
jasminun-tutorial = Jasminum 的详细使用说明,可以参考
han-tutorial = 韩敏义老师制作的操作说明
# Popup messager
cnkimetadata-success = 抓取知网元数据成功
cnkimetadata-fail = 抓取知网元数据失败, 作者: { $author } ,标题: { $title }
# about-desc = 首先非常感谢各位使用茉莉花插件🌹因能力和时间限制,难免会有一些不足。如果使用中遇到一些问题或者建议,欢迎发送反馈到邮箱:linxzh1989@gmail-com。最后也欢迎大家加入 Zotero中文插件 QQ群 1群 913637964, 2群 617148016, 3群 962963257, 4群 893963769一起学习交流。
1 change: 0 additions & 1 deletion addon/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pref("__prefsPrefix__.autobookmark", true);
pref("__prefsPrefix__.autolanguage", true);
pref("__prefsPrefix__.autolanguagefunc", "Auto");
pref("__prefsPrefix__.autoupdate", false);
pref("__prefsPrefix__.citefield", "extra");
pref("__prefsPrefix__.completelanguage", true);
pref("__prefsPrefix__.dateformatter", "ISO");
pref("__prefsPrefix__.dateformatterfill", "false");
Expand Down
18 changes: 9 additions & 9 deletions src/modules/bookmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function checkPDFtkPath() {
pdftk = OS.Path.join(pdftkpath, "pdftk");
}
ztoolkit.log(pdftk);
var fileExist = await OS.File.exists(pdftk);
const fileExist = await OS.File.exists(pdftk);
return fileExist;
}

Expand Down Expand Up @@ -53,9 +53,9 @@ async function getChapterText(
"div.main-content > div.list-main > ul.ls-chapters > li"
);
ztoolkit.log(rows.length);
let rows_array = [];
const rows_array = [];
let note = "";
for (let row of rows) {
for (const row of rows) {
ztoolkit.log(row.textContent!.trim());
const level =
parseInt(row.getAttribute("class")?.split("-")[1] as string) + 1; // Source level from 0
Expand Down Expand Up @@ -88,7 +88,7 @@ async function addBookmark(item: Zotero.Item, bookmark: string) {
// PDFtk will throw errors when args contains Chinese character
// So create a tmp folder.
if (Zotero.isWin) {
var newTmp = OS.Path.join(cacheFile.path.slice(0, 3), "tmp");
const newTmp = OS.Path.join(cacheFile.path.slice(0, 3), "tmp");
Zotero.debug("** Jasminum new tmp path " + newTmp);
cacheFile = Zotero.getTempDirectory();
cachePDF = Zotero.getTempDirectory();
Expand All @@ -108,19 +108,19 @@ async function addBookmark(item: Zotero.Item, bookmark: string) {
cachePDF.remove(false);
}

let encoder = new TextEncoder();
let array = encoder.encode(bookmark);
const encoder = new TextEncoder();
const array = encoder.encode(bookmark);
await OS.File.writeAtomic(cacheFile.path, array, {
tmpPath: cacheFile.path + ".tmp",
});
var pdftk = Zotero.Prefs.get("jasminum.pdftkpath") as string;
let pdftk = Zotero.Prefs.get("jasminum.pdftkpath") as string;
if (Zotero.isWin) {
pdftk = OS.Path.join(pdftk, "pdftk.exe");
} else {
pdftk = OS.Path.join(pdftk, "pdftk");
}
Zotero.debug("** Jasminum pdftk path: " + pdftk);
var args: string[] = [
const args: string[] = [
item.getFilePath() as string,
"update_info_utf8",
cacheFile.path,
Expand Down Expand Up @@ -159,7 +159,7 @@ export async function addBookmarkItem(item?: Zotero.Item) {
return;
}
// Show alert when file is missing
var attachmentExists =
const attachmentExists =
item.getFilePath() && (await OS.File.exists(item.getFilePath() as string));
if (!attachmentExists) {
showPop(getString("pdf-missing"), "fail");
Expand Down
2 changes: 1 addition & 1 deletion src/modules/cnki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ export async function updateCiteCSSCI() {
// 或者可以参考其他核心期刊数据来源
await ztoolkit.ExtraField.setExtraField(item, "CSSCI", cssci);
}
showPop(getString("cssci-success", {args:{title:item.getField("title"), cite:cite, cssci:cssci}}));
showPop(getString("cssci-success", {args:{title:item.getField("title"), cite:cite ? cite : '', cssci:cssci ? cssci : ''}}));
ztoolkit.log("cite number: ${cite} cssci: ${cssci}");
} else {
showPop(getString("url-missing"), "fail");
Expand Down
8 changes: 4 additions & 4 deletions src/modules/jasminum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ export class UIExampleFactory {
@example
static async registerExtraColumn() {
await ztoolkit.ItemTree.register(
"引用数",
"知网引用数",
"cnki-citations",
getString("cnkicite-field-label"),
(
field: string,
unformatted: boolean,
Expand All @@ -353,8 +353,8 @@ export class UIExampleFactory {
}
);
await ztoolkit.ItemTree.register(
"期刊",
"知网核心期刊",
"cnki-journal-type",
getString("cssci-field-label"),
(
field: string,
unformatted: boolean,
Expand Down

0 comments on commit fa4c501

Please sign in to comment.