Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add german #192

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading