Skip to content

Commit cfb6b34

Browse files
committed
fix hardcoded langs code
1 parent ec64ea5 commit cfb6b34

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

geonode_mapstore_client/client/js/plugins/MetadataEditor/components/_widgets/TextWidgetMultiLang.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ const TextWidgetMultiLang = (props) => {
1919
const id = props.id || Math.random().toString(36).substring(7);
2020
const { title, description } = schema;
2121

22-
// TODO map langs from schema when iso lang is change to 2 chars https://github.com/GeoNode/geonode/issues/13643#issuecomment-3728578749
23-
const languages = ["en", "hy", "ru"];
22+
const languages = Object.keys(schema?.properties);
23+
const languageLabels = languages.reduce((acc, lang) => {
24+
const label = schema?.properties?.[lang]?.['geonode:multilang-lang-label'] || lang;
25+
acc[lang] = label;
26+
return acc;
27+
}, {});
28+
2429
const languageLong = (langCode) => {
25-
return {
26-
en: "English",
27-
hy: "Armenian",
28-
ru: "Russian"
29-
}[langCode] || langCode.toUpperCase();
30+
return languageLabels[langCode] || langCode;
3031
};
3132

3233
const isTextarea = schema?.['ui:options']?.widget === 'textarea';

0 commit comments

Comments
 (0)