diff --git a/.projectile b/.projectile index fc38a1a..42e5b5a 100644 --- a/.projectile +++ b/.projectile @@ -2,3 +2,5 @@ -/tmp/ -/build/ -/.gems/ +-/packages/typescript/*/src/*.js +-/packages/typescript/*/src/**/*.js diff --git a/packages/typescript/Quran/src/index.ts b/packages/typescript/Quran/src/index.ts index a0e9ab1..51a9701 100644 --- a/packages/typescript/Quran/src/index.ts +++ b/packages/typescript/Quran/src/index.ts @@ -20,6 +20,10 @@ class Quran { locale: TLocale; surahs: Surah[]; + static get locales(): Array { + return ["ar", "en"]; + } + constructor(self: TQuran) { this.locale = self.locale; this.surahs = self.surahs; diff --git a/src/js/main/redirect.ts b/src/js/main/redirect.ts index 1efbde0..1d50fa3 100644 --- a/src/js/main/redirect.ts +++ b/src/js/main/redirect.ts @@ -1,12 +1,8 @@ +import { Quran, TLocale } from "Quran"; (function () { - const LOCALES = ["ar", "en"]; - const DEFAULT_LOCALE = "en"; - function getUserLocale() { - return ( - navigator.languages - .map(s => s.slice(0, 2)) - .find(s => LOCALES.includes(s)) || DEFAULT_LOCALE - ); - } - location.replace(["", getUserLocale(), ""].join("/")); + const defaultl = "en"; + const locale = navigator.languages + .map(s => s.slice(0, 2).toLowerCase()) + .find(s => Quran.locales.includes(s as TLocale)) || defaultl; + location.replace(`/${locale}/`); })();