mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix/locale (#277)
* fix/locale * fix: check on lowercase values * fix: remove console logs
This commit is contained in:
		
							parent
							
								
									f66cca468e
								
							
						
					
					
						commit
						0340573199
					
				| @ -17,34 +17,35 @@ const UserProfile = ({ | |||||||
|     logoutUser, |     logoutUser, | ||||||
| }) => { | }) => { | ||||||
|     const [showProfile, setShowProfile] = useState(false); |     const [showProfile, setShowProfile] = useState(false); | ||||||
|  |     const [currentLocale, setCurrentLocale] = useState([]); | ||||||
| 
 | 
 | ||||||
|     const styles = useStyles(); |     const styles = useStyles(); | ||||||
|     const commonStyles = useCommonStyles(); |     const commonStyles = useCommonStyles(); | ||||||
| 
 | 
 | ||||||
|     const [possibleLocales, setPossibleLocales] = useState([ |     const [possibleLocales, setPossibleLocales] = useState([ | ||||||
|         { value: 'en-US', image: 'en-US' }, |         'en-US', | ||||||
|         { value: 'en-GB', image: 'en-GB' }, |         'en-GB', | ||||||
|         { value: 'nb-NO', image: 'nb-NO' }, |         'nb-NO', | ||||||
|         { value: 'sv-SE', image: 'sv-SE' }, |         'sv-SE', | ||||||
|         { value: 'da-DK', image: 'da-DK' }, |         'da-DK', | ||||||
|         { value: 'en-IN', image: 'en-IN' }, |         'en-IN', | ||||||
|         { value: 'de', image: 'de_DE' }, |         'de', | ||||||
|         { value: 'cs', image: 'cs_CZ' }, |         'cs', | ||||||
|         { value: 'pt-BR', image: 'pt_BR' }, |         'pt-BR', | ||||||
|         { value: 'fr-FR', image: 'fr-FR' }, |         'fr-FR', | ||||||
|     ]); |     ]); | ||||||
| 
 | 
 | ||||||
|     useEffect(() => { |     useEffect(() => { | ||||||
|         fetchUser(); |         fetchUser(); | ||||||
| 
 | 
 | ||||||
|         const locale = navigator.language || navigator.userLanguage; |         const locale = navigator.language || navigator.userLanguage; | ||||||
|         let found = possibleLocales.find(l => l.value === locale); |         let found = possibleLocales.find(l => | ||||||
|  |             l.toLowerCase().includes(locale.toLowerCase()) | ||||||
|  |         ); | ||||||
|  |         setCurrentLocale(found); | ||||||
|  | 
 | ||||||
|         if (!found) { |         if (!found) { | ||||||
|             setPossibleLocales(prev => ({ |             setPossibleLocales(prev => [...prev, locale]); | ||||||
|                 ...prev, |  | ||||||
|                 value: locale, |  | ||||||
|                 image: 'unknown-locale', |  | ||||||
|             })); |  | ||||||
|         } |         } | ||||||
|         /* eslint-disable-next-line*/ |         /* eslint-disable-next-line*/ | ||||||
|     }, []); |     }, []); | ||||||
| @ -77,6 +78,8 @@ const UserProfile = ({ | |||||||
|                     possibleLocales={possibleLocales} |                     possibleLocales={possibleLocales} | ||||||
|                     logoutUser={logoutUser} |                     logoutUser={logoutUser} | ||||||
|                     location={location} |                     location={location} | ||||||
|  |                     setCurrentLocale={setCurrentLocale} | ||||||
|  |                     currentLocale={currentLocale} | ||||||
|                 /> |                 /> | ||||||
|             </div> |             </div> | ||||||
|         </OutsideClickHandler> |         </OutsideClickHandler> | ||||||
|  | |||||||
| @ -22,11 +22,12 @@ const UserProfileContent = ({ | |||||||
|     possibleLocales, |     possibleLocales, | ||||||
|     updateSettingLocation, |     updateSettingLocation, | ||||||
|     imageUrl, |     imageUrl, | ||||||
|  |     currentLocale, | ||||||
|  |     setCurrentLocale, | ||||||
|     location, |     location, | ||||||
|     logoutUser, |     logoutUser, | ||||||
| }) => { | }) => { | ||||||
|     const commonStyles = useCommonStyles(); |     const commonStyles = useCommonStyles(); | ||||||
|     const [currentLocale, setCurrentLocale] = useState(location.locale); |  | ||||||
|     const [updatedPassword, setUpdatedPassword] = useState(false); |     const [updatedPassword, setUpdatedPassword] = useState(false); | ||||||
|     const [edititingProfile, setEditingProfile] = useState(false); |     const [edititingProfile, setEditingProfile] = useState(false); | ||||||
|     const styles = useStyles(); |     const styles = useStyles(); | ||||||
| @ -103,11 +104,10 @@ const UserProfileContent = ({ | |||||||
|                                         > |                                         > | ||||||
|                                             Date/Time formatting |                                             Date/Time formatting | ||||||
|                                         </InputLabel> |                                         </InputLabel> | ||||||
| 
 |  | ||||||
|                                         <Select |                                         <Select | ||||||
|                                             id="locale-select" |                                             id="locale-select" | ||||||
|                                             native |  | ||||||
|                                             value={currentLocale || ''} |                                             value={currentLocale || ''} | ||||||
|  |                                             native | ||||||
|                                             onChange={handleChange} |                                             onChange={handleChange} | ||||||
|                                             MenuProps={{ |                                             MenuProps={{ | ||||||
|                                                 style: { |                                                 style: { | ||||||
| @ -118,10 +118,10 @@ const UserProfileContent = ({ | |||||||
|                                             {possibleLocales.map(locale => { |                                             {possibleLocales.map(locale => { | ||||||
|                                                 return ( |                                                 return ( | ||||||
|                                                     <option |                                                     <option | ||||||
|                                                         key={locale.value} |                                                         key={locale} | ||||||
|                                                         value={locale.value} |                                                         value={locale} | ||||||
|                                                     > |                                                     > | ||||||
|                                                         {locale.value} |                                                         {locale} | ||||||
|                                                     </option> |                                                     </option> | ||||||
|                                                 ); |                                                 ); | ||||||
|                                             })} |                                             })} | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user