Add a basic exemple (only constants)
This commit is contained in:
parent
f7e5fb9caa
commit
eadcf1d708
|
@ -1,53 +1,6 @@
|
|||
/**
|
||||
* Sample React Native App
|
||||
* https://github.com/facebook/react-native
|
||||
* @flow
|
||||
*/
|
||||
// @flow
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import {
|
||||
AppRegistry,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View
|
||||
} from 'react-native';
|
||||
import { AppRegistry } from 'react-native';
|
||||
import Screen from './screen';
|
||||
|
||||
export default class RNI18nExample extends Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>
|
||||
Welcome to React Native!
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
To get started, edit index.android.js
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
Double tap R on your keyboard to reload,{'\n'}
|
||||
Shake or press menu button for dev menu
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
welcome: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
instructions: {
|
||||
textAlign: 'center',
|
||||
color: '#333333',
|
||||
marginBottom: 5,
|
||||
},
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent('RNI18nExample', () => RNI18nExample);
|
||||
AppRegistry.registerComponent('RNI18nExample', () => Screen);
|
||||
|
|
|
@ -1,53 +1,6 @@
|
|||
/**
|
||||
* Sample React Native App
|
||||
* https://github.com/facebook/react-native
|
||||
* @flow
|
||||
*/
|
||||
// @flow
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import {
|
||||
AppRegistry,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View
|
||||
} from 'react-native';
|
||||
import { AppRegistry } from 'react-native';
|
||||
import Screen from './screen';
|
||||
|
||||
export default class RNI18nExample extends Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>
|
||||
Welcome to React Native!
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
To get started, edit index.ios.js
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
Press Cmd+R to reload,{'\n'}
|
||||
Cmd+D or shake for dev menu
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
welcome: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
instructions: {
|
||||
textAlign: 'center',
|
||||
color: '#333333',
|
||||
marginBottom: 5,
|
||||
},
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent('RNI18nExample', () => RNI18nExample);
|
||||
AppRegistry.registerComponent('RNI18nExample', () => Screen);
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
// @ flow
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import { language, languages } from 'react-native-i18n';
|
||||
|
||||
import {
|
||||
Platform,
|
||||
StyleSheet,
|
||||
Text,
|
||||
ScrollView,
|
||||
View,
|
||||
} from 'react-native';
|
||||
|
||||
export default class extends Component {
|
||||
render() {
|
||||
return (
|
||||
<ScrollView style={styles.container}>
|
||||
<Text style={styles.title}>Constants</Text>
|
||||
|
||||
<View style={styles.line}>
|
||||
<Text style={styles.label}>language: </Text>
|
||||
<Text>{JSON.stringify(language)}</Text>
|
||||
</View>
|
||||
|
||||
<View style={styles.line}>
|
||||
<Text style={styles.label}>languages: </Text>
|
||||
<Text>{JSON.stringify(languages)}</Text>
|
||||
</View>
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: '#F5FCFF',
|
||||
padding: 24,
|
||||
paddingTop: Platform.OS === 'ios' ? 44 : 24,
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
fontWeight: '700',
|
||||
marginBottom: 8,
|
||||
},
|
||||
line: {
|
||||
flexDirection: 'row',
|
||||
},
|
||||
label: {
|
||||
fontWeight: '700',
|
||||
marginRight: 8,
|
||||
},
|
||||
});
|
15
index.js
15
index.js
|
@ -1,7 +1,12 @@
|
|||
import {NativeModules} from 'react-native'
|
||||
import I18n from 'i18n-js'
|
||||
const {RNI18n} = NativeModules
|
||||
// @flow
|
||||
|
||||
I18n.locale = RNI18n.locale
|
||||
import { NativeModules } from 'react-native';
|
||||
import I18n from 'i18n-js';
|
||||
const { RNI18n } = NativeModules;
|
||||
|
||||
export default I18n
|
||||
I18n.locale = RNI18n.language;
|
||||
|
||||
export const language = RNI18n.language;
|
||||
export const languages = RNI18n.languages;
|
||||
|
||||
export default I18n;
|
||||
|
|
Loading…
Reference in New Issue