mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 14:47:56 +01:00
Fix i18n issue on editor
This commit is contained in:
parent
e2083befa9
commit
57c051c348
@ -75,11 +75,6 @@ const Editor = ({
|
|||||||
DesignerKeyboard.pause();
|
DesignerKeyboard.pause();
|
||||||
}
|
}
|
||||||
}, [options.enableKeyboardEvents]);
|
}, [options.enableKeyboardEvents]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
Messages.init(options.locale);
|
|
||||||
}, [options.locale]);
|
|
||||||
|
|
||||||
const onLoadDesigner = (mapId: string, options: EditorOptions, persistenceManager: PersistenceManager): Designer => {
|
const onLoadDesigner = (mapId: string, options: EditorOptions, persistenceManager: PersistenceManager): Designer => {
|
||||||
const buildOptions = DesignerOptionsBuilder.buildOptions({
|
const buildOptions = DesignerOptionsBuilder.buildOptions({
|
||||||
persistenceManager,
|
persistenceManager,
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2021] [wisemapping]
|
||||||
|
*
|
||||||
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the license at
|
||||||
|
*
|
||||||
|
* http://www.wisemapping.org/license
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import Editor, { EditorOptions } from '../../../../src/index';
|
import Editor, { EditorOptions } from '../../../../src/index';
|
||||||
|
@ -22,6 +22,7 @@ class Messages {
|
|||||||
public static __bundle;
|
public static __bundle;
|
||||||
|
|
||||||
static init(locale: string) {
|
static init(locale: string) {
|
||||||
|
console.log(`Init designer message: ${locale}`);
|
||||||
let userLocale = $defined(locale) ? locale : 'en';
|
let userLocale = $defined(locale) ? locale : 'en';
|
||||||
let bundle = Bundle[userLocale];
|
let bundle = Bundle[userLocale];
|
||||||
|
|
||||||
@ -36,7 +37,6 @@ class Messages {
|
|||||||
|
|
||||||
const $msg = function $msg(key: string) {
|
const $msg = function $msg(key: string) {
|
||||||
if (!Messages.__bundle) {
|
if (!Messages.__bundle) {
|
||||||
console.log('Trigger initialization');
|
|
||||||
Messages.init('en');
|
Messages.init('en');
|
||||||
}
|
}
|
||||||
const msg = Messages.__bundle[key];
|
const msg = Messages.__bundle[key];
|
||||||
|
@ -611,7 +611,7 @@ export default class RestClient implements Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildPersistenceManager(editorMode: EditorRenderMode): PersistenceManager {
|
buildPersistenceManager(editorMode: EditorRenderMode ): PersistenceManager {
|
||||||
if (this.persistenceManager) {
|
if (this.persistenceManager) {
|
||||||
return this.persistenceManager;
|
return this.persistenceManager;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import { useSelector } from 'react-redux';
|
|||||||
import { hotkeysEnabled } from '../../redux/editorSlice';
|
import { hotkeysEnabled } from '../../redux/editorSlice';
|
||||||
import ReactGA from 'react-ga';
|
import ReactGA from 'react-ga';
|
||||||
import Client from '../../classes/client';
|
import Client from '../../classes/client';
|
||||||
import { activeInstance } from '../../redux/clientSlice';
|
import { activeInstance, fetchAccount } from '../../redux/clientSlice';
|
||||||
import { PersistenceManager } from '@wisemapping/mindplot';
|
import { PersistenceManager } from '@wisemapping/mindplot';
|
||||||
import EditorOptionsBulder from './EditorOptionsBuider';
|
import EditorOptionsBulder from './EditorOptionsBuider';
|
||||||
|
|
||||||
@ -20,22 +20,22 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => {
|
|||||||
const hotkey = useSelector(hotkeysEnabled);
|
const hotkey = useSelector(hotkeysEnabled);
|
||||||
const userLocale = AppI18n.getUserLocale();
|
const userLocale = AppI18n.getUserLocale();
|
||||||
const client: Client = useSelector(activeInstance);
|
const client: Client = useSelector(activeInstance);
|
||||||
const [persistenceManager, setPersistenceManager] = React.useState<PersistenceManager>();
|
|
||||||
const { mapId, options } = EditorOptionsBulder.build(userLocale.code, hotkey, isTryMode);
|
const { mapId, options } = EditorOptionsBulder.build(userLocale.code, hotkey, isTryMode);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ReactGA.pageview(window.location.pathname + window.location.search);
|
ReactGA.pageview(window.location.pathname + window.location.search);
|
||||||
const persistence = client.buildPersistenceManager(options.mode);
|
|
||||||
setPersistenceManager(persistence);
|
|
||||||
return () => client.removePersistenceManager();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// As temporal hack, editor properties are propagated from global variables...
|
// Account settings can be null and editor cannot be initilized multiple times. This creates problems
|
||||||
return persistenceManager ? (
|
// at the i18n resource loading.
|
||||||
|
const persistence = client.buildPersistenceManager(options.mode);
|
||||||
|
const loadCompleted = persistence && (options.mode === 'showcase' || fetchAccount());
|
||||||
|
|
||||||
|
return loadCompleted ? (
|
||||||
<>
|
<>
|
||||||
<Editor onAction={setActiveDialog}
|
<Editor onAction={setActiveDialog}
|
||||||
options={options}
|
options={options}
|
||||||
persistenceManager={persistenceManager}
|
persistenceManager={persistence}
|
||||||
mapId={mapId} />
|
mapId={mapId} />
|
||||||
{
|
{
|
||||||
activeDialog &&
|
activeDialog &&
|
||||||
|
Loading…
Reference in New Issue
Block a user