Skip to content

Commit 7bdca3a

Browse files
committed
Fixed method for retrieving locale data
1 parent 7053c5a commit 7bdca3a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/card.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ function getAnimationStyles(
161161
* @returns {Promise<string>} - SVG markup for the statistics card.
162162
*/
163163
export default async function card(data: GetData, uiConfig: UiConfig): Promise<string> {
164-
const fallbackLocale = "en";
165-
const defaultLocale = locales[fallbackLocale];
166-
const selectedLocale = locales[uiConfig.Locale] || defaultLocale;
164+
const getLocale = (locale: string): string => {
165+
return Object.keys(locales).includes(locale) ? locale : "en";
166+
};
167+
const activeLocale = getLocale(uiConfig.Locale);
168+
const selectedLocale = locales[activeLocale];
167169

168170
const isRtl = parseBoolean(selectedLocale.rtlDirection || false);
169171
const isAnimDisabled = parseBoolean(uiConfig.disabledAnimations || uiConfig.Format === "png");

0 commit comments

Comments
 (0)