Skip to content

Commit 760ebbe

Browse files
authored
Translate resource type in the detail panel (#2108)
1 parent 673a865 commit 760ebbe

File tree

16 files changed

+121
-18
lines changed

16 files changed

+121
-18
lines changed
Submodule MapStore2 updated 47 files

geonode_mapstore_client/client/js/plugins/ResourceDetails/ResourceDetails.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ import Message from '@mapstore/framework/components/I18N/Message';
7373
* {
7474
* "type": "query",
7575
* "labelId": "gnviewer.resourceType",
76-
* "value": "{context.get(state('gnResourceData'), 'resource_type')}",
76+
* "valueId": "{'gnviewer.' + context.get(state('gnResourceData'), 'resource_type')}",
7777
* "pathname": "/",
7878
* "query": {
7979
* "f": "{context.get(state('gnResourceData'), 'resource_type')}"
@@ -130,7 +130,7 @@ function ResourceDetailsPanel({
130130
{
131131
"type": "query",
132132
"labelId": "gnviewer.resourceType",
133-
"value": "{context.get(state('gnResourceData'), 'resource_type')}",
133+
"valueId": "{'gnviewer.' + context.get(state('gnResourceData'), 'resource_type')}",
134134
"pathname": "/",
135135
"query": {
136136
"f": "{context.get(state('gnResourceData'), 'resource_type')}"

geonode_mapstore_client/client/js/plugins/ResourceDetails/containers/DetailsPanel.jsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,24 @@ import useParsePluginConfigExpressions from '@mapstore/framework/plugins/Resourc
4040
import { hashLocationToHref } from '@mapstore/framework/utils/ResourcesFiltersUtils';
4141
import { getMonitoredStateSelector, getRouterLocation, getDetailPanelTab } from '@mapstore/framework/plugins/ResourcesCatalog/selectors/resources';
4242
import withScrollableTabs from '@js/components/enhancers/withScrollableTabs';
43+
import { getMessageById } from '@mapstore/framework/utils/LocaleUtils';
4344
import { setDetailPanelTab } from '@mapstore/framework/plugins/ResourcesCatalog/actions/resources';
4445
const DetailsInfo = withScrollableTabs(DetailsInfoComp);
4546

47+
const transformValue = (obj, messages) => {
48+
if (Array.isArray(obj)) {
49+
return obj.map(item => transformValue(item, messages));
50+
}
51+
if (obj && typeof obj === 'object') {
52+
const { valueId, items, ...rest } = obj;
53+
return {
54+
...rest,
55+
...(valueId ? { value: getMessageById(messages, valueId) } : {}),
56+
...(items ? { items: transformValue(items, messages) } : {})
57+
};
58+
}
59+
return obj;
60+
};
4661
const ConnectedDetailsThumbnail = connect(
4762
createSelector([
4863
state => state?.gnresource?.showMapThumbnail || false,
@@ -86,6 +101,7 @@ function DetailsPanel({
86101

87102
const resource = parseCatalogResource(resourceProp);
88103
const parsedConfig = useParsePluginConfigExpressions(monitoredState, { tabs }, context?.plugins?.requires);
104+
const transformedTabs = transformValue(parsedConfig?.tabs ?? [], context?.messages);
89105

90106
const { query } = url.parse(location.search, true);
91107
const updatedLocation = useRef();
@@ -140,7 +156,7 @@ function DetailsPanel({
140156
{!loading ? <DetailsInfo
141157
className="_padding-lr-md"
142158
key={resource?.pk || resource?.id}
143-
tabs={replaceResourcePaths(parsedConfig.tabs, resource, [])}
159+
tabs={replaceResourcePaths(transformedTabs, resource, [])}
144160
tabComponents={tabComponents}
145161
query={query}
146162
formatHref={handleFormatHref}
@@ -161,7 +177,8 @@ function DetailsPanel({
161177
}
162178

163179
DetailsPanel.contextTypes = {
164-
plugins: PropTypes.object
180+
plugins: PropTypes.object,
181+
messages: PropTypes.object
165182
};
166183

167184
const ConnectedDetailsPanel = connect(

geonode_mapstore_client/static/mapstore/gn-translations/data.de-DE.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,13 @@
478478
"showPreview": "Vorschau anzeigen",
479479
"hidePreview": "Vorschau ausblenden",
480480
"columnTitle": "Titel",
481-
"columnOwner": "Eigentümer"
481+
"columnOwner": "Eigentümer",
482+
"dataset": "datensatz",
483+
"map": "karte",
484+
"geostory": "geostory",
485+
"document": "dokument",
486+
"dashboard": "dashboard",
487+
"mapviewer": "kartenviewer"
482488
},
483489
"resourcesCatalog": {
484490
"anonymous": "Jeder",

geonode_mapstore_client/static/mapstore/gn-translations/data.en-US.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,13 @@
478478
"showPreview": "Show Preview",
479479
"hidePreview": "Hide Preview",
480480
"columnTitle": "Title",
481-
"columnOwner": "Owner"
481+
"columnOwner": "Owner",
482+
"dataset": "dataset",
483+
"map": "map",
484+
"geostory": "geostory",
485+
"document": "document",
486+
"dashboard": "dashboard",
487+
"mapviewer": "mapviewer"
482488
},
483489
"resourcesCatalog": {
484490
"anonymous": "Anyone",

geonode_mapstore_client/static/mapstore/gn-translations/data.es-ES.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,13 @@
477477
"showPreview": "Mostrar vista previa",
478478
"hidePreview": "Ocultar vista previa",
479479
"columnTitle": "Título",
480-
"columnOwner": "Propietario"
480+
"columnOwner": "Propietario",
481+
"dataset": "conjunto de datos",
482+
"map": "mapa",
483+
"geostory": "geohistoria",
484+
"document": "documento",
485+
"dashboard": "tablero",
486+
"mapviewer": "visor de mapa"
481487
},
482488
"resourcesCatalog": {
483489
"anonymous": "Cualquiera",

geonode_mapstore_client/static/mapstore/gn-translations/data.fi-FI.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,13 @@
448448
"showPreview": "Show Preview",
449449
"hidePreview": "Hide Preview",
450450
"columnTitle": "Title",
451-
"columnOwner": "Owner"
451+
"columnOwner": "Owner",
452+
"dataset": "dataset",
453+
"map": "map",
454+
"geostory": "geostory",
455+
"document": "document",
456+
"dashboard": "dashboard",
457+
"mapviewer": "mapviewer"
452458
},
453459
"resourcesCatalog": {
454460
"anonymous": "Anyone",

geonode_mapstore_client/static/mapstore/gn-translations/data.fr-FR.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,13 @@
478478
"showPreview": "Afficher l'aperçu",
479479
"hidePreview": "Masquer l'aperçu",
480480
"columnTitle": "Titre",
481-
"columnOwner": "Propriétaire"
481+
"columnOwner": "Propriétaire",
482+
"dataset": "jeu de données",
483+
"map": "carte",
484+
"geostory": "géohistoire",
485+
"document": "document",
486+
"dashboard": "tableau de bord",
487+
"mapviewer": "visionneuse de carte"
482488
},
483489
"resourcesCatalog": {
484490
"anonymous": "N'importe qui",

geonode_mapstore_client/static/mapstore/gn-translations/data.hr-HR.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,13 @@
448448
"showPreview": "Show Preview",
449449
"hidePreview": "Hide Preview",
450450
"columnTitle": "Title",
451-
"columnOwner": "Owner"
451+
"columnOwner": "Owner",
452+
"dataset": "dataset",
453+
"map": "map",
454+
"geostory": "geostory",
455+
"document": "document",
456+
"dashboard": "dashboard",
457+
"mapviewer": "mapviewer"
452458
},
453459
"resourcesCatalog": {
454460
"anonymous": "Anyone",

geonode_mapstore_client/static/mapstore/gn-translations/data.it-IT.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,13 @@
480480
"showPreview": "Mostra Anteprima",
481481
"hidePreview": "Nascondi Anteprima",
482482
"columnTitle": "Titolo",
483-
"columnOwner": "Proprietario"
483+
"columnOwner": "Proprietario",
484+
"dataset": "dataset",
485+
"map": "mappa",
486+
"geostory": "geostory",
487+
"document": "documento",
488+
"dashboard": "dashboard",
489+
"mapviewer": "visualizzatore di mappa"
484490
},
485491
"resourcesCatalog": {
486492
"anonymous": "Chiunque",

0 commit comments

Comments
 (0)