Add Quran.locales
This commit is contained in:
parent
fcb7aa391a
commit
deae96fc4b
3 changed files with 12 additions and 10 deletions
|
@ -2,3 +2,5 @@
|
||||||
-/tmp/
|
-/tmp/
|
||||||
-/build/
|
-/build/
|
||||||
-/.gems/
|
-/.gems/
|
||||||
|
-/packages/typescript/*/src/*.js
|
||||||
|
-/packages/typescript/*/src/**/*.js
|
||||||
|
|
|
@ -20,6 +20,10 @@ class Quran {
|
||||||
locale: TLocale;
|
locale: TLocale;
|
||||||
surahs: Surah[];
|
surahs: Surah[];
|
||||||
|
|
||||||
|
static get locales(): Array<TLocale> {
|
||||||
|
return ["ar", "en"];
|
||||||
|
}
|
||||||
|
|
||||||
constructor(self: TQuran) {
|
constructor(self: TQuran) {
|
||||||
this.locale = self.locale;
|
this.locale = self.locale;
|
||||||
this.surahs = self.surahs;
|
this.surahs = self.surahs;
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
|
import { Quran, TLocale } from "Quran";
|
||||||
(function () {
|
(function () {
|
||||||
const LOCALES = ["ar", "en"];
|
const defaultl = "en";
|
||||||
const DEFAULT_LOCALE = "en";
|
const locale = navigator.languages
|
||||||
function getUserLocale() {
|
.map(s => s.slice(0, 2).toLowerCase())
|
||||||
return (
|
.find(s => Quran.locales.includes(s as TLocale)) || defaultl;
|
||||||
navigator.languages
|
location.replace(`/${locale}/`);
|
||||||
.map(s => s.slice(0, 2))
|
|
||||||
.find(s => LOCALES.includes(s)) || DEFAULT_LOCALE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
location.replace(["", getUserLocale(), ""].join("/"));
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue