Skip to content

Commit

Permalink
add german language (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmintey authored Dec 11, 2024
1 parent 13d520a commit e69e466
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@prisma/client": "^6.0.1",
"@zxcvbn-ts/core": "^3.0.4",
"@zxcvbn-ts/language-common": "^3.0.4",
"@zxcvbn-ts/language-de": "^3.0.2",
"@zxcvbn-ts/language-en": "^3.0.2",
"@zxcvbn-ts/language-es-es": "^3.0.2",
"@zxcvbn-ts/language-fr": "^3.0.2",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/i18n/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
6 changes: 6 additions & 0 deletions src/lib/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const initLang = async () => {
register("es", () => import("../i18n/es.json"));
register("fr", () => import("../i18n/fr.json"));
register("sv", () => import("../i18n/sv.json"));
register("de", () => import("../i18n/de.json"));

await init({
fallbackLocale: defaultLocale,
Expand Down Expand Up @@ -50,3 +51,8 @@ export const getClosestAvailableLocale = (langs: readonly string[]) => {
const $locales = get(locales);
return langs.find((lang) => $locales.find(($locale) => $locale === lang));
};

export const getPrimaryLang = () => {
const lang = get(locale);
return lang?.toLowerCase().split("-")[0];
};
8 changes: 5 additions & 3 deletions src/lib/zxcvbn.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { get } from "svelte/store";
import { locale } from "svelte-i18n";
import { getPrimaryLang } from "./i18n";

export const loadOptions = async () => {
const lang = get(locale);
const langCommon = await import("@zxcvbn-ts/language-common");
const langEn = await import("@zxcvbn-ts/language-en");
let langUser: any;
if (lang?.toLowerCase() === "es-es") {
if (get(locale)?.toLowerCase() === "es-es") {
langUser = await import("@zxcvbn-ts/language-es-es");
} else if (lang?.toLowerCase().split("-")[0]) {
} else if (getPrimaryLang() === "fr") {
langUser = await import("@zxcvbn-ts/language-fr");
} else if (getPrimaryLang() === "de") {
langUser = await import("@zxcvbn-ts/language-de");
}

return {
Expand Down

0 comments on commit e69e466

Please sign in to comment.