Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add-Chinese-support-to-smart-chat #395

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ const SUPPORTED_FILE_TYPES = ["md", "canvas"];
//create one object with all the translations
// research : SMART_TRANSLATION[language][key]
const SMART_TRANSLATION = {
"zh":{
"pronous": ["我", "咱", "鄙人", "本人", "俺", "寡人", "本公主", "本王子", "在下", "本宫", "本座", "老夫", "贫道"],
"prompt": "基于你的笔记",
"initial_message": "你好,我是ChatGPT,我通过Smart Connections可以访问您的笔记。请问有关您的笔记方面有什么问题吗?我会尽力回答。"
},
"en": {
"pronous": ["my", "I", "me", "mine", "our", "ours", "us", "we"],
"prompt": "Based on your notes",
Expand Down Expand Up @@ -245,7 +250,16 @@ class SmartConnectionsPlugin extends Obsidian.Plugin {
});
}
// load self_ref_kw_regex
this.self_ref_kw_regex = new RegExp(`\\b(${SMART_TRANSLATION[this.settings.language].pronous.join("|")})\\b`, "gi");
// Language that separates words without spaces.(Asian languages)
if (this.settings.language == "zh")
{
this.self_ref_kw_regex = new RegExp(`(${SMART_TRANSLATION[this.settings.language].pronous.join("|")})`, "gi");
}
// Language that separates words with spaces.
else
{
this.self_ref_kw_regex = new RegExp(`\\b(${SMART_TRANSLATION[this.settings.language].pronous.join("|")})\\b`, "gi");
}
// load failed files
await this.load_failed_files();
}
Expand Down