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/
|
||||
-/build/
|
||||
-/.gems/
|
||||
-/packages/typescript/*/src/*.js
|
||||
-/packages/typescript/*/src/**/*.js
|
||||
|
|
|
@ -20,6 +20,10 @@ class Quran {
|
|||
locale: TLocale;
|
||||
surahs: Surah[];
|
||||
|
||||
static get locales(): Array<TLocale> {
|
||||
return ["ar", "en"];
|
||||
}
|
||||
|
||||
constructor(self: TQuran) {
|
||||
this.locale = self.locale;
|
||||
this.surahs = self.surahs;
|
||||
|
|
|
@ -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}/`);
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue