mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 16:35:57 +08:00
Added mult language show error and notice
This commit is contained in:
19
Message.ts
Normal file
19
Message.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
export const NoticeMsg: {[key: string]:any} = {
|
||||||
|
"en": {
|
||||||
|
"notion-logo": "Share to notion",
|
||||||
|
"sync-success": "Sync to notion success: \n",
|
||||||
|
"sync-fail": "Sync to notion fail: \n",
|
||||||
|
"open-notion": "Please open the file that needs to be synchronized",
|
||||||
|
},
|
||||||
|
"zh": {
|
||||||
|
"notion-logo": "分享到Notion",
|
||||||
|
"sync-success": "同步到Notion成功:\n",
|
||||||
|
"sync-fail": "同步到Notion失败: \n",
|
||||||
|
"open-file": "请打开需要同步的文件"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const NoticeMConfig = (lang:any) :any => {
|
||||||
|
return NoticeMsg[lang]
|
||||||
|
}
|
||||||
16
main.ts
16
main.ts
@@ -1,8 +1,5 @@
|
|||||||
import { timingSafeEqual } from "crypto";
|
|
||||||
import {
|
import {
|
||||||
App,
|
App,
|
||||||
EditableFileView,
|
|
||||||
requestUrl,
|
|
||||||
Editor,
|
Editor,
|
||||||
MarkdownView,
|
MarkdownView,
|
||||||
Modal,
|
Modal,
|
||||||
@@ -16,6 +13,8 @@ import { join } from "path";
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {addIcons} from 'icon';
|
import {addIcons} from 'icon';
|
||||||
import { Upload2Notion } from "Upload2Notion";
|
import { Upload2Notion } from "Upload2Notion";
|
||||||
|
import {NoticeMConfig} from "Message";
|
||||||
|
|
||||||
|
|
||||||
// Remember to rename these classes and interfaces!
|
// Remember to rename these classes and interfaces!
|
||||||
|
|
||||||
@@ -24,6 +23,7 @@ interface MyPluginSettings {
|
|||||||
databaseID: string;
|
databaseID: string;
|
||||||
bannerUrl: string;
|
bannerUrl: string;
|
||||||
proxy: string;
|
proxy: string;
|
||||||
|
langConfig: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: MyPluginSettings = {
|
const DEFAULT_SETTINGS: MyPluginSettings = {
|
||||||
@@ -31,11 +31,11 @@ const DEFAULT_SETTINGS: MyPluginSettings = {
|
|||||||
databaseID: "",
|
databaseID: "",
|
||||||
bannerUrl: "",
|
bannerUrl: "",
|
||||||
proxy: "",
|
proxy: "",
|
||||||
|
langConfig: NoticeMConfig( window.localStorage.getItem('language') || 'en')
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class MyPlugin extends Plugin {
|
export default class MyPlugin extends Plugin {
|
||||||
settings: MyPluginSettings;
|
settings: MyPluginSettings;
|
||||||
|
|
||||||
async onload() {
|
async onload() {
|
||||||
await this.loadSettings();
|
await this.loadSettings();
|
||||||
addIcons();
|
addIcons();
|
||||||
@@ -45,7 +45,7 @@ export default class MyPlugin extends Plugin {
|
|||||||
"Share to notion",
|
"Share to notion",
|
||||||
async (evt: MouseEvent) => {
|
async (evt: MouseEvent) => {
|
||||||
// Called when the user clicks the icon.
|
// Called when the user clicks the icon.
|
||||||
console.log(this,window.localStorage.getItem('language'))
|
|
||||||
|
|
||||||
|
|
||||||
this.upload();
|
this.upload();
|
||||||
@@ -90,9 +90,9 @@ export default class MyPlugin extends Plugin {
|
|||||||
const res = await upload.syncMarkdownToNotion(basename,fileData, fullPath)
|
const res = await upload.syncMarkdownToNotion(basename,fileData, fullPath)
|
||||||
console.log(res)
|
console.log(res)
|
||||||
if(res.status === 200){
|
if(res.status === 200){
|
||||||
new Notice(`${basename} 同步成功`)
|
new Notice(`${this.settings.langConfig["sync-success"]}${basename}`)
|
||||||
}else {
|
}else {
|
||||||
new Notice(`${basename} 同步失败`)
|
new Notice(`${this.settings.langConfig["sync-fail"]}${basename}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ export default class MyPlugin extends Plugin {
|
|||||||
fullPath,
|
fullPath,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
new Notice("请打开需要同步的文件");
|
new Notice(this.settings.langConfig["open-file"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user