Skip to content

Commit

Permalink
fix: #835 代码提示自动补全国际化问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xiayuxuan committed Jul 10, 2024
1 parent eb08453 commit d94b357
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/core/hooks/SuggestList.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,14 @@ const MoreSuggestList = [
},
{
icon: 'FullWidth',
label: '行内代码',
label: 'inlineCode',
keyword: '`',
value: '``',
goLeft: 1,
},
{
icon: 'FullWidth',
label: '代码块',
label: 'codeBlock',
keyword: '`',
value: '```\n\n```\n',
goTop: 2,
Expand Down Expand Up @@ -316,10 +316,10 @@ export function allSuggestList(keyword, locales) {
const systemSuggestList = [].concat(SystemSuggestList);
const otherSuggestList = [].concat(OtherSuggestList);
systemSuggestList.forEach((item) => {
item.label = locales ? locales[item.label] : item.label;
item.label = locales[item.label] || item.label;
});
otherSuggestList.forEach((item) => {
item.label = locales ? locales[item.label] : item.label;
item.label = locales[item.label] || item.label;
});
if (keyword[0] === '/' || keyword[0] === '、' || addonsKeywords.includes(keyword[0])) {
systemSuggestList.forEach((item) => {
Expand Down
3 changes: 2 additions & 1 deletion src/core/hooks/Suggester.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,15 @@ export default class Suggester extends SyntaxBase {

this.suggester = {};
const defaultSuggest = [];
const that = this;
// 默认的唤醒关键字
for (const suggesterKeyword of suggesterKeywords) {
defaultSuggest.push({
keyword: suggesterKeyword,
suggestList(_word, callback) {
// 将word全转成小写
const word = _word.toLowerCase();
const systemSuggestList = allSuggestList(suggesterKeyword, this.$locale);
const systemSuggestList = allSuggestList(suggesterKeyword, that.$locale);
// 加个空格就直接退出联想
if (/^\s$/.test(word)) {
callback(false);
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en_US.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,6 @@ export default {
superLarge: 'Super Large',
detailDefaultContent:
'Click to expand more\nContent\n++- Expand by default\nContent\n++ Collapse by default\nContent',
inlineCode: 'Inline Code',
codeBlock: 'Code Block',
};
2 changes: 2 additions & 0 deletions src/locales/zh_CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,6 @@ export default {
large: '大',
superLarge: '特大',
detailDefaultContent: '点击展开更多\n内容\n++- 默认展开\n内容\n++ 默认收起\n内容',
inlineCode: '行内代码',
codeBlock: '代码块',
};

0 comments on commit d94b357

Please sign in to comment.