Created
October 7, 2016 17:35
-
-
Save helloncanella/541f065c26dd6f0ac26c3b9e52811175 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import {Loading} from '/client/pages/loading/loading.jsx' | |
import {Translations} from '/lib/collections/translations' | |
import {Session} from '/meteor/session' | |
export class TranslatorComponent extends Component{ | |
render(){ | |
return( | |
<div className='className'> | |
</div> | |
) | |
} | |
} | |
export const T = React.createClass({ | |
mixins: [ | |
ReactMeteorData | |
], | |
isReady: function() { | |
var subs = [ | |
Meteor.subscribe('translation') | |
]; | |
var ready = true; | |
_.each(subs, function(sub) { | |
if(!sub.ready()) | |
ready = false | |
}); | |
return ready | |
}, | |
getMeteorData: function() { | |
let translations, currentLanguage, dataLoading | |
if(this.isReady()) { | |
translations = Translations.find().fetch() | |
currentLanguage = Session.get('language') || 'en' | |
dataLoading = false | |
} | |
return { | |
translations | |
, currentLanguage | |
, dataLoading | |
} | |
}, | |
render() { | |
let {children} = this.props | |
if(this.data.dataLoading) { | |
return ( | |
<Loading /> | |
); | |
} else { | |
return ( | |
<div className='translator-component'> | |
<TranslatorComponent {...this.data} >{children}</TranslatorComponent> | |
</div> | |
); | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment