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

How to enable Chinese language support for searching? #395

Open
ly55521 opened this issue Apr 22, 2024 · 7 comments
Open

How to enable Chinese language support for searching? #395

ly55521 opened this issue Apr 22, 2024 · 7 comments
Labels
more-information-needed Please Provide More Details

Comments

@ly55521
Copy link

ly55521 commented Apr 22, 2024

请问怎么让其支持中文搜索?
How to enable Chinese language support for searching?

@ryanlelek
Copy link
Owner

Hello, to help us out with this feature request, please provide:

  • Example content / page with Chinese language
  • Search query string(s) that should match the above content

@ryanlelek ryanlelek added the more-information-needed Please Provide More Details label Apr 30, 2024
@ly55521
Copy link
Author

ly55521 commented May 6, 2024

Hello, to help us out with this feature request, please provide:

  • Example content / page with Chinese language
  • Search query string(s) that should match the above content

搜索的关键字(Search keywords):接口、注意、青龙、直接操作
页面内容如下(UTF-8 Page content):
在青龙面板中,启用或禁用环境变量并非通过Python脚本直接操作,而是通过调用青龙面板提供的API接口来实现。以下是一个基本的示例,说明如何使用Python脚本来调用青龙面板的API接口以启用或禁用环境变量。请注意,这需要青龙面板已经配置好了API密钥,并且API接口支持这些操作。

@ly55521
Copy link
Author

ly55521 commented May 28, 2024

Hello, to help us out with this feature request, please provide:

您好,为了帮助我们解决此功能请求,请提供:

  • Example content / page with Chinese language
  • 中文示例内容/页面
  • Search query string(s) that should match the above content
  • 搜索应与上述内容匹配的查询字符串

Have you made any progress?

@zhouslin
Copy link

修改 app/core 中lunr.js
import lunr_ru from 'lunr-languages/lunr.zh.js';
导入中文语言包

function getLunr(config) {
if (instance === null) {
instance = lunr;
lunr_stemmer(instance);
lunr_multi(instance);
lunr_tinyseg(instance);
config.searchExtraLanguages.forEach((lang) => {
if (lang === 'zh') {
lunr_ru(instance);
}
});
}
return instance;
}

修改完后还有个bug
修改page.js

const file = await fs.readFile(contentDir+filePath);

这里路径源码是读不到的加上contentDir

就能中文搜索了。

@ly55521
Copy link
Author

ly55521 commented Sep 14, 2024

修改 app/core 中lunr.js import lunr_ru from 'lunr-languages/lunr.zh.js'; 导入中文语言包

function getLunr(config) { if (instance === null) { instance = lunr; lunr_stemmer(instance); lunr_multi(instance); lunr_tinyseg(instance); config.searchExtraLanguages.forEach((lang) => { if (lang === 'zh') { lunr_ru(instance); } }); } return instance; }

修改完后还有个bug 修改page.js

const file = await fs.readFile(contentDir+filePath);

这里路径源码是读不到的加上contentDir

就能中文搜索了。

试了下编译报错,是要安装中文依赖???

@ly55521
Copy link
Author

ly55521 commented Sep 14, 2024

修改 app/core 中lunr.js import lunr_ru from 'lunr-languages/lunr.zh.js'; 导入中文语言包

function getLunr(config) { if (instance === null) { instance = lunr; lunr_stemmer(instance); lunr_multi(instance); lunr_tinyseg(instance); config.searchExtraLanguages.forEach((lang) => { if (lang === 'zh') { lunr_ru(instance); } }); } return instance; }

修改完后还有个bug 修改page.js

const file = await fs.readFile(contentDir+filePath);

这里路径源码是读不到的加上contentDir

就能中文搜索了。

node:internal/modules/esm/resolve:844
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'lunr-languages' imported from /opt/raneto/app/core/lunr.js
at packageResolve (node:internal/modules/esm/resolve:844:9)
at moduleResolve (node:internal/modules/esm/resolve:901:20)
at defaultResolve (node:internal/modules/esm/resolve:1131:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38)
at ModuleWrap. (node:internal/modules/esm/module_job:85:39)
at link (node:internal/modules/esm/module_job:84:36) {
code: 'ERR_MODULE_NOT_FOUND'
}

@zhouslin
Copy link

zhouslin commented Sep 23, 2024

npm install lunr-languages

安装 lunr-languages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more-information-needed Please Provide More Details
Projects
None yet
Development

No branches or pull requests

3 participants