From 6287efc05b0ea35b05f3dfe7e84d79977483c7d5 Mon Sep 17 00:00:00 2001 From: chengyu Date: Fri, 26 Nov 2021 17:59:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E9=9A=90=E8=97=8F=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=8C=89=E9=92=AE=EF=BC=8C=E5=8F=AF=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=BB=98=E8=AE=A4=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/menu-bar/menu-bar.jsx | 4 +++- src/lib/app-state-hoc.jsx | 12 +++++++++++- src/playground/index.ejs | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/menu-bar/menu-bar.jsx b/src/components/menu-bar/menu-bar.jsx index 253d961..80c33d2 100644 --- a/src/components/menu-bar/menu-bar.jsx +++ b/src/components/menu-bar/menu-bar.jsx @@ -412,7 +412,9 @@ class MenuBar extends React.Component { /> )} - {(this.props.canChangeLanguage) && (
diff --git a/src/lib/app-state-hoc.jsx b/src/lib/app-state-hoc.jsx index f7afcb9..75bb2dd 100644 --- a/src/lib/app-state-hoc.jsx +++ b/src/lib/app-state-hoc.jsx @@ -31,7 +31,15 @@ const AppStateHOC = function (WrappedComponent, localesOnly) { let enhancer; let initializedLocales = localesInitialState; - const locale = detectLocale(Object.keys(locales)); + let locale; + if(window.scratchConfig && window.scratchConfig.menuBar && window.scratchConfig.menuBar.languageButton && + window.scratchConfig.menuBar.languageButton.defaultLanguage){ + window.scratchConfig.menuBar.languageButton.defaultLanguage + locale = window.scratchConfig.menuBar.languageButton.defaultLanguage + }else{ + locale = detectLocale(Object.keys(locales)); + } + if (locale !== 'en') { initializedLocales = initLocale(initializedLocales, locale); } @@ -103,6 +111,8 @@ const AppStateHOC = function (WrappedComponent, localesOnly) { var event = new CustomEvent('setFullScreen', {"detail": {isFullScreen: isFullScreen}}); document.dispatchEvent(event); } + + } componentDidUpdate (prevProps) { if (localesOnly) return; diff --git a/src/playground/index.ejs b/src/playground/index.ejs index 76c4e24..947cc49 100644 --- a/src/playground/index.ejs +++ b/src/playground/index.ejs @@ -28,6 +28,11 @@ style: { background: 'hsla(215, 100%, 65%, 1)', }, + //切换语言按钮 + languageButton:{ + show: true, //是否显示 + defaultLanguage: 'zh-cn' //默认语言 en zh-cn zh-tw + }, //新建按钮 newButton:{ show: true, //是否显示