Combined translation strings with those used by the webapp (#48)

* Combined translation strings with those used by the webapp

* Fix a few incorrect i18n message ids
This commit is contained in:
Harrison Healey 2016-10-20 20:51:34 -04:00 committed by Thomas Hopkins
parent 231fda1160
commit 59ea04fc0c
11 changed files with 4234 additions and 88 deletions

View file

@ -43,7 +43,7 @@ class ChannelsListView extends Component {
</Text>
<FormattedText
style={GlobalStyles.subheader}
id='components.channels_list_view.yourChannels'
id='mobile.components.channels_list_view.yourChannels'
defaultMessage='Your channels:'
/>
{_.map(channels, (channel) => (

View file

@ -4,8 +4,6 @@
import React, {Component, PropTypes} from 'react';
import {Text} from 'react-native';
import FormattedText from 'components/formatted_text';
import {GlobalStyles} from 'styles';
const propTypes = {
@ -20,29 +18,10 @@ export default class ErrorText extends Component {
return null;
}
let message;
if (typeof this.props.error === 'string' || this.props.error instanceof String) {
message = this.props.error;
}
if (this.props.error.message && this.props.error.message.length > 0) {
message = this.props.error.message;
}
if (message) {
return (
<Text style={GlobalStyles.errorLabel}>
{message}
</Text>
);
}
return (
<FormattedText
style={GlobalStyles.errorLabel}
id='components.error_text.unknownError'
defaultMessage='Unknown error'
/>
<Text style={GlobalStyles.errorLabel}>
{this.props.error.message || this.props.error}
</Text>
);
}
}

View file

@ -2,12 +2,13 @@
// See License.txt for license information.
import React, {Component, PropTypes} from 'react';
import {View, TextInput, Image} from 'react-native';
import {View, Text, TextInput, Image} from 'react-native';
import {Actions as Routes} from 'react-native-router-flux';
import Button from 'components/button';
import FormattedText from 'components/formatted_text';
import ErrorText from 'components/error_text';
import Loading from 'components/loading';
import {GlobalStyles} from 'styles';
import logo from 'images/logo.png';
@ -15,6 +16,7 @@ import {injectIntl, intlShape} from 'react-intl';
const propTypes = {
intl: intlShape.isRequired,
clientConfig: PropTypes.object.isRequired,
login: PropTypes.object.isRequired,
actions: PropTypes.object.isRequired
};
@ -40,28 +42,62 @@ class LoginView extends Component {
}
}
createLoginPlaceholder() {
const {formatMessage} = this.props.intl;
const clientConfig = this.props.clientConfig.data;
const loginPlaceholders = [];
if (clientConfig.EnableSignInWithEmail === 'true') {
loginPlaceholders.push(formatMessage({id: 'login.email', defaultMessage: 'Email'}));
}
if (clientConfig.EnableSignInWithUsername === 'true') {
loginPlaceholders.push(formatMessage({id: 'login.username', defaultMessage: 'Username'}));
}
if (clientConfig.EnableLdap === 'true') { // TODO check if we're licensed once we have that
if (clientConfig.LdapLoginFieldName) {
loginPlaceholders.push(clientConfig.LdapLoginFieldName);
} else {
loginPlaceholders.push(formatMessage({id: 'login.ldapUsername', defaultMessage: 'AD/LDAP Username'}));
}
}
if (loginPlaceholders.length >= 2) {
return loginPlaceholders.slice(0, loginPlaceholders.length - 1).join(', ') +
` ${formatMessage({id: 'login.or', defaultMessage: 'or'})} ` +
loginPlaceholders[loginPlaceholders.length - 1];
} else if (loginPlaceholders.length === 1) {
return loginPlaceholders[0];
}
return '';
}
render() {
if (!this.props.clientConfig || !this.props.clientConfig.data) {
return <Loading/>;
}
return (
<View style={GlobalStyles.container}>
<Image
style={GlobalStyles.logo}
source={logo}
/>
<FormattedText
style={GlobalStyles.header}
id='components.login_view.header'
defaultMessage='Mattermost'
/>
<Text style={GlobalStyles.header}>
{this.props.clientConfig.data.SiteName}
</Text>
<FormattedText
style={GlobalStyles.subheader}
id='components.login_view.subheader'
id='web.root.signup_info'
defaultMessage='All team communication in one place, searchable and accessible anywhere'
/>
<TextInput
value={this.state.loginId}
onChangeText={(loginId) => this.setState({loginId})}
style={GlobalStyles.inputBox}
placeholder={this.props.intl.formatMessage({id: 'components.login_view.loginIdPlaceholder', defaultMessage: 'Email or Username'})}
placeholder={this.createLoginPlaceholder()}
autoCorrect={false}
autoCapitalize='none'
underlineColorAndroid='transparent'
@ -70,14 +106,14 @@ class LoginView extends Component {
value={this.state.password}
onChangeText={(password) => this.setState({password})}
style={GlobalStyles.inputBox}
placeholder={this.props.intl.formatMessage({id: 'components.login_view.passwordPlaceholder', defaultMessage: 'Password'})}
placeholder={this.props.intl.formatMessage({id: 'login.password', defaultMessage: 'Password'})}
autoCorrect={false}
autoCapitalize='none'
underlineColorAndroid='transparent'
/>
<Button onPress={() => this.signIn()}>
<FormattedText
id='components.login_view.signIn'
id='login.signIn'
defaultMessage='Sign in'
/>
</Button>

View file

@ -15,8 +15,11 @@ import FormattedText from 'components/formatted_text';
import {GlobalStyles} from 'styles';
import logo from 'images/logo.png';
import {injectIntl, intlShape} from 'react-intl';
class SelectServerView extends Component {
static propTypes = {
intl: intlShape.isRequired,
ping: React.PropTypes.object.isRequired,
device: React.PropTypes.object.isRequired,
actions: React.PropTypes.object.isRequired
@ -32,6 +35,7 @@ class SelectServerView extends Component {
onClick = () => {
Client.setUrl(this.state.serverUrl);
this.props.actions.getClientConfig();
Routes.goToLogin();
// this.props.actions.getPing().then(() => {
@ -44,6 +48,8 @@ class SelectServerView extends Component {
}
render() {
const {formatMessage} = this.props.intl;
return (
<View style={GlobalStyles.container}>
<Image
@ -52,7 +58,7 @@ class SelectServerView extends Component {
/>
<FormattedText
style={_.at(GlobalStyles, ['header', 'label'])}
id='components.select_server_view.enterServerUrl'
id='mobile.components.select_server_view.enterServerUrl'
defaultMessage='Enter Server URL'
/>
<TextInput
@ -63,7 +69,7 @@ class SelectServerView extends Component {
autoCapitalize='none'
autoCorrect={false}
keyboardType='url'
placeholder='https://mattermost.example.com'
placeholder={formatMessage({id: 'mobile.components.select_server_view.siteUrlPlaceholder', defaultMessage: 'https://mattermost.example.com'})}
returnKeyType='go'
underlineColorAndroid='transparent'
/>
@ -72,7 +78,7 @@ class SelectServerView extends Component {
loading={this.props.ping.loading}
>
<FormattedText
id='components.select_server_view.proceed'
id='mobile.components.select_server_view.proceed'
defaultMessage='Proceed'
/>
</Button>
@ -83,4 +89,4 @@ class SelectServerView extends Component {
}
}
export default SelectServerView;
export default injectIntl(SelectServerView);

View file

@ -3,7 +3,7 @@
import React, {Component, PropTypes} from 'react';
import {View, Image} from 'react-native';
import {View, Image, Text} from 'react-native';
import {Actions as Routes} from 'react-native-router-flux';
import Button from 'react-native-button';
import Icon from 'react-native-vector-icons/MaterialIcons';
@ -15,6 +15,7 @@ import logo from 'images/logo.png';
import FormattedText from 'components/formatted_text';
const propTypes = {
clientConfig: PropTypes.object.isRequired,
teams: PropTypes.object.isRequired,
actions: PropTypes.object.isRequired
};
@ -36,25 +37,24 @@ export default class SelectTeamView extends Component {
render() {
const teams = _.values(this.props.teams.data);
return (
<View style={GlobalStyles.container}>
<Image
style={GlobalStyles.logo}
source={logo}
/>
<FormattedText
style={GlobalStyles.header}
id='components.select_team_view.header'
defaultMessage='Mattermost'
/>
<Text style={GlobalStyles.header}>
{this.props.clientConfig.data.SiteName}
</Text>
<FormattedText
style={GlobalStyles.subheader}
id='components.select_team_view.subheader'
id='web.root.signup_info'
defaultMessage='All team communication in one place, searchable and accessible anywhere'
/>
<FormattedText
style={GlobalStyles.subheader}
id='components.select_team_view.yourTeams'
id='signup_team.choose'
defaultMessage='Your teams:'
/>
{_.map(teams, (team) => (

View file

@ -8,6 +8,7 @@ import LoginView from 'components/login_view';
function mapStateToProps(state) {
return {
clientConfig: state.entities.general.clientConfig,
login: state.views.login
};
}

View file

@ -3,7 +3,7 @@
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {getPing} from 'actions/general';
import {getPing, getClientConfig} from 'actions/general';
import SelectServerView from 'components/select_server_view';
function mapStateToProps(state) {
@ -15,7 +15,7 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({getPing}, dispatch)
actions: bindActionCreators({getPing, getClientConfig}, dispatch)
};
}

View file

@ -8,6 +8,7 @@ import SelectTeamView from 'components/select_team_view';
function mapStateToProps(state) {
return {
clientConfig: state.entities.general.clientConfig,
teams: state.entities.teams
};
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -29,18 +29,18 @@ class Routes extends Component {
<Scene
key='goToLogin'
component={LoginContainer}
title={formatMessage({id: 'routes.login', defaultMessage: 'Login'})}
title={formatMessage({id: 'mobile.routes.login', defaultMessage: 'Login'})}
/>
<Scene
key='goToSelectServer'
component={SelectServerContainer}
title={formatMessage({id: 'routes.enterServerUrl', defaultMessage: 'Enter Server URL'})}
title={formatMessage({id: 'mobile.routes.enterServerUrl', defaultMessage: 'Enter Server URL'})}
initial={true}
/>
<Scene
key='goToChannelsList'
component={ChannelsListContainer}
title={formatMessage({id: 'routes.channels', defaultMessage: 'Channels'})}
title={formatMessage({id: 'mobile.routes.channels', defaultMessage: 'Channels'})}
renderRightButton={() =>
<Logout actions={logout}/>
}
@ -48,7 +48,7 @@ class Routes extends Component {
<Scene
key='goToSelectTeam'
component={SelectTeamContainer}
title={formatMessage({id: 'routes.selectTeam', defaultMessage: 'Select Team'})}
title={formatMessage({id: 'mobile.routes.selectTeam', defaultMessage: 'Select Team'})}
renderRightButton={() =>
<Logout actions={logout}/>
}
@ -56,7 +56,7 @@ class Routes extends Component {
<Scene
key='goToPostsList'
component={PostsListContainer}
title={formatMessage({id: 'routes.postsList', defaultMessage: 'Posts List'})}
title={formatMessage({id: 'mobile.routes.postsList', defaultMessage: 'Posts List'})}
renderRightButton={() =>
<Logout actions={logout}/>
}