Skip to content

Commit

Permalink
Fix i18n not working if locale is set to a non-existen language
Browse files Browse the repository at this point in the history
  • Loading branch information
kytta committed Jan 20, 2024
1 parent 3819048 commit 447c877
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/i18n/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import { strings, defaultLanguage, languages } from "./translations";

export function useTranslations(language: string) {
if (!(language in strings)) {
language = defaultLanguage;
}
return function t(
key: keyof (typeof strings)[typeof defaultLanguage],
): string {
Expand Down Expand Up @@ -46,6 +43,9 @@ export function findBestLanguage(): string {
}

export function applyTranslations(language: string) {
if (!(language in strings)) {
language = defaultLanguage;
}
const t = useTranslations(language);

for (const node of document.querySelectorAll("[data-translate]")) {
Expand Down

0 comments on commit 447c877

Please sign in to comment.