ui: use lang pretest setting to locate related languages (#390)

This commit is contained in:
undefined committed 2022-07-20 18:53:29 +08:00
1 parent bbde2b9cda
commit d9972d6e97
6 files changed
+97 -91

No files matched your search

@@ -87,7 +87,8 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
super(props);
if (!availableLangs[this.props.editorLang]) {
// preference not allowed
const key = keys.find((i) => availableLangs[i].pretest === this.props.editorLang);
const key = keys.filter((i) => availableLangs[i].pretest)
.find((i) => availableLangs[i].pretest.split('.')[0] === this.props.editorLang.split('.')[0]);
this.props.setEditorLanguage(key || keys[0]);
}
}