mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-25 15:47:55 +01:00
Fix i18n on default user
This commit is contained in:
parent
275f05a41e
commit
c77268868d
@ -37,8 +37,7 @@ const queryClient = new QueryClient({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const App = (): ReactElement => {
|
const App = (): ReactElement => {
|
||||||
const appi18n = new AppI18n();
|
const locale = AppI18n.getBrowserLocale();
|
||||||
const locale = appi18n.getBrowserLocale();
|
|
||||||
|
|
||||||
// global variables set server-side
|
// global variables set server-side
|
||||||
const istTryMode = global.memoryPersistence;
|
const istTryMode = global.memoryPersistence;
|
||||||
|
@ -15,13 +15,13 @@ export class Locale {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class AppI18n {
|
export default abstract class AppI18n {
|
||||||
public getUserLocale(): Locale {
|
public static getUserLocale(): Locale {
|
||||||
const account = fetchAccount();
|
const account = fetchAccount();
|
||||||
return account ? account.locale : this.getBrowserLocale();
|
return account?.locale ? account.locale : this.getBrowserLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
public getBrowserLocale(): Locale {
|
public static getBrowserLocale(): Locale {
|
||||||
let localeCode = (navigator.languages && navigator.languages[0]) || navigator.language;
|
let localeCode = (navigator.languages && navigator.languages[0]) || navigator.language;
|
||||||
|
|
||||||
// Just remove the variant ...
|
// Just remove the variant ...
|
||||||
|
@ -63,7 +63,7 @@ export type AccountInfo = {
|
|||||||
firstname: string;
|
firstname: string;
|
||||||
lastname: string;
|
lastname: string;
|
||||||
email: string;
|
email: string;
|
||||||
locale: Locale;
|
locale?: Locale;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Permission = {
|
export type Permission = {
|
||||||
|
@ -184,7 +184,7 @@ export default class RestClient implements Client {
|
|||||||
`${this.baseUrl}/c/restful/maps?title=${model.title}&description=${model.description ? model.description : ''
|
`${this.baseUrl}/c/restful/maps?title=${model.title}&description=${model.description ? model.description : ''
|
||||||
}`,
|
}`,
|
||||||
model.content,
|
model.content,
|
||||||
{ headers: { 'Content-Type': model.contentType } }
|
{ headers: { 'Content-Type': 'application/xml' } }
|
||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const mapId = response.headers.resourceid;
|
const mapId = response.headers.resourceid;
|
||||||
@ -214,7 +214,7 @@ export default class RestClient implements Client {
|
|||||||
lastname: account.lastname ? account.lastname : '',
|
lastname: account.lastname ? account.lastname : '',
|
||||||
firstname: account.firstname ? account.firstname : '',
|
firstname: account.firstname ? account.firstname : '',
|
||||||
email: account.email,
|
email: account.email,
|
||||||
locale: locale ? localeFromStr(locale) : Locales.EN,
|
locale: locale ? localeFromStr(locale) : undefined,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
@ -13,8 +13,7 @@ const EditorPage = ({ mapId, ...props }: EditorPropsType): React.ReactElement =>
|
|||||||
const [activeDialog, setActiveDialog] = React.useState<ActionType | null>(null);
|
const [activeDialog, setActiveDialog] = React.useState<ActionType | null>(null);
|
||||||
|
|
||||||
// Load user locale ...
|
// Load user locale ...
|
||||||
const appi18n = new AppI18n();
|
const userLocale = AppI18n.getUserLocale();
|
||||||
const userLocale = appi18n.getUserLocale();
|
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<Editor {...props} onAction={setActiveDialog} locale={userLocale.code} />
|
<Editor {...props} onAction={setActiveDialog} locale={userLocale.code} />
|
||||||
|
@ -105,7 +105,7 @@ const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => {
|
|||||||
description={intl.formatMessage({
|
description={intl.formatMessage({
|
||||||
id: 'import.description',
|
id: 'import.description',
|
||||||
defaultMessage:
|
defaultMessage:
|
||||||
'You can import FreeMind 1.0.1 and WiseMapping maps to your list of maps. Select the file you want to import.',
|
'You can import WiseMapping maps to your list of maps. Select the file you want to import.',
|
||||||
})}
|
})}
|
||||||
submitButton={intl.formatMessage({ id: 'import.button', defaultMessage: 'Create' })}
|
submitButton={intl.formatMessage({ id: 'import.button', defaultMessage: 'Create' })}
|
||||||
>
|
>
|
||||||
|
@ -66,8 +66,7 @@ const MapsPage = (): ReactElement => {
|
|||||||
const [activeDialog, setActiveDialog] = React.useState<ActionType | undefined>(undefined);
|
const [activeDialog, setActiveDialog] = React.useState<ActionType | undefined>(undefined);
|
||||||
|
|
||||||
// Reload based on user preference ...
|
// Reload based on user preference ...
|
||||||
const appi18n = new AppI18n();
|
const userLocale = AppI18n.getUserLocale();
|
||||||
const userLocale = appi18n.getUserLocale();
|
|
||||||
|
|
||||||
const cache = createIntlCache();
|
const cache = createIntlCache();
|
||||||
const intl = createIntl({
|
const intl = createIntl({
|
||||||
|
@ -5,7 +5,7 @@ import Client from '../../../classes/client';
|
|||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { activeInstance, fetchAccount } from '../../../redux/clientSlice';
|
import { activeInstance, fetchAccount } from '../../../redux/clientSlice';
|
||||||
import { FormattedMessage, useIntl } from 'react-intl';
|
import { FormattedMessage, useIntl } from 'react-intl';
|
||||||
import { LocaleCode, Locales } from '../../../classes/app-i18n';
|
import AppI18n, { LocaleCode, Locales } from '../../../classes/app-i18n';
|
||||||
import Tooltip from '@mui/material/Tooltip';
|
import Tooltip from '@mui/material/Tooltip';
|
||||||
import Button from '@mui/material/Button';
|
import Button from '@mui/material/Button';
|
||||||
import Menu from '@mui/material/Menu';
|
import Menu from '@mui/material/Menu';
|
||||||
@ -49,7 +49,7 @@ const LanguageMenu = (): React.ReactElement => {
|
|||||||
mutation.mutate(localeCode);
|
mutation.mutate(localeCode);
|
||||||
};
|
};
|
||||||
|
|
||||||
const accountInfo = fetchAccount();
|
const userLocale = AppI18n.getUserLocale();
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
@ -68,7 +68,7 @@ const LanguageMenu = (): React.ReactElement => {
|
|||||||
onClick={handleMenu}
|
onClick={handleMenu}
|
||||||
startIcon={<TranslateTwoTone style={{ color: 'inherit' }} />}
|
startIcon={<TranslateTwoTone style={{ color: 'inherit' }} />}
|
||||||
>
|
>
|
||||||
{accountInfo?.locale?.label}
|
{userLocale.label}
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Menu
|
<Menu
|
||||||
|
Loading…
Reference in New Issue
Block a user