File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed
app/src/components/domain/BaseMap Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " go-web-app " : patch
3+ ---
4+
5+ Show admin labels in maps in different languages, potentially fixing [ ##1036 ] ( https://github.com/IFRCGo/go-web-app/issues/1036 )
Original file line number Diff line number Diff line change 1- import { useMemo } from 'react' ;
1+ import {
2+ useContext ,
3+ useMemo ,
4+ } from 'react' ;
5+ import { LanguageContext } from '@ifrc-go/ui/contexts' ;
26import {
37 isDefined ,
48 isFalsyString ,
@@ -12,7 +16,6 @@ import { type SymbolLayer } from 'mapbox-gl';
1216
1317import useCountry from '#hooks/domain/useCountry' ;
1418import {
15- adminLabelLayerOptions ,
1619 defaultMapOptions ,
1720 defaultMapStyle ,
1821 defaultNavControlOptions ,
@@ -98,6 +101,34 @@ function BaseMap(props: Props) {
98101 [ countries ] ,
99102 ) ;
100103
104+ const {
105+ currentLanguage,
106+ } = useContext ( LanguageContext ) ;
107+
108+ const adminLabelLayerOptions : Omit < SymbolLayer , 'id' > = useMemo (
109+ ( ) => {
110+ // ar, es, fr
111+ let label : string ;
112+ if ( currentLanguage === 'es' ) {
113+ label = 'name_es' ;
114+ } else if ( currentLanguage === 'ar' ) {
115+ label = 'name_ar' ;
116+ } else if ( currentLanguage === 'fr' ) {
117+ label = 'name_fr' ;
118+ } else {
119+ label = 'name' ;
120+ }
121+
122+ return {
123+ type : 'symbol' ,
124+ layout : {
125+ 'text-field' : [ 'get' , label ] ,
126+ } ,
127+ } ;
128+ } ,
129+ [ currentLanguage ] ,
130+ ) ;
131+
101132 return (
102133 < Map
103134 mapStyle = { mapStyle ?? defaultMapStyle }
You can’t perform that action at this time.
0 commit comments