-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Would it be possible to add support for flattened city names, where the accents are removed, so we can look up cities irrespective of their accents?
Right now I have a workaround:
When I load:
for (let i = 0; i < cityTimezones.cityMapping.length; i++) {
// eslint-disable-next-line camelcase
(cityTimezones.cityMapping[i] as any).city_flattened
= removeAccents(cityTimezones.cityMapping[i].city_ascii).toLowerCase();
}and then when I lookup:
cityName = removeAccents(cityName).toLowerCase();
cities = CityTimezones.cityMapping;
for (let i = 0; i < cities.length; i++) {
if ((cities[i] as any).city_flattened === cityName) {
return cities[i];
}
}and the implementation for the removeAccents function:
function removeAccents (text: string): string {
return text.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
}Metadata
Metadata
Assignees
Labels
No labels