Skip to content

Commit

Permalink
Fix error when using language English (US) in HA
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Kissling authored and pkissling committed Jan 14, 2023
1 parent 09ba984 commit 3f16b19
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/clock-weather-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,14 @@ export class ClockWeatherCard extends LitElement {
const localeOne = localeParts[0].toLowerCase();
const localeTwo = localeParts[1]?.toUpperCase() || '';
const dateFnsLocale = localeOne + localeTwo;
// HA provides en-US as en
if (dateFnsLocale === 'en') {
return locales.enUS;
}
const importedLocale = locales[dateFnsLocale];
if (!importedLocale) {
console.error('clock-weather-card - Locale not supported: ' + dateFnsLocale)
return locales.enGB
console.error('clock-weather-card - Locale not supported: ' + dateFnsLocale);
return locales.enGB;
}
return importedLocale;
}
Expand Down

0 comments on commit 3f16b19

Please sign in to comment.