const DoneButton = ({ onClose }) => ( <TouchableHighlight underlayColor="#2f0001" onPress={onClose}> <Text style={styles.done}>{I18n.t('done')}</Text> </TouchableHighlight> )
renderLoginButton () { return ( <RoundedButton onPress={NavigationActions.login}> {I18n.t('signIn')} </RoundedButton> ) }
const SoundStatusButton = ({ value, onPress }: Props) => ( <TouchableHighlight onPress={onPress} underlayColor="#eee"> <View style={styles.container}> <Text style={styles.label}>{I18n.t('onfinish')}</Text> <View style={styles.sound}> <Text style={styles.soundText}>{I18n.t(soundLabel(value))}</Text> <Text style={styles.soundTextArrow}>></Text> </View> </View> </TouchableHighlight> )
function t(scope, options){ return I18n.t(scope, options) }
const buildConstants = (translations, namespace, locale) => { const constants = {}; Object.keys(translations[locale]).forEach( key => (constants[constantCase(key)] = (...configArgs) => I18n.t(getI18key(namespace, key), arrayToObject(configArgs))) ); return constants; }
// This function is a wrapper to avoid exception wich leads in a crash const translateOrFallback = initialMsg => { // We tried to translate something else than a string // The native I18n function will simply crash instead of rejecting the attempt with an error message if (typeof initialMsg !== 'string') { __DEV__ && console.log(`I18n: you must give a string to translate instead of "${typeof initialMsg}"`) return '' // We don't return any message as we don't know what to send } let localMsg = I18n.t(initialMsg) // The translation does not exist, the default message is not very sexy // Instead we return the message we tried to translate if (missingTranslationRegex.test(localMsg)) { __DEV__ && console.log(`translation "${initialMsg}" does not exists in translations files`) return initialMsg } return localMsg }
render() { const { start, pause, onCancel } = this.props; return ( <View style={styles.container}> <View style={styles.leftButton}> <CircleButton label={I18n.t('cancel')} disabled={!start} backgroundColor="#aaa" onPress={onCancel} /> </View> <View style={styles.rightButton}> <CircleButton label={pause ? I18n.t('resume') : (start && I18n.t('stop') || I18n.t('start'))} backgroundColor={start && !pause ? '#a40000' : '#449c01' } onPress={this.handleOnStart} /> </View> </View> ); }
renderLogoutButton () { return ( <RoundedButton onPress={this.props.logout}> {I18n.t('logOut')} </RoundedButton> ) }
const CancelButton = ({ onClose }) => ( <TouchableHighlight underlayColor="#2f0001" onPress={onClose}> <Text style={styles.cancel}>{I18n.t('cancel')}</Text> </TouchableHighlight> )
renderLoginButton () { return ( <RoundedButton onPress={NavigationActions.login}> {I18n.t('signIn')} </RoundedButton> ) }
renderLogoutButton () { return ( <RoundedButton onPress={this.props.logout}> {I18n.t('logOut')} </RoundedButton> ) }
// This function is a wrapper to avoid exception wich leads in a crash const translateOrFallback = initialMsg => { // We tried to translate something else than a string // The native I18n function will simply crash instead of rejecting the attempt with an error message if (typeof initialMsg !== 'string') { __DEV__ && console.log(`I18n: you must give a string to translate instead of "${typeof initialMsg}"`) return '' // We don't return any message as we don't know what to send } let localMsg = I18n.t(initialMsg) // The translation does not exist, the default message is not very sexy // Instead we return the message we tried to translate if (missingTranslationRegex.test(localMsg)) { __DEV__ && console.log(`translation "${initialMsg}" does not exists in translations files`) return initialMsg } return localMsg }
// This function is a wrapper to avoid exception wich leads in a crash const translateOrFallback = (initialMsg, options) => { // We tried to translate something else than a string // The native I18n function will simply crash instead of rejecting the attempt with an error message if (typeof initialMsg !== 'string') { __DEV__ && console.log( `I18n: you must give a string to translate instead of "${typeof initialMsg}"` ) return '' // We don't return any message as we don't know what to send } let localMsg = I18n.t(initialMsg, options) // The translation does not exist, the default message is not very sexy // Instead we return the message we tried to translate if (missingTranslationRegex.test(localMsg)) { __DEV__ && console.log( `translation "${initialMsg}" does not exists in translations files` ) return initialMsg } return localMsg }