-
Notifications
You must be signed in to change notification settings - Fork 370
Local support #523
Local support #523
Changes from 1 commit
ef3acc2
465ef5a
c7e1f1f
ff4c393
e722edc
d5102a5
564a3e4
8d77638
9058a4f
70d0276
161ff10
b87506b
2bf0186
11afb12
dbfeeb8
1002dde
85f7eeb
2979a75
18f3a01
18c392a
aae5118
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import Row from 'react-bootstrap/lib/Row'; | |
| import Col from 'react-bootstrap/lib/Col'; | ||
|
|
||
| import LocaleFormattedMessage from 'components/LocaleFormattedMessage'; | ||
| import LocaleSwitcher from 'components/LocaleSwitcher' | ||
|
|
||
| const styles = require('./style.scss'); | ||
|
|
||
|
|
@@ -15,7 +16,7 @@ const Footer = () => ( | |
| <Col md={10} mdOffset={1}> | ||
| <Row> | ||
| <Col md={2} sm={4} xs={12} className={styles.about}> | ||
| <p>Navigate</p> | ||
| <p className={styles.header}>Navigate</p> | ||
| <ul className={`source-sans ${styles.list}`}> | ||
| <li> | ||
| <Link to="/about"> | ||
|
|
@@ -43,8 +44,9 @@ const Footer = () => ( | |
| </li> | ||
| </ul> | ||
| </Col> | ||
|
|
||
| <Col md={3} sm={4} xs={12} className={styles.links}> | ||
| <p> | ||
| <p className={styles.header}> | ||
| <LocaleFormattedMessage | ||
| id={'nav.usefulSites'} | ||
| defaultMessage={'USEFUL SITES'} | ||
|
|
@@ -61,8 +63,9 @@ const Footer = () => ( | |
| </li> | ||
| </ul> | ||
| </Col> | ||
|
|
||
| <Col md={3} sm={4} xs={12} className={styles.links}> | ||
| <p> | ||
| <p className={styles.header}> | ||
| <LocaleFormattedMessage | ||
| id={'nav.otherLinks'} | ||
| defaultMessage={'Other links'} | ||
|
|
@@ -90,15 +93,27 @@ const Footer = () => ( | |
| </li> | ||
| </ul> | ||
| </Col> | ||
|
|
||
| <Col md={4} sm={12} xs={12} className={styles.links}> | ||
| <p className="monserrat"> | ||
| <p className={styles.header}> | ||
| <LocaleFormattedMessage | ||
| id={'nav.aboutQuranProject'} | ||
| defaultMessage={'Quran.com (also known as The Noble Quran, Al Quran, Holy Quran, Koran) is a pro bono project.'} | ||
| id={'local.selectLabel'} | ||
| defaultMessage={'Site Language'} | ||
| /> | ||
| </p> | ||
|
|
||
| <p className="monserrat">© QURAN.COM. ALL RIGHTS RESERVED 2016</p> | ||
| <div className={styles.list}> | ||
| <LocaleSwitcher/> | ||
|
|
||
| <p className="monserrat"> | ||
| <LocaleFormattedMessage | ||
| id={'nav.aboutQuranProject'} | ||
| defaultMessage={'Quran.com (also known as The Noble Quran, Al Quran, Holy Quran, Koran) is a pro bono project.'} | ||
| /> | ||
| </p> | ||
|
|
||
| <p className="monserrat">© QURAN.COM. ALL RIGHTS RESERVED 2016</p> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be translated?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, we need to translate this and other static pages. Next PR, it was already became huge. |
||
| </div> | ||
| </Col> | ||
| </Row> | ||
| </Col> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import React, { Component, PropTypes } from "react"; | ||
|
|
||
| import { locales, defaultLocale } from "../../config"; | ||
| import cookie from 'react-cookie'; | ||
| import LocaleFormattedMessage from 'components/LocaleFormattedMessage'; | ||
|
|
||
| export default class LocaleSwitcher extends Component { | ||
| state = { | ||
| currentLocale: defaultLocale, | ||
| }; | ||
|
|
||
| componentDidMount() { | ||
| if (__CLIENT__) { | ||
| this.setState({currentLocale: cookie.load('currentLocale') || defaultLocale}); | ||
| } | ||
| } | ||
|
|
||
| handleLocaleClick(locale, e) { | ||
| e.preventDefault(); | ||
| let expireDate = new Date(); | ||
| expireDate.setYear(expireDate.getFullYear()+1); | ||
|
|
||
| this.setState({currentLocale: locale}); | ||
|
|
||
| cookie.save('currentLocale', locale, { | ||
| path: '/', | ||
| expires: new Date(expireDate), | ||
| }); | ||
|
|
||
| window.location.reload(); | ||
| } | ||
|
|
||
| renderLocaleLink(locale, native) { | ||
|
|
||
| let className = "local-switch-link"; | ||
| if (locale === this.state.currentLocale) { | ||
| className = `btn ${className} ${className}-active`; | ||
| } | ||
|
|
||
| return ( | ||
| <a key={ locale } | ||
| className={className} | ||
| onClick={ this.handleLocaleClick.bind(this, locale) } | ||
| href={ `?local=${locale}` } | ||
| > | ||
| { locales[locale] } | ||
| </a> | ||
| ); | ||
| } | ||
|
|
||
| render() { | ||
| const keys = Object.keys(locales); | ||
|
|
||
| return ( | ||
| <div className='local-switcher'> | ||
| <p> | ||
| <LocaleFormattedMessage id={'local.changeLocal'} defaultMessage={'Choose language '} /> | ||
| </p> | ||
|
|
||
| { keys.map(this.renderLocaleLink, this) } | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .local-switcher{ | ||
| color: red; | ||
| } | ||
| .local-switch-link{ | ||
|
|
||
| } | ||
|
|
||
| .local-switch-link-active{ | ||
| color: #2CA4AB; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import config from "../config"; | ||
| import cookie from 'react-cookie'; | ||
|
|
||
| export function getLocalMessages(req) { | ||
| let currentLocal; | ||
| let expireDate = new Date(); | ||
| expireDate.setYear(expireDate.getFullYear()+1); | ||
|
||
| const availableLocals = Object.keys(config.locales); | ||
|
|
||
| if (req && req.query.local) { | ||
| currentLocal = req.query.local; | ||
| } | ||
| else{ | ||
|
||
| currentLocal = cookie.load('currentLocale'); | ||
| } | ||
|
|
||
| if(availableLocals.indexOf(currentLocal) == -1){ | ||
|
||
| currentLocal = config.defaultLocale; | ||
| } | ||
|
|
||
| cookie.save('currentLocale', currentLocal, { | ||
| path: '/', | ||
| expires: new Date(expireDate), | ||
| }); | ||
|
|
||
| let localeData = require('../locale/'+currentLocal+'.js'); | ||
|
||
|
|
||
| return localeData.messages; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| // jscs:disable disallowQuotedKeysInObjects | ||
| export default { | ||
| messages: { | ||
| "local": "arabic", | ||
| "local.changeLocal": 'اختر اللغة التي تود عرض الموقع بها', | ||
| "local.navtiveName": 'العربية', | ||
| "local.selectLabel": 'اللغة', | ||
| "setting.title": "اختیارات", | ||
| "setting.surahs": "سورة", | ||
| "setting.verses": "آیت منتخب کریں", | ||
| "setting.reciters": "قاری منتخب کریں", | ||
| "setting.translations.title": "ترجمے", | ||
| "setting.translations.removeAll": "سب کو ہٹا دیں", | ||
| "setting.translations.english": "انگریزی", | ||
| "setting.translations.other": "دوسری زبانیں", | ||
| "setting.fontSize": "حرف کا سائز", | ||
| "setting.fontSize.arabic": "عربی", | ||
| "setting.reading": "پڑہائی", | ||
| "setting.tooltip": "لفظ کے اوپر", | ||
| "setting.tooltip.title": "لفظ کے اوپر کیا ہو", | ||
| "setting.tooltip.translation": "ترجمہ", | ||
| "setting.tooltip.transliteration": "تلفظ", | ||
| "setting.nightMode": "رات کا وقت", | ||
| "setting.nightMode.dayTip": "دن کے موڈ میں دیکھیں", | ||
| "setting.nightMode.nightTip": "رات کے موڈ میں دیکھیں", | ||
|
|
||
| "ayah.media.lectureFrom": "{from} کے لیکچرو دیکھے", | ||
|
|
||
| "search.placeholder": "تلاش کر یں", | ||
| "search.resultHeading": "{from}-{to} OF <span> {total} </span> SEARCH RESULTS FOR: <span>{query}</span>", | ||
|
||
| "search.error": "معذرت، آپ کی تلاش کے ساتھ ایک خرابی پیش آگئی.", | ||
| "search.noResult": "کوئی نتیجہ نہیں ملا", | ||
|
|
||
| "surah.next": "اگلی سورت", | ||
| "surah.previous": "پچھلی سورت", | ||
| "surah.info": "سورہ کی معلومات", | ||
| "surah.index.heading": "سورتیں", | ||
| "surah.index.quickLinks": "فوری لنک", | ||
| "surah.goToBeginning": "سورہ کے شروع میں جائیں", | ||
|
|
||
| "player.currentAyah": "آیت", | ||
| "player.nextAyah": "اگلی آیت", | ||
| "player.previousAyah": "پچھلی آیت", | ||
| "player.repeat.title": " دہرائیں", | ||
| "player.repeat.single": "اکیلی آیت", | ||
| "player.repeat.range": "مخصوص آیات", | ||
| "player.repeat.rangeStart": "سے", | ||
| "player.repeat.rangeEnd": "تک", | ||
| "player.repeat.times": "کتنی بار", | ||
| "player.repeat.loop": "چلاتے رہو", | ||
| "player.scrollButtonTip": "جو آیت چل رہیی ہو اس کو صفہ پر سامنے رکھو", | ||
|
|
||
| "app.loading": "لوڈ ہو رہا ہے", | ||
| "actions.copy": "کاپی", | ||
| "actions.copied": "کاپی کر لیا", | ||
| "actions.play": "چلاو", | ||
| "actions.pause": "روک دیں", | ||
|
|
||
| "nav.contribute": "تعاون کریں", | ||
| "nav.aboutUs": "ہمارے متعلق", | ||
| "nav.developers": "ڈویلپرز", | ||
| "nav.usefulSites": "مفید سائٹس", | ||
| "nav.otherLinks": "دیگر لنکس", | ||
| "nav.contactUs": "ہم سے رابطہ", | ||
| "nav.aboutQuranProject": "قرآن کریم ایک فلاں عامہ (عوامی بہبود کے لئے) منصوبہ ہے", | ||
| "nav.mobile": "موبائل", | ||
| "nav.legacySite": "پرانی سائٹ" | ||
| } | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requires translation please :)