Finalized language handover.
This commit is contained in:
		| @@ -38,36 +38,33 @@ class Language { | ||||
|  | ||||
|   setLanguage(lang) { | ||||
|     this.langName = lang; | ||||
|     this.data = LANGUAGES[lang]; | ||||
|     this.dataRaw = LANGUAGES[lang]; | ||||
|  | ||||
|     //Now parse | ||||
|     this.data = this.parseRecursive(this.dataRaw); | ||||
|   } | ||||
|  | ||||
|   getLanguage() { | ||||
|     return this.langName; | ||||
|   } | ||||
|  | ||||
|   get(key) { | ||||
|     if(typeof key === typeof undefined)  return "Key \"undefined\"."; | ||||
|     let j = this.getRecursive(key.split(".")); | ||||
|     if(typeof j === typeof undefined || j == null) return "Missing \"" + key + "\""; | ||||
|     return j; | ||||
|   } | ||||
|  | ||||
|   getRecursive(key_array, data_obj) { | ||||
|     if(typeof data_obj === typeof undefined) data_obj = this.data; | ||||
|     if(typeof data_obj === typeof undefined) return null; | ||||
|  | ||||
|     let k = key_array[0]; | ||||
|     let o = data_obj[k]; | ||||
|     if(typeof o === typeof undefined) return null; | ||||
|     if(typeof o === 'function') o = o(); | ||||
|  | ||||
|     //Awesome | ||||
|     if(key_array.length > 1) { | ||||
|       if(typeof o !== "object") return null; | ||||
|       key_array.shift(); | ||||
|       return this.getRecursive(key_array, o); | ||||
|     } | ||||
|     return o; | ||||
|   parseRecursive(o) { | ||||
|     let keys = Object.keys(o); | ||||
|     let p = {}; | ||||
|     keys.forEach(key => { | ||||
|       let d = o[key]; | ||||
|       if(typeof d === typeof undefined) d = null; | ||||
|       if(typeof d === 'function') { | ||||
|         p[key] = d(); | ||||
|         return; | ||||
|       } | ||||
|       if(typeof d === 'string') { | ||||
|         p[key] = d; | ||||
|         return; | ||||
|       } | ||||
|       p[key] = this.parseRecursive(d); | ||||
|     }); | ||||
|     return p; | ||||
|   } | ||||
|  | ||||
|   getLanguages() { | ||||
|   | ||||
| @@ -163,7 +163,7 @@ export default { | ||||
|           </Fragment> ); } | ||||
|         }, | ||||
|         "footer": "Want me for your next project?", | ||||
|         "footer-button": "Contact Me" | ||||
|         "footerButton": "Contact Me" | ||||
|       } | ||||
|     }, | ||||
|  | ||||
|   | ||||
| @@ -32,7 +32,7 @@ import { openModal } from '@public/actions/ModalActions'; | ||||
|  | ||||
| //Components | ||||
| import Page, { PageBoundary } from '@components/page/Page'; | ||||
| import Language from '@public/language/Language'; | ||||
| import { withLanguage } from '@public/language/Language'; | ||||
| import Section, { | ||||
|   BodySection, | ||||
|   ClearSection, | ||||
| @@ -75,13 +75,14 @@ class ContactPage extends React.Component { | ||||
|  | ||||
|   onError(e, a, b) { | ||||
|     this.props.openModal( | ||||
|       <Modal close title={Language.get("pages.contact.error")}> | ||||
|       <Modal close title={ this.props.lang.pages.contact.error }> | ||||
|         { e } | ||||
|       </Modal> | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   render() { | ||||
|     let { lang } = this.props; | ||||
|  | ||||
|     //Form | ||||
|     let inners; | ||||
| @@ -90,8 +91,8 @@ class ContactPage extends React.Component { | ||||
|       inners = ( | ||||
|         <ElementScrollFader from="bottom"> | ||||
|           <ContentBox box className="u-text-center"> | ||||
|             <Heading1>{ Language.get("pages.contact.success.heading") }</Heading1> | ||||
|             <Paragraph>{ Language.get("pages.contact.success.paragraph") }</Paragraph> | ||||
|             <Heading1>{ lang.pages.contact.success.heading }</Heading1> | ||||
|             <Paragraph>{ lang.pages.contact.success.paragraph }</Paragraph> | ||||
|           </ContentBox> | ||||
|         </ElementScrollFader> | ||||
|       ); | ||||
| @@ -105,18 +106,18 @@ class ContactPage extends React.Component { | ||||
|               contentType="application/json" | ||||
|               ajax | ||||
|               loader | ||||
|               onSuccess={ this.onSuccess.bind(this) } | ||||
|               onError={ this.onError.bind(this) } | ||||
|               onSuccess={ (e) => this.onSuccess(e) } | ||||
|               onError={ (e) => this.onError(e) } | ||||
|               manager={ this.manager } | ||||
|             > | ||||
|               <FormGroup> | ||||
|                 <Label htmlFor="name"> | ||||
|                   { Language.get("pages.contact.name.label") } | ||||
|                   { lang.pages.contact.name.label } | ||||
|                 </Label> | ||||
|                 <Input | ||||
|                   name="name" | ||||
|                   type="text" | ||||
|                   placeholder={ Language.get("pages.contact.name.placeholder") } | ||||
|                   placeholder={ lang.pages.contact.name.placeholder } | ||||
|                   required={ Forms.contact.name.required } | ||||
|                   maxLength={ Forms.contact.name.maxLength } | ||||
|                   manager={ this.manager } | ||||
| @@ -125,12 +126,12 @@ class ContactPage extends React.Component { | ||||
|  | ||||
|               <FormGroup > | ||||
|                 <Label htmlFor="email"> | ||||
|                   { Language.get("pages.contact.email.label") } | ||||
|                   { lang.pages.contact.email.label } | ||||
|                 </Label> | ||||
|                 <Input | ||||
|                   name="email" | ||||
|                   type="email" | ||||
|                   placeholder={ Language.get("pages.contact.email.placeholder") } | ||||
|                   placeholder={ lang.pages.contact.email.placeholder } | ||||
|                   required={ Forms.contact.email.required } | ||||
|                   maxLength={ Forms.contact.email.maxLength } | ||||
|                   manager={ this.manager } | ||||
| @@ -139,11 +140,11 @@ class ContactPage extends React.Component { | ||||
|  | ||||
|               <FormGroup> | ||||
|                 <Label> htmlFor="message"> | ||||
|                   { Language.get("pages.contact.message.label") } | ||||
|                   { lang.pages.contact.message.label } | ||||
|                 </Label> | ||||
|                 <TextArea | ||||
|                   name="message" | ||||
|                   placeholder={ Language.get("pages.contact.message.placeholder") } | ||||
|                   placeholder={ lang.pages.contact.message.placeholder } | ||||
|                   rows="8" | ||||
|                   className="p-contact-page__message" | ||||
|                   required={ Forms.contact.message.required } | ||||
| @@ -153,8 +154,8 @@ class ContactPage extends React.Component { | ||||
|               </FormGroup> | ||||
|  | ||||
|               <ButtonGroup> | ||||
|                 <Input type="submit" value={ Language.get("pages.contact.send") } primary="true" /> | ||||
|                 <Input type="reset" value={ Language.get("pages.contact.reset") } /> | ||||
|                 <Input type="submit" value={ lang.pages.contact.send } primary="true" /> | ||||
|                 <Input type="reset" value={ lang.pages.contact.reset } /> | ||||
|               </ButtonGroup> | ||||
|             </Form> | ||||
|           </BodySection> | ||||
| @@ -163,14 +164,14 @@ class ContactPage extends React.Component { | ||||
|     } | ||||
|  | ||||
|     return ( | ||||
|       <Page style="contact-page" className="p-contact-page" title={ Language.get("pages.contact.title") }> | ||||
|       <Page style="contact-page" className="p-contact-page" title={ lang.pages.contact.title }> | ||||
|         <ClearSection /> | ||||
|         <PageBoundary small> | ||||
|           <ElementScrollFader from="left"> | ||||
|             <ContentBox box className="u-text-center"> | ||||
|               <Title>{ Language.get("pages.contact.heading") }</Title> | ||||
|               <Title>{ lang.pages.contact.heading }</Title> | ||||
|               <Paragraph> | ||||
|                 { Language.get("pages.contact.paragraph") } | ||||
|                 { lang.pages.contact.paragraph } | ||||
|               </Paragraph> | ||||
|             </ContentBox> | ||||
|           </ElementScrollFader> | ||||
| @@ -186,16 +187,12 @@ class ContactPage extends React.Component { | ||||
|   } | ||||
| } | ||||
|  | ||||
| const mapStateToProps = function(state) { | ||||
|   return { | ||||
|     code: state.language.code | ||||
|   } | ||||
| } | ||||
| const mapStateToProps = state => {return {}}; | ||||
|  | ||||
| const mapDispatchToProps = (dispatch) => { | ||||
| const mapDispatchToProps = dispatch => { | ||||
|   return bindActionCreators({ | ||||
|     openModal: openModal | ||||
|   },dispatch); | ||||
| } | ||||
|  | ||||
| export default connect(mapStateToProps, mapDispatchToProps)(ContactPage); | ||||
| export default connect(mapStateToProps, mapDispatchToProps)(withLanguage(ContactPage)); | ||||
|   | ||||
| @@ -22,7 +22,7 @@ | ||||
| // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||||
|  | ||||
| import React from 'react'; | ||||
| import Language from '@public/language/Language'; | ||||
| import { withLanguage } from '@public/language/Language'; | ||||
| import { PageBoundary } from '@components/page/Page'; | ||||
| import { ImageSection, SplitSection, Split, ClearSection } from '@components/section/Section'; | ||||
| import ContentBox from '@objects/content/box/ContentBox'; | ||||
| @@ -107,7 +107,9 @@ const ExistingWorkFrame = (props) => { | ||||
|  | ||||
|  | ||||
|  | ||||
| export default props => { | ||||
| export default withLanguage(props => { | ||||
|   let { lang } = props; | ||||
|  | ||||
|   return ( | ||||
|     <ImageSection | ||||
|       className="p-home-page__promo p-home-page__promo-work" | ||||
| @@ -120,10 +122,10 @@ export default props => { | ||||
|         <ElementScrollFader from="left"> | ||||
|           <ContentBox box> | ||||
|             <Heading1 className="u-text-center"> | ||||
|               { Language.get("pages.home.work.heading") } | ||||
|               { lang.pages.home.work.heading } | ||||
|             </Heading1> | ||||
|             <Paragraph> | ||||
|               { Language.get("pages.home.work.paragraph") } | ||||
|               { lang.pages.home.work.paragraph } | ||||
|             </Paragraph> | ||||
|           </ContentBox> | ||||
|         </ElementScrollFader> | ||||
| @@ -138,8 +140,8 @@ export default props => { | ||||
|           fromLeft="top" | ||||
|           fromRight="bottom" | ||||
|           src={ require('@assets/images/work-showcase/kopalife.png') } | ||||
|           title={ Language.get("pages.home.work.kopa.heading") } | ||||
|           description={ Language.get("pages.home.work.kopa.description") } | ||||
|           title={ lang.pages.home.work.kopa.heading } | ||||
|           description={ lang.pages.home.work.kopa.description } | ||||
|         /> | ||||
|  | ||||
|         {/* SMAI */} | ||||
| @@ -149,8 +151,8 @@ export default props => { | ||||
|           fromRight="right" | ||||
|           swap | ||||
|           src={ require('@assets/images/work-showcase/smai.svg') } | ||||
|           title={ Language.get("pages.home.work.smai.heading") } | ||||
|           description={ Language.get("pages.home.work.smai.description") } | ||||
|           title={ lang.pages.home.work.smai.heading } | ||||
|           description={ lang.pages.home.work.smai.description } | ||||
|         /> | ||||
|  | ||||
|         {/* Cocksox */} | ||||
| @@ -159,8 +161,8 @@ export default props => { | ||||
|           fromLeft="bottom" | ||||
|           fromRight="top" | ||||
|           src={ require('@assets/images/work-showcase/cocksox.png') } | ||||
|           title={ Language.get("pages.home.work.cocksox.heading") } | ||||
|           description={ Language.get("pages.home.work.cocksox.description") } | ||||
|           title={ lang.pages.home.work.cocksox.heading } | ||||
|           description={ lang.pages.home.work.cocksox.description } | ||||
|         /> | ||||
|  | ||||
|         {/* Oz Hair and Beauty */} | ||||
| @@ -170,8 +172,8 @@ export default props => { | ||||
|           fromRight="left" | ||||
|           swap | ||||
|           src={ require('@assets/images/work-showcase/ozhair.png') } | ||||
|           title={ Language.get("pages.home.work.ozhair.heading") } | ||||
|           description={ Language.get("pages.home.work.ozhair.description") } | ||||
|           title={ lang.pages.home.work.ozhair.heading } | ||||
|           description={ lang.pages.home.work.ozhair.description } | ||||
|         /> | ||||
|       </PageBoundary> | ||||
|  | ||||
| @@ -180,9 +182,9 @@ export default props => { | ||||
|  | ||||
|         <ElementScrollFader from="bottom"> | ||||
|           <ContentBox box className="u-text-center"> | ||||
|             <Subtitle>{ Language.get("pages.home.work.footer") }</Subtitle> | ||||
|             <Subtitle>{ lang.pages.home.work.footer }</Subtitle> | ||||
|             <Button size="large" to="/contact"> | ||||
|               { Language.get("pages.home.work.footer-button") } | ||||
|               { lang.pages.home.work.footerButton } | ||||
|             </Button> | ||||
|           </ContentBox> | ||||
|         </ElementScrollFader> | ||||
| @@ -191,4 +193,4 @@ export default props => { | ||||
|       </PageBoundary> | ||||
|     </ImageSection> | ||||
|   ); | ||||
| } | ||||
| }); | ||||
|   | ||||
| @@ -39,7 +39,7 @@ const Platform = (props) => { | ||||
|   if(props.to) { | ||||
|     children = ( | ||||
|       <a href={props.to} target="_blank" className="p-home-page__brands-link" title={props.title}> | ||||
|         {image} | ||||
|         { image } | ||||
|       </a> | ||||
|     ); | ||||
|   } else { | ||||
|   | ||||
| @@ -23,14 +23,15 @@ | ||||
|  | ||||
| import React from 'react'; | ||||
| import { connect } from 'react-redux'; | ||||
| import Language from '@public/language/Language'; | ||||
| import { withLanguage } from '@public/language/Language'; | ||||
| import { PageBoundary } from '@components/page/Page'; | ||||
| import { ImageSection } from '@components/section/Section'; | ||||
| import ContentBox from '@objects/content/box/ContentBox'; | ||||
| import { Title, Paragraph, Heading1 } from '@objects/typography/Typography'; | ||||
| import ElementScrollFader from '@objects/animation/fade/ElementScrollFader'; | ||||
|  | ||||
| export default (props) => { | ||||
| export default withLanguage(props => { | ||||
|   let { lang } = props; | ||||
|   return ( | ||||
|     <ImageSection | ||||
|       className="p-home-page__promo p-home-page__promo-programming" | ||||
| @@ -42,12 +43,12 @@ export default (props) => { | ||||
|         <ElementScrollFader from="bottom"> | ||||
|           <ContentBox box> | ||||
|             <Heading1 className="u-text-center"> | ||||
|               { Language.get("pages.home.programming.heading") } | ||||
|               { lang.pages.home.programming.heading } | ||||
|             </Heading1> | ||||
|             { Language.get("pages.home.programming.paragraph") } | ||||
|             { lang.pages.home.programming.paragraph } | ||||
|           </ContentBox> | ||||
|         </ElementScrollFader> | ||||
|       </PageBoundary> | ||||
|     </ImageSection> | ||||
|   ); | ||||
| } | ||||
| }); | ||||
|   | ||||
| @@ -22,7 +22,7 @@ | ||||
| // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||||
|  | ||||
| import React from 'react'; | ||||
| import Language from '@public/language/Language'; | ||||
| import { withLanguage } from '@public/language/Language'; | ||||
| import Page, { PageBoundary } from '@components/page/Page'; | ||||
| import Section, {  SplitSection, Split } from '@components/section/Section'; | ||||
| import ContentBox from '@objects/content/box/ContentBox'; | ||||
| @@ -32,7 +32,9 @@ import { Title, Subtitle, Paragraph, Heading1 } from '@objects/typography/Typogr | ||||
| import ElementScrollFader from '@objects/animation/fade/ElementScrollFader'; | ||||
|  | ||||
|  | ||||
| export default (props) => { | ||||
| export default withLanguage(props => { | ||||
|   let { lang } = props; | ||||
|  | ||||
|   return ( | ||||
|     <Section className="p-home-page__promo p-home-page__promo-video"> | ||||
|       <PageBoundary> | ||||
| @@ -52,10 +54,10 @@ export default (props) => { | ||||
|             <ElementScrollFader from="bottom"> | ||||
|               <ContentBox box> | ||||
|                 <Title> | ||||
|                   { Language.get("pages.home.video.heading") } | ||||
|                   { lang.pages.home.video.heading } | ||||
|                 </Title> | ||||
|                 <Paragraph> | ||||
|                   { Language.get("pages.home.video.paragraph") } | ||||
|                   { lang.pages.home.video.paragraph } | ||||
|                 </Paragraph> | ||||
|               </ContentBox> | ||||
|             </ElementScrollFader> | ||||
| @@ -65,4 +67,4 @@ export default (props) => { | ||||
|       </PageBoundary> | ||||
|     </Section> | ||||
|   ); | ||||
| } | ||||
| }); | ||||
|   | ||||
| @@ -23,33 +23,25 @@ | ||||
|  | ||||
| import React from 'react'; | ||||
| import { connect } from 'react-redux'; | ||||
| import Language from '@public/language/Language'; | ||||
| import { withLanguage } from '@public/language/Language'; | ||||
|  | ||||
| import Page, { PageBoundary } from '@components/page/Page'; | ||||
| import { BodySection, ClearSection } from '@components/section/Section'; | ||||
|  | ||||
| import { Title } from '@objects/typography/Typography'; | ||||
|  | ||||
| const PrivacyPolicyPage = (props) => { | ||||
| export default withLanguage(props => { | ||||
|   let { lang } = props; | ||||
|   return ( | ||||
|     <Page style="privacy-policy" className="p-privacy-policy" title={ Language.get("pages.privacy.title") }> | ||||
|     <Page style="privacy-policy" className="p-privacy-policy" title={ lang.pages.privacy.title }> | ||||
|       <PageBoundary small> | ||||
|         <ClearSection /> | ||||
|         <BodySection> | ||||
|           <Title>{ Language.get("pages.privacy.heading") }</Title> | ||||
|           { Language.get("pages.privacy.policy") } | ||||
|           <Title>{ lang.pages.privacy.heading }</Title> | ||||
|           { lang.pages.privacy.policy } | ||||
|         </BodySection> | ||||
|         <ClearSection /> | ||||
|       </PageBoundary> | ||||
|     </Page> | ||||
|   ); | ||||
| }; | ||||
|  | ||||
|  | ||||
| const mapStateToProps = function(state) { | ||||
|   return { | ||||
|     code: state.language.code | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default connect(mapStateToProps)(PrivacyPolicyPage); | ||||
| }); | ||||
|   | ||||
| @@ -28,7 +28,7 @@ const initialState = { | ||||
|   code: Language.getLanguage() | ||||
| }; | ||||
|  | ||||
| function language(state, action) { | ||||
| export default (state, action) => { | ||||
|   if(typeof state === typeof undefined) { | ||||
|     state = initialState; | ||||
|   } | ||||
| @@ -42,6 +42,4 @@ function language(state, action) { | ||||
|     default: | ||||
|       return state; | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default language; | ||||
| }; | ||||
|   | ||||
| @@ -31,7 +31,7 @@ const initialState = { | ||||
|   open: false | ||||
| } | ||||
|  | ||||
| const menu = function(state, action) { | ||||
| export default (state, action) => { | ||||
|   if(typeof state === typeof undefined) { | ||||
|     state = initialState; | ||||
|   } | ||||
| @@ -47,5 +47,3 @@ const menu = function(state, action) { | ||||
|       return state; | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default menu; | ||||
|   | ||||
| @@ -30,7 +30,7 @@ const initialState = { | ||||
|   open: false | ||||
| } | ||||
|  | ||||
| const modal = function(state, action) { | ||||
| export default (state, action) => { | ||||
|   if(typeof state === typeof undefined) { | ||||
|     state = initialState; | ||||
|   } | ||||
| @@ -47,5 +47,3 @@ const modal = function(state, action) { | ||||
|       return state; | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default modal; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user