24709.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. "use strict";
  2. exports.id = 24709;
  3. exports.ids = [24709];
  4. exports.modules = {
  5. /***/ 24709:
  6. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  7. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  8. /* harmony export */ "A3": () => (/* binding */ getOpenGraphLocale),
  9. /* harmony export */ "Dl": () => (/* binding */ getLocaleNameByFullName),
  10. /* harmony export */ "J_": () => (/* binding */ getLocaleName),
  11. /* harmony export */ "K8": () => (/* binding */ toLocalizedDate),
  12. /* harmony export */ "Sj": () => (/* binding */ toLocalizedVersesRange),
  13. /* harmony export */ "Tj": () => (/* binding */ toLocalizedVerseKey),
  14. /* harmony export */ "XP": () => (/* binding */ getDir),
  15. /* harmony export */ "iS": () => (/* binding */ isRTLLocale),
  16. /* harmony export */ "ic": () => (/* binding */ getLangFullLocale),
  17. /* harmony export */ "j2": () => (/* binding */ getLanguageDataById),
  18. /* harmony export */ "qc": () => (/* binding */ getLanguageAlternates),
  19. /* harmony export */ "rQ": () => (/* binding */ toLocalizedNumber),
  20. /* harmony export */ "uP": () => (/* binding */ shouldUseMinimalLayout),
  21. /* harmony export */ "zi": () => (/* binding */ findLanguageIdByLocale)
  22. /* harmony export */ });
  23. /* unused harmony exports LANG_LOCALE_MAP, Direction, Languages, getLanguageDirectionById, getLanguageFontById, localizeNumericalStringWithSplitter, getOpenGraphAlternateLocales, toLocalizedMonthName */
  24. /* harmony import */ var lodash_findKey__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12372);
  25. /* harmony import */ var lodash_findKey__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_findKey__WEBPACK_IMPORTED_MODULE_0__);
  26. /* harmony import */ var _i18n_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(50608);
  27. /* harmony import */ var _url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(69663);
  28. /* eslint-disable max-lines */ /* eslint-disable import/prefer-default-export */
  29. const RTL_LOCALES = [
  30. "ar",
  31. "fa",
  32. "ur"
  33. ];
  34. const LOCALE_NAME = {
  35. en: "English",
  36. ar: "العربية",
  37. bn: "বাংলা",
  38. fa: "فارسی",
  39. fr: "Fran\xe7ais",
  40. id: "Indonesia",
  41. it: "Italiano",
  42. nl: "Dutch",
  43. pt: "Portugu\xeas",
  44. ru: "русский",
  45. sq: "Shqip",
  46. th: "ภาษาไทย",
  47. tr: "T\xfcrk\xe7e",
  48. ur: "اردو",
  49. zh: "简体中文",
  50. ms: "Melayu",
  51. de: "Deutsch",
  52. inh: "ʁəlʁɑj mot",
  53. ta: "தமிழ்",
  54. hi: "हिन्दी",
  55. ku: "Kurd\xee"
  56. };
  57. const LOCALE_NAME_TO_CODE = {
  58. bengali: "bn",
  59. english: "en",
  60. arabic: "ar",
  61. russian: "ru",
  62. urdu: "ur",
  63. Kurdish: "ku"
  64. };
  65. const LANG_LOCALE_MAP = {
  66. en: "en-US",
  67. ar: "ar-EG",
  68. bn: "bn-BD",
  69. fa: "fa-IR",
  70. fr: "fr-FR",
  71. id: "id-ID",
  72. it: "it-IT",
  73. nl: "nl-NL",
  74. pt: "pt-BR",
  75. ru: "ru-RU",
  76. sq: "sq-AL",
  77. th: "th-TH",
  78. tr: "tr-TR",
  79. ur: "ur-PK",
  80. zh: "zh-CN",
  81. ms: "ms-MY"
  82. };
  83. var Direction;
  84. (function(Direction) {
  85. Direction["LTR"] = "ltr";
  86. Direction["RTL"] = "rtl";
  87. })(Direction || (Direction = {}));
  88. const Languages = {
  89. 9: {
  90. // Arabic,
  91. dir: Direction.RTL,
  92. locale: "ar"
  93. },
  94. 20: {
  95. // Bengali
  96. locale: "bn"
  97. },
  98. 34: {
  99. font: "divehi",
  100. locale: "dv",
  101. dir: Direction.RTL
  102. },
  103. 38: {
  104. // English
  105. locale: "en"
  106. },
  107. 43: {
  108. // Persian/Farsi
  109. dir: Direction.RTL,
  110. locale: "fa"
  111. },
  112. 49: {
  113. // French
  114. locale: "fr"
  115. },
  116. 59: {
  117. // Hebrew
  118. dir: Direction.RTL,
  119. locale: "he"
  120. },
  121. 67: {
  122. // Indonesian
  123. locale: "id"
  124. },
  125. 74: {
  126. // Italian
  127. locale: "it"
  128. },
  129. 89: {
  130. font: "kurdish",
  131. locale: "ku",
  132. dir: Direction.RTL
  133. },
  134. 133: {
  135. // Portuguese
  136. locale: "pt"
  137. },
  138. 118: {
  139. // Dutch
  140. locale: "nl"
  141. },
  142. 138: {
  143. // Russian
  144. locle: "ru"
  145. },
  146. 151: {
  147. // Albanian
  148. locale: "sq"
  149. },
  150. 161: {
  151. // Thai
  152. locale: "th"
  153. },
  154. 172: {
  155. // Uyghur/Uighur
  156. dir: Direction.RTL,
  157. locale: "ug"
  158. },
  159. 174: {
  160. font: "urdu",
  161. dir: Direction.RTL,
  162. locale: "ur"
  163. },
  164. 185: {
  165. // Chinese
  166. locale: "zh"
  167. }
  168. };
  169. /**
  170. * Check whether the locale should have a minimalLayout. This will be reflect in
  171. * certain components like ChapterHeader or SurahPreviewRow and the reason we need
  172. * this is that for Arabic for example, we the transliteratedName and translatedName
  173. * have the same value which will result in redundant UI.
  174. *
  175. * @param {string} lang
  176. * @returns {boolean}
  177. */ const shouldUseMinimalLayout = (lang)=>{
  178. return lang === "ar";
  179. };
  180. /**
  181. * Check whether the current locale is RTL.
  182. *
  183. * @param {string} locale
  184. * @returns {boolean}
  185. */ const isRTLLocale = (locale)=>RTL_LOCALES.includes(locale);
  186. /**
  187. * Gir the dir of the element based on the locale.
  188. *
  189. * @param {string} locale
  190. * @returns {string}
  191. */ const getDir = (locale)=>isRTLLocale(locale) ? Direction.RTL : Direction.LTR;
  192. /**
  193. * Get direction and font name of language by language id
  194. *
  195. * @param {number} languageId
  196. * @returns {LanguageData}
  197. */ const getLanguageDataById = (languageId)=>{
  198. const lang = Languages[languageId];
  199. return {
  200. font: lang?.font,
  201. direction: lang?.dir || Direction.LTR,
  202. code: lang?.locale || "en"
  203. };
  204. };
  205. /**
  206. * Get direction of language by language id
  207. *
  208. * @param {number} languageId
  209. * @returns {string}
  210. */ const getLanguageDirectionById = (languageId)=>{
  211. const mapping = Languages[languageId];
  212. return mapping?.dir || Direction.LTR;
  213. };
  214. /**
  215. * Get font face name of language by language id
  216. *
  217. * @param {number} languageId
  218. * @returns {string}
  219. */ const getLanguageFontById = (languageId)=>{
  220. const mapping = Languages[languageId];
  221. return mapping?.font;
  222. };
  223. /**
  224. * Find language Id by its locale
  225. *
  226. * @param {string} locale
  227. * @returns {number} language id
  228. */ const findLanguageIdByLocale = (locale)=>{
  229. return Number(lodash_findKey__WEBPACK_IMPORTED_MODULE_0___default()(Languages, {
  230. locale
  231. }));
  232. };
  233. /**
  234. * Generate the language alternates of a given path so that Search Engines can
  235. * recommend the alternate page to the users based on their region/locale.
  236. *
  237. * @see https://developers.google.com/search/docs/advanced/crawling/localized-versions
  238. * @param {string} path
  239. * @returns {LinkLanguageAlternate[]}
  240. */ const getLanguageAlternates = (path)=>{
  241. const { locales } = _i18n_json__WEBPACK_IMPORTED_MODULE_1__;
  242. const basePath = (0,_url__WEBPACK_IMPORTED_MODULE_2__/* .getBasePath */ .bv)();
  243. return locales.map((locale)=>({
  244. hrefLang: locale,
  245. href: `${basePath}/${locale}${path === "/" ? "" : path}`
  246. })).concat({
  247. hrefLang: "x-default",
  248. href: `${basePath}${path}`
  249. });
  250. };
  251. /**
  252. * Get the locale name.
  253. *
  254. * @param {string} locale
  255. * @returns {string}
  256. */ const getLocaleName = (locale)=>LOCALE_NAME[locale];
  257. /**
  258. * Converts a locale name e.g. 'english' to its code e.g. 'en'.
  259. *
  260. * @param {string} fullName
  261. * @returns {string}
  262. */ const getLocaleNameByFullName = (fullName)=>LOCALE_NAME[LOCALE_NAME_TO_CODE[fullName]];
  263. /**
  264. * Takes a number and returns a localized string based on the provided locale.
  265. *
  266. * @param {number} value
  267. * @param {string} locale
  268. * @param {boolean} showLeadingZero
  269. * @param {Intl.NumberFormatOptions} options
  270. * @returns {string}
  271. */ // Intl.NumberFormat is performance heavy so we are caching the formatter.
  272. const numberFormatters = new Map();
  273. let currentLanguageLocale = null;
  274. const toLocalizedNumber = (value, locale, showLeadingZero = false, options = undefined)=>{
  275. // we do this because an empty object will result in a new formatter being created everytime since we don't have it's reference.
  276. const formatterKey = options ?? "DEFAULT_OPTIONS";
  277. if (numberFormatters.has(formatterKey) && currentLanguageLocale === locale) {
  278. return getFormattedNumber(numberFormatters.get(formatterKey), value, showLeadingZero);
  279. }
  280. currentLanguageLocale = locale;
  281. const fullLocale = LANG_LOCALE_MAP[locale];
  282. const newNumberFormatter = new Intl.NumberFormat(fullLocale, options);
  283. numberFormatters.set(formatterKey, newNumberFormatter);
  284. return getFormattedNumber(newNumberFormatter, value, showLeadingZero);
  285. };
  286. /**
  287. * Get the formatted localized number. This either returns
  288. * the original value or prepends a leading 0 to the beginning
  289. * of the string if it's allowed and the value is below 10.
  290. *
  291. * @param {Intl.NumberFormat} formatter
  292. * @param {number} value
  293. * @param {boolean} showLeadingZero
  294. * @returns {string}
  295. */ const getFormattedNumber = (formatter, value, showLeadingZero)=>{
  296. const formattedNumber = formatter.format(value);
  297. if (!showLeadingZero || value >= 10) {
  298. return formattedNumber;
  299. }
  300. return `${formatter.format(0)}${formattedNumber}`;
  301. };
  302. /**
  303. * Get the full locale name with lang + country e.g. ar-SA or en-US.
  304. *
  305. * @param {string} locale
  306. * @returns {string}
  307. */ const getLangFullLocale = (locale)=>LANG_LOCALE_MAP[locale];
  308. /**
  309. * Takes a date and returns a localized string based on the provided locale and options.
  310. *
  311. * @param {number} value
  312. * @param {string} locale
  313. * @param {Intl.DateTimeFormatOptions} options
  314. * @returns {string}
  315. */ const toLocalizedDate = (value, locale, options = {})=>{
  316. const fullLocale = LANG_LOCALE_MAP[locale];
  317. return new Intl.DateTimeFormat(fullLocale, options).format(value);
  318. };
  319. /**
  320. * Localize a string that contains 2 numbers with a splitter in between
  321. * e.g. "2:55" or "2-5".
  322. *
  323. * @param {string} string
  324. * @param {string} lang
  325. * @param {string} splitter
  326. * @returns {string}
  327. */ const localizeNumericalStringWithSplitter = (string, lang, splitter = ":")=>string.split(splitter).map((value)=>toLocalizedNumber(Number(value), lang)).join(splitter);
  328. /**
  329. * Get the localized value of the verse key.
  330. *
  331. * @param {string} verseKey
  332. * @param {string} lang
  333. * @returns {string}
  334. */ const toLocalizedVerseKey = (verseKey, lang)=>localizeNumericalStringWithSplitter(verseKey, lang);
  335. /**
  336. * Get the localized value of a range e.g. "1-20"
  337. *
  338. * @param {string} range
  339. * @param {string} lang
  340. * @returns {string}
  341. */ const toLocalizedVersesRange = (range, lang)=>localizeNumericalStringWithSplitter(range, lang, "-");
  342. /**
  343. * Generate the locale by mapping the current iso language to
  344. * the format that Facebook accepts @see https://developers.facebook.com/docs/javascript/internationalization#locales .
  345. * Since LANG_LOCALE_MAP has the following format LL-CC, we need to convert it into LL_CC
  346. * be replacing "-" with "_".
  347. *
  348. * @param {string} currentLocale
  349. * @returns {string}
  350. */ const getOpenGraphLocale = (currentLocale)=>`${LANG_LOCALE_MAP[currentLocale]}`.replace("-", "_");
  351. /**
  352. * Generate the alternate locales that the current content can be served in.
  353. * When Facebook needs to render an object in one of the specified locales,
  354. * it will make a request to the URL with the fb_locale URL parameter.
  355. *
  356. * @see https://developers.facebook.com/blog/post/2013/11/11/605/
  357. *
  358. * @param {string} currentLocale
  359. * @returns {MetaTag[]}
  360. */ const getOpenGraphAlternateLocales = (currentLocale)=>{
  361. return Object.keys(LANG_LOCALE_MAP).filter((languageCode)=>languageCode !== currentLocale).map((languageCode)=>({
  362. name: "og:locale:alternate",
  363. content: `${LANG_LOCALE_MAP[languageCode]}`.replace("-", "_")
  364. }));
  365. };
  366. /**
  367. * Convert a month number to the corresponding localized month name.
  368. *
  369. * @param {number} monthNumber
  370. * @param {string} locale
  371. * @returns {string}
  372. */ const toLocalizedMonthName = (monthNumber, locale)=>{
  373. const objDate = new Date();
  374. objDate.setDate(1);
  375. objDate.setMonth(monthNumber - 1);
  376. return objDate.toLocaleString(locale, {
  377. month: "long"
  378. });
  379. };
  380. /***/ }),
  381. /***/ 69663:
  382. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  383. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  384. /* harmony export */ "Jz": () => (/* binding */ getCurrentPath),
  385. /* harmony export */ "R": () => (/* binding */ navigateToExternalUrl),
  386. /* harmony export */ "Yj": () => (/* binding */ getWindowOrigin),
  387. /* harmony export */ "bv": () => (/* binding */ getBasePath),
  388. /* harmony export */ "vv": () => (/* binding */ getAuthApiPath)
  389. /* harmony export */ });
  390. const getLocalePostfix = (locale)=>locale !== "en" ? `/${locale}` : "";
  391. const getCurrentPath = ()=>{
  392. if (false) {}
  393. return "";
  394. };
  395. const getWindowOrigin = (locale)=>{
  396. if (false) {}
  397. return "";
  398. };
  399. /**
  400. * Navigate programmatically to an external url. we will try to open
  401. * the url in a new tab and if it doesn't work due to pop-ups being blocked,
  402. * we will open the url in the current tab.
  403. *
  404. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/open#return_value
  405. *
  406. * @param {string} url
  407. */ const navigateToExternalUrl = (url)=>{
  408. if (false) {}
  409. };
  410. /**
  411. * Get the base path of the current deployment on Vercel/local machine
  412. * e.g. http://localhost
  413. * or https://quran-com-ebqc5a2d5-qurancom.vercel.app this is needed
  414. * if we want to construct a full path e.g. when we add alternate languages
  415. * meta tags.
  416. *
  417. * @see https://vercel.com/docs/concepts/projects/environment-variables
  418. * @returns {string}
  419. */ const getBasePath = ()=>`${process.env.NEXT_PUBLIC_VERCEL_ENV === "development" ? "http" : "https"}://${process.env.NEXT_PUBLIC_VERCEL_URL}`;
  420. /**
  421. * Get the auth api path.
  422. *
  423. * @param {string} path
  424. * @returns {string}
  425. */ const getAuthApiPath = (path)=>`${process.env.NEXT_PUBLIC_AUTH_BASE_URL}/${path}`;
  426. /***/ }),
  427. /***/ 50608:
  428. /***/ ((module) => {
  429. module.exports = JSON.parse('{"locales":["en","ar","bn","fa","fr","id","it","nl","pt","ru","sq","th","tr","ur","zh","ms"],"defaultLocale":"en","pages":{"*":["common","error","radio","quick-links","onboarding"],"/":["home","radio","collection","reading-goal","reciter"],"/reading-goal":["reading-goal","reciter"],"/my-learning-plans":["learn"],"/learning-plans":["learn"],"/learning-plans/[slug]":["learn"],"/learning-plans/[slug]/lessons/[lessonSlugOrId]":["learn"],"/reading-goal/progress":["reading-goal","reading-progress"],"/[chapterId]":["quran-reader","reading-goal","notes","chapter","surah-info"],"/[chapterId]/reflections":["quran-reader","reading-goal","notes"],"/[chapterId]/[verseId]":["quran-reader","reading-goal","notes"],"/[chapterId]/[verseId]/tafsirs":["quran-reader","reading-goal","notes"],"/page/[pageId]":["quran-reader","reading-goal","notes"],"/juz/[juzId]":["quran-reader","reading-goal","notes"],"/hizb/[hizbId]":["quran-reader","reading-goal","notes"],"/surah/[chapterId]/info":["surah-info"],"/chapter_info/[chapterId]":["surah-info"],"/surah-info/[chapterId]":["surah-info"],"/collections/all":["collection"],"/collections/[collectionId]":["collection"],"/search":["search"],"/about-us":["about"],"/developers":["developers"],"/privacy":["privacy"],"/rub/[rubId]":["quran-reader","reading-goal","notes"],"/support":["support"],"/tajweed-colors":["tajweed"],"/product-updates":["product-updates"],"/product-updates/[id]":["product-updates"],"/apps":["apps"],"/radio":["home","radio"],"/reciters/[reciterId]":["home","radio","reciter"],"/reciters/[reciterId]/[chapterId]":["reciter"],"/reciters":["reciter","home"],"/profile":["home","profile","collection","quran-reader"],"/login":["login"],"/about-the-quran":["about-quran"],"/notes-and-reflections":["notes"],"/ramadan-activities":["ramadan-activities"],"/notification-settings":["notification-settings"],"/calendar":["quranic-calendar"]}}');
  430. /***/ })
  431. };
  432. ;
  433. //# sourceMappingURL=24709.js.map