Fix i18n bug on map load

This commit is contained in:
Paulo Gustavo Veiga 2022-02-05 13:53:10 -08:00
parent 3c5a133b02
commit 3bd509f1af
8 changed files with 90 additions and 69 deletions

View File

@ -28,5 +28,8 @@ module.exports = {
resolve: { resolve: {
extensions: ['.js'], extensions: ['.js'],
}, },
plugins: [new CleanWebpackPlugin()], plugins: [new CleanWebpackPlugin({
dangerouslyAllowCleanPatternsOutsideProject: true,
dry: false,
})],
}; };

View File

@ -21,7 +21,7 @@
"defaultMessage": "Cancelar" "defaultMessage": "Cancelar"
}, },
"action.close-button": { "action.close-button": {
"defaultMessage": "Cerca" "defaultMessage": "Cerrar"
}, },
"action.delete": { "action.delete": {
"defaultMessage": "Borrar" "defaultMessage": "Borrar"
@ -60,16 +60,16 @@
"defaultMessage": "Nuevo mapa" "defaultMessage": "Nuevo mapa"
}, },
"action.open": { "action.open": {
"defaultMessage": "Abierto" "defaultMessage": "Abrir"
}, },
"action.print": { "action.print": {
"defaultMessage": "Impresión" "defaultMessage": "Imprimir"
}, },
"action.publish": { "action.publish": {
"defaultMessage": "Publicar" "defaultMessage": "Publicar"
}, },
"action.rename": { "action.rename": {
"defaultMessage": "Rebautizar" "defaultMessage": "Renombar"
}, },
"action.rename-description-placeholder": { "action.rename-description-placeholder": {
"defaultMessage": "Descripción" "defaultMessage": "Descripción"
@ -78,10 +78,10 @@
"defaultMessage": "Nombre" "defaultMessage": "Nombre"
}, },
"action.share": { "action.share": {
"defaultMessage": "Cuota" "defaultMessage": "Compartir"
}, },
"changepwd.button": { "changepwd.button": {
"defaultMessage": "Cambio" "defaultMessage": "Cambiar"
}, },
"changepwd.confirm-password": { "changepwd.confirm-password": {
"defaultMessage": "Confirmar contraseña" "defaultMessage": "Confirmar contraseña"
@ -195,7 +195,7 @@
"defaultMessage": "¿Ya tienes una cuenta?" "defaultMessage": "¿Ya tienes una cuenta?"
}, },
"help.support": { "help.support": {
"defaultMessage": "Apoyo" "defaultMessage": "Ayuda"
}, },
"history.no-changes": { "history.no-changes": {
"defaultMessage": "No hay cambios disponibles" "defaultMessage": "No hay cambios disponibles"
@ -231,7 +231,7 @@
"defaultMessage": "Última fecha de modificación" "defaultMessage": "Última fecha de modificación"
}, },
"info.modified-tny": { "info.modified-tny": {
"defaultMessage": "ultima modificacion por" "defaultMessage": "Ultima modificacion por"
}, },
"info.name": { "info.name": {
"defaultMessage": "Nombre" "defaultMessage": "Nombre"
@ -240,10 +240,10 @@
"defaultMessage": "Visible públicamente" "defaultMessage": "Visible públicamente"
}, },
"info.sharing": { "info.sharing": {
"defaultMessage": "Intercambio" "defaultMessage": "Compartido"
}, },
"info.starred": { "info.starred": {
"defaultMessage": "Sembrado de estrellas" "defaultMessage": "Destacados"
}, },
"info.title": { "info.title": {
"defaultMessage": "Información" "defaultMessage": "Información"
@ -286,7 +286,7 @@
"defaultMessage": "Inscribirse" "defaultMessage": "Inscribirse"
}, },
"login.title": { "login.title": {
"defaultMessage": "Bienvenidos" "defaultMessage": "Bienvenido"
}, },
"login.userinactive": { "login.userinactive": {
"defaultMessage": "Lo sentimos, tu cuenta aún no ha sido activada. Recibirás un correo electrónico de notificación cuando se active. ¡Manténganse al tanto!." "defaultMessage": "Lo sentimos, tu cuenta aún no ha sido activada. Recibirás un correo electrónico de notificación cuando se active. ¡Manténganse al tanto!."
@ -331,34 +331,34 @@
"defaultMessage": "Modificado por {by} el {on}" "defaultMessage": "Modificado por {by} el {on}"
}, },
"maps.nav-all": { "maps.nav-all": {
"defaultMessage": "Todo" "defaultMessage": "Todos"
}, },
"maps.nav-onwned": { "maps.nav-onwned": {
"defaultMessage": "propiedad" "defaultMessage": "Mis Mapas"
}, },
"maps.nav-public": { "maps.nav-public": {
"defaultMessage": "Público" "defaultMessage": "Públicos"
}, },
"maps.nav-shared": { "maps.nav-shared": {
"defaultMessage": "Comparte conmigo" "defaultMessage": "Compartidos"
}, },
"maps.nav-starred": { "maps.nav-starred": {
"defaultMessage": "Sembrado de estrellas" "defaultMessage": "Destacados"
}, },
"maps.page-title": { "maps.page-title": {
"defaultMessage": "Mis mapas | WiseMapping" "defaultMessage": "Mis Mapas | WiseMapping"
}, },
"maps.revert": { "maps.revert": {
"defaultMessage": "Revertir" "defaultMessage": "Revertir"
}, },
"maps.search-action": { "maps.search-action": {
"defaultMessage": "Búsqueda ..." "defaultMessage": "Búscar ..."
}, },
"maps.tooltip-open": { "maps.tooltip-open": {
"defaultMessage": "Abierto para edición" "defaultMessage": "Abrir para edición"
}, },
"maps.tooltip-starred": { "maps.tooltip-starred": {
"defaultMessage": "Sembrado de estrellas" "defaultMessage": "Destacados"
}, },
"maps.view": { "maps.view": {
"defaultMessage": "Vista" "defaultMessage": "Vista"
@ -439,7 +439,7 @@
"defaultMessage": "Editor" "defaultMessage": "Editor"
}, },
"role.owner": { "role.owner": {
"defaultMessage": "onwer" "defaultMessage": "Dueño"
}, },
"role.viewer": { "role.viewer": {
"defaultMessage": "Espectador" "defaultMessage": "Espectador"

View File

@ -53,31 +53,35 @@ const App = (): ReactElement => {
<Route exact path="/"> <Route exact path="/">
<Redirect to="/c/login" /> <Redirect to="/c/login" />
</Route> </Route>
<Route path="/c/login" component={LoginPage} /> <Route path="/c/login"
<Route path="/c/registration"> component={LoginPage}
<RegistationPage /> />
<Route
path="/c/registration">
component={RegistationPage}
</Route> </Route>
<Route <Route
path="/c/registration-success" path="/c/registration-success"
component={RegistrationSuccessPage} component={RegistrationSuccessPage}
/> />
<Route path="/c/forgot-password"> <Route
<ForgotPasswordPage /> path="/c/forgot-password"
</Route> component={ForgotPasswordPage} />
<Route <Route
path="/c/forgot-password-success" path="/c/forgot-password-success"
component={ForgotPasswordSuccessPage} component={ForgotPasswordSuccessPage}
/> />
<Route exact path="/c/maps/"> <Route
<MapsPage /> exact path="/c/maps/"
</Route> component={MapsPage}
/>
<Route exact path="/c/maps/:id/edit"> <Route exact path="/c/maps/:id/edit">
<Editor memoryPersistence={memoryPersistence} <Editor memoryPersistence={memoryPersistence}
readOnlyMode={readOnlyMode} mapId={mapId} /> readOnlyMode={readOnlyMode} mapId={mapId} />
</Route> </Route>
<Route exact path="/c/maps/:id/try"> <Route exact path="/c/maps/:id/try">
<Editor memoryPersistence={memoryPersistence} <Editor memoryPersistence={memoryPersistence}
readOnlyMode={readOnlyMode} mapId={mapId} /> readOnlyMode={readOnlyMode} mapId={mapId} />
</Route> </Route>
</Switch> </Switch>
</Router> </Router>

View File

@ -686,7 +686,7 @@
"maps.nav-all": [ "maps.nav-all": [
{ {
"type": 0, "type": 0,
"value": "All" "value": "All 333"
} }
], ],
"maps.nav-onwned": [ "maps.nav-onwned": [

View File

@ -44,7 +44,7 @@
"action.close-button": [ "action.close-button": [
{ {
"type": 0, "type": 0,
"value": "Cerca" "value": "Cerrar"
} }
], ],
"action.delete": [ "action.delete": [
@ -122,13 +122,13 @@
"action.open": [ "action.open": [
{ {
"type": 0, "type": 0,
"value": "Abierto" "value": "Abrir"
} }
], ],
"action.print": [ "action.print": [
{ {
"type": 0, "type": 0,
"value": "Impresión" "value": "Imprimir"
} }
], ],
"action.publish": [ "action.publish": [
@ -140,7 +140,7 @@
"action.rename": [ "action.rename": [
{ {
"type": 0, "type": 0,
"value": "Rebautizar" "value": "Renombar"
} }
], ],
"action.rename-description-placeholder": [ "action.rename-description-placeholder": [
@ -158,13 +158,13 @@
"action.share": [ "action.share": [
{ {
"type": 0, "type": 0,
"value": "Cuota" "value": "Compartir"
} }
], ],
"changepwd.button": [ "changepwd.button": [
{ {
"type": 0, "type": 0,
"value": "Cambio" "value": "Cambiar"
} }
], ],
"changepwd.confirm-password": [ "changepwd.confirm-password": [
@ -404,7 +404,7 @@
"help.support": [ "help.support": [
{ {
"type": 0, "type": 0,
"value": "Apoyo" "value": "Ayuda"
} }
], ],
"history.no-changes": [ "history.no-changes": [
@ -476,7 +476,7 @@
"info.modified-tny": [ "info.modified-tny": [
{ {
"type": 0, "type": 0,
"value": "ultima modificacion por" "value": "Ultima modificacion por"
} }
], ],
"info.name": [ "info.name": [
@ -494,13 +494,13 @@
"info.sharing": [ "info.sharing": [
{ {
"type": 0, "type": 0,
"value": "Intercambio" "value": "Compartido"
} }
], ],
"info.starred": [ "info.starred": [
{ {
"type": 0, "type": 0,
"value": "Sembrado de estrellas" "value": "Destacados"
} }
], ],
"info.title": [ "info.title": [
@ -584,7 +584,7 @@
"login.title": [ "login.title": [
{ {
"type": 0, "type": 0,
"value": "Bienvenidos" "value": "Bienvenido"
} }
], ],
"login.userinactive": [ "login.userinactive": [
@ -686,37 +686,37 @@
"maps.nav-all": [ "maps.nav-all": [
{ {
"type": 0, "type": 0,
"value": "Todo" "value": "Todos"
} }
], ],
"maps.nav-onwned": [ "maps.nav-onwned": [
{ {
"type": 0, "type": 0,
"value": "propiedad" "value": "Mis Mapas"
} }
], ],
"maps.nav-public": [ "maps.nav-public": [
{ {
"type": 0, "type": 0,
"value": "Público" "value": "Públicos"
} }
], ],
"maps.nav-shared": [ "maps.nav-shared": [
{ {
"type": 0, "type": 0,
"value": "Comparte conmigo" "value": "Compartidos"
} }
], ],
"maps.nav-starred": [ "maps.nav-starred": [
{ {
"type": 0, "type": 0,
"value": "Sembrado de estrellas" "value": "Destacados"
} }
], ],
"maps.page-title": [ "maps.page-title": [
{ {
"type": 0, "type": 0,
"value": "Mis mapas | WiseMapping" "value": "Mis Mapas | WiseMapping"
} }
], ],
"maps.revert": [ "maps.revert": [
@ -728,19 +728,19 @@
"maps.search-action": [ "maps.search-action": [
{ {
"type": 0, "type": 0,
"value": "Búsqueda ..." "value": "Búscar ..."
} }
], ],
"maps.tooltip-open": [ "maps.tooltip-open": [
{ {
"type": 0, "type": 0,
"value": "Abierto para edición" "value": "Abrir para edición"
} }
], ],
"maps.tooltip-starred": [ "maps.tooltip-starred": [
{ {
"type": 0, "type": 0,
"value": "Sembrado de estrellas" "value": "Destacados"
} }
], ],
"maps.view": [ "maps.view": [
@ -902,7 +902,7 @@
"role.owner": [ "role.owner": [
{ {
"type": 0, "type": 0,
"value": "onwer" "value": "Dueño"
} }
], ],
"role.viewer": [ "role.viewer": [

View File

@ -1,8 +1,8 @@
import React from 'react'; import React from 'react';
import { useIntl } from 'react-intl';
import ActionDispatcher from '../action-dispatcher'; import ActionDispatcher from '../action-dispatcher';
import { ActionType } from '../action-chooser'; import { ActionType } from '../action-chooser';
import WiseEditor from '@wisemapping/editor'; import WiseEditor from '@wisemapping/editor';
import AppI18n from '../../../classes/app-i18n';
export type EditorPropsType = { export type EditorPropsType = {
mapId: number; mapId: number;
@ -10,11 +10,15 @@ export type EditorPropsType = {
readOnlyMode: boolean; readOnlyMode: boolean;
}; };
export default function Editor({ mapId, ...props } : EditorPropsType): React.ReactElement { export default function Editor({ mapId, ...props }: EditorPropsType): React.ReactElement {
const [activeDialog, setActiveDialog] = React.useState<ActionType | null>(null); const [activeDialog, setActiveDialog] = React.useState<ActionType | null>(null);
const intl = useIntl();
// Load user locale ...
const appi18n = new AppI18n();
const userLocale = appi18n.getUserLocale();
return <> return <>
<WiseEditor {...props} onAction={setActiveDialog} locale={intl.locale} /> <WiseEditor {...props} onAction={setActiveDialog} locale={userLocale.code} />
{ {
activeDialog && activeDialog &&
<ActionDispatcher <ActionDispatcher

View File

@ -7,7 +7,7 @@ import List from '@material-ui/core/List';
import IconButton from '@material-ui/core/IconButton'; import IconButton from '@material-ui/core/IconButton';
import { useStyles } from './style'; import { useStyles } from './style';
import { MapsList } from './maps-list'; import { MapsList } from './maps-list';
import { FormattedMessage, IntlProvider, useIntl } from 'react-intl'; import { createIntl, createIntlCache, FormattedMessage, IntlProvider, IntlShape, useIntl } from 'react-intl';
import { useQuery, useMutation, useQueryClient } from 'react-query'; import { useQuery, useMutation, useQueryClient } from 'react-query';
import { activeInstance } from '../../redux/clientSlice'; import { activeInstance } from '../../redux/clientSlice';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
@ -64,9 +64,20 @@ const MapsPage = (): ReactElement => {
const client: Client = useSelector(activeInstance); const client: Client = useSelector(activeInstance);
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const [activeDialog, setActiveDialog] = React.useState<ActionType | undefined>(undefined); const [activeDialog, setActiveDialog] = React.useState<ActionType | undefined>(undefined);
const intl = useIntl();
// Reload based on user preference ...
const appi18n = new AppI18n();
const userLocale = appi18n.getUserLocale();
const cache = createIntlCache();
const intl = createIntl({
defaultLocale: userLocale.code,
locale: Locales.EN.code,
messages: userLocale.message
}, cache)
useEffect(() => { useEffect(() => {
document.title = intl.formatMessage({ document.title = intl.formatMessage({
id: 'maps.page-title', id: 'maps.page-title',
defaultMessage: 'My Maps | WiseMapping', defaultMessage: 'My Maps | WiseMapping',
@ -130,10 +141,6 @@ const MapsPage = (): ReactElement => {
}) })
); );
// Configure using user settings ...
const appi18n = new AppI18n();
const userLocale = appi18n.getUserLocale();
return ( return (
<IntlProvider <IntlProvider
locale={userLocale.code} locale={userLocale.code}

View File

@ -45,7 +45,10 @@ module.exports = {
}, },
}, },
plugins: [ plugins: [
new CleanWebpackPlugin(), new CleanWebpackPlugin({
dangerouslyAllowCleanPatternsOutsideProject: true,
dry: false,
}),
new CopyWebpackPlugin({ new CopyWebpackPlugin({
patterns: [ patterns: [
{ {