Open adamlui opened 1 year ago
It looks like it works on the Docsify site. Can you start with the config for search like in here:
https://github.com/docsifyjs/docsify/blob/a69c22ac79f117f091fcfc96c46dc440ef151e48/index.html#L70
And then carefully convert to your languages and see where it breaks?
Also we can't see your working code example so we cannot see if there is some other issue.
Ok I thought my link to the folder containig index.html made it clear but here's a link to the index.html https://github.com/kudoai/chatgpt.js/blob/main/docs/index.html
I'm adding languages offline one by one now
It immediately fails to show the placeholder at 1 language added
search: {
paths: 'auto',
placeholder: { '/': 'Search',
'/zh-cn/': '搜索' },
noData: { '/': 'No results!',
'/zh-cn/': '没有结果!' },
pathNamespaces: ['/zh-cn'],
},
however when I use the docsify/index.html format, it works
search: {
noData: {
'/zh-cn/': '没有结果!',
'/': 'No results!',
},
paths: 'auto',
placeholder: {
'/zh-cn/': '搜索',
'/': 'Search',
},
pathNamespaces: ['/zh-cn'],
},
...so it appears order of keys or values matters, something i don't recall the instructions mentioning
I found the glitch, if /
is the 1st key in either placeholder
or noData
then no translations show (for that obj)
If this is intended behavior, the docs should explicitly state this because the first example
...makes it look like '/'
should go first in obj's
pathNamespaces: /^(\/(zh-cn|ja|ko|hi|de|es|fr|it|pt))?/
isn't indexing the translated docs though, I'm trying the docsify/index.html way now
I can't get it to work that way either :(
Ah, good find a out the ordering. We should definitely mention that in the docs.
I guess /
matches everything, so it doesn't have a chance to fall through to try other cases (like string.match). So more-specific items should go first.
I hadn't noticed as I haven't tried translations myself yet.
It also has some errors in my project. It can only show the undefined
, it accords to the hash of the location ? and it can search the file by the current lanaguage
search: {
maxAge: 86400000, // 过期时间,单位毫秒,默认一天
paths: "auto", // or 'auto'
// placeholder: "Search",
placeholder: {
"/zh-cn": "搜索",
"/en": "Type to search",
},
noData: "No Results",
depth: 2, // 搜索标题的最大层级, 1 - 6
hideOtherSidebarContent: false, // 是否隐藏其他侧边栏内容
},
url: chinese: http://localhost:3000/zh-cn#/. url: english: http://localhost:3000/en#/
Bug Report
When filling localized info in
placeholder
,noData
&pathNamespaces
ofwindow.$docsify.search
inindex.html
, only English appears even on non-English pagesSteps to reproduce
window.$docsify.search
inindex.html
with localized info such as:What is current behaviour
Search bar displays English
What is the expected behaviour
Search bar displays localized language
Other relevant information
[x] Bug does still occur when all/other plugins are disabled?
Your OS: Windows 10
Node.js version: 18.15.0
npm/yarn version: 9.5.0
Browser version: 114.0.2
Docsify version: 4.13.0
Docsify plugins: search, code-copy
Please create a reproducible sandbox
The codesandbox.io site keeps giving error when I try to upload files (https://github.com/chatgptjs/chatgpt.js/tree/main/docs)
Mention the docsify version in which this bug was not present (if any)