Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add button to change language #85

Merged
merged 3 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
cherry-pick
  • Loading branch information
amaury1093 committed Apr 26, 2019
commit 3212213b2f073524a401d85d3704d6c8308151b7
8 changes: 8 additions & 0 deletions App/Screens/About/About.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export class About extends PureComponent {
{'\n'}
Shoot! I Smoke v{Constants.manifest.version}.
</Text>
<View style={styles.language}>
<Text style={theme.text}>Change language:</Text>
<Language></Language>
</View>
</View>
</ScrollView>
);
Expand Down Expand Up @@ -157,6 +161,10 @@ const styles = StyleSheet.create({
lineHeight: 24,
marginBottom: theme.spacing.small
},
language: {
marginTop: theme.spacing.normal,
justifyContent: 'space-between'
},
section: {
marginBottom: theme.spacing.big
}
Expand Down
52 changes: 52 additions & 0 deletions App/Screens/About/Language/Language.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Sh**t! I Smoke
// Copyright (C) 2018-2019 Marcelo S. Coelho, Amaury Martiny

// Sh**t! I Smoke is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Sh**t! I Smoke is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Sh**t! I Smoke. If not, see <http:https://www.gnu.org/licenses/>.

import { inject, observer } from 'mobx-react';
import React, { Component } from 'react';
import { Picker, StyleSheet } from 'react-native';

import { i18n } from '../../../localization';
import * as theme from '../../../utils/theme';

@inject('stores')
@observer
export class Language extends Component {
handleValueChange = (itemValue) => {
i18n.locale = itemValue;

this.props.stores.reloadApp();
}

render () {
return (
<Picker
itemStyle={theme.text}
onValueChange={this.handleValueChange}
selectedValue={i18n.locale}
style={styles.picker}
>
<Picker.Item label="English (US)" value="en" />
<Picker.Item label="Spanish (Spain)" value="es" />
</Picker>
);
}
}

const styles = StyleSheet.create({
picker: {
width: 200
}
});
1 change: 1 addition & 0 deletions App/localization/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ i18n.translations = {
es,
fr
};
console.log('AAAAAAA');
i18n.locale = Localization.locale;

export {
Expand Down
4 changes: 4 additions & 0 deletions App/stores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,9 @@ export const RootStore = types
// TODO Add sentry
// https://github.com/amaurymartiny/shoot-i-smoke/issues/22
self.error = newError;
},
reloadApp () {
// This will reload the app
self.location.setCurrent();
}
}));