Spaces:
Configuration error
Configuration error
Download src/components/hooks/useRegionNames.ts from SreejithSHR/umami: direct link, hf CLI and curl.
- Browser
- Download file 615 Bytes
-
https://huggingface.co/spaces/SreejithSHR/umami/resolve/main/src/components/hooks/useRegionNames.ts
- Command line
-
hf download hf://spaces/SreejithSHR/umami/src/components/hooks/useRegionNames.ts
-
curl -L -o useRegionNames.ts https://huggingface.co/spaces/SreejithSHR/umami/resolve/main/src/components/hooks/useRegionNames.ts
615 Bytes
| import useCountryNames from './useCountryNames'; | |
| import regions from '../../../public/iso-3166-2.json'; | |
| export function useRegionNames(locale: string) { | |
| const { countryNames } = useCountryNames(locale); | |
| const getRegionName = (regionCode: string, countryCode?: string) => { | |
| if (!countryCode) { | |
| return regions[regionCode]; | |
| } | |
| const region = regionCode.includes('-') ? regionCode : `${countryCode}-${regionCode}`; | |
| return regions[region] ? `${regions[region]}, ${countryNames[countryCode]}` : region; | |
| }; | |
| return { regionNames: regions, getRegionName }; | |
| } | |
| export default useRegionNames; | |