Commit 16c6f244 authored by valzav's avatar valzav
Browse files

merge locale-selector

parent 45267c40
......@@ -48,6 +48,7 @@ if (!window.Intl) {
require.ensure(['intl/dist/Intl'], (require) => {
window.IntlPolyfill = window.Intl = require('intl/dist/Intl')
require('intl/locale-data/jsonp/en-US.js')
require('intl/locale-data/jsonp/es.js')
Iso.bootstrap(runApp);
}, "IntlBundle");
}
......
import React from 'react';
import {connect} from 'react-redux'
import {IntlProvider} from 'react-intl';
import {IntlProvider, addLocaleData} from 'react-intl';
import en from 'react-intl/locale-data/en';
import es from 'react-intl/locale-data/es';
import {DEFAULT_LANGUAGE} from 'app/client_config';
import tt from 'counterpart';
addLocaleData([...en, ...es]);
tt.registerTranslations('en', require('app/locales/en.json'));
tt.registerTranslations('es', require('app/locales/es.json'));
class Translator extends React.Component {
render() {
let language = this.props.locale;
tt.setLocale(language);
return <IntlProvider
// to ensure dynamic language change, "key" property with same "locale" info must be added
// see: https://github.com/yahoo/react-intl/wiki/Components#multiple-intl-contexts
......
import React from 'react';
import QRCode from 'react-qr'
import tt from 'counterpart';
require('./QrKeyView.scss');
export default ({type, text, isPrivate, onClose}) => {
return (
......
......@@ -84,11 +84,6 @@ class Settings extends React.Component {
if(!metaData.profile.location) delete metaData.profile.location;
if(!metaData.profile.website) delete metaData.profile.website;
// TODO: Update language & currency
//store.set('language', language)
//this.props.changeLanguage(language)
//store.set('currency', event.target.value)
const {account, updateAccount} = this.props
this.setState({loading: true})
updateAccount({
......@@ -124,6 +119,12 @@ class Settings extends React.Component {
})
}
handleLanguageChange = (event) => {
const language = event.target.value
store.set('language', language)
this.props.changeLanguage(language)
}
render() {
const {state, props} = this
......@@ -132,40 +133,22 @@ class Settings extends React.Component {
const {profile_image, name, about, location, website} = this.state
const {follow, account, isOwnAccount} = this.props
const {follow, account, isOwnAccount, locale} = this.props
const following = follow && follow.getIn(['getFollowingAsync', account.name]);
const ignores = isOwnAccount && following && following.get('ignore_result')
return <div className="Settings">
{/*<div className="row">
<div className="row">
<div className="small-12 medium-6 large-4 columns">
<label>{tt('g.choose_language')}
<select defaultValue={store.get('language')} onChange={this.handleLanguageChange}>
<select defaultValue={locale} onChange={this.handleLanguageChange}>
<option value="en">English</option>
<option value="ru">Russian</option>
<option value="es">Spanish</option>
<option value="es-AR">Spanish (Argentina)</option>
<option value="fr">French</option>
<option value="it">Italian</option>
<option value="jp">Japanese</option>
</select>
</label>
</div>
</div>*/}
{/*<div className="row">
<div className="small-12 medium-6 large-4 columns">
<label>{tt('g.choose_currency')}
<select defaultValue={store.get('currency')} onChange={this.handleCurrencyChange}>
{
ALLOWED_CURRENCIES.map(i => {
return <option key={i} value={i}>{i}</option>
})
}
</select>
</label>
</div>
</div>*/}
</div>
<br />
<div className="row">
<form onSubmit={this.handleSubmitForm} className="small-12 medium-6 large-4 columns">
<h4>{tt('settings_jsx.public_profile_settings')}</h4>
......@@ -251,7 +234,8 @@ export default connect(
const username = current_user ? current_user.get('username') : ''
let metaData = account ? o2j.ifStringParseJSON(account.json_metadata) : {}
if (typeof metaData === 'string') metaData = o2j.ifStringParseJSON(metaData); // issue #1237
const profile = metaData && metaData.profile ? metaData.profile : {}
const profile = metaData && metaData.profile ? metaData.profile : {};
const locale = state.user.get('locale');
return {
account,
......@@ -260,6 +244,7 @@ export default connect(
isOwnAccount: username == accountname,
profile,
follow: state.global.get('follow'),
locale,
...ownProps
}
},
......
......@@ -16,6 +16,7 @@
"by": "by",
"cancel": "Cancel",
"change_password": "Change Password",
"choose_language": "Choose Language",
"clear": "Clear",
"close": "Close",
"comments": "Comments",
......
This diff is collapsed.
import {fromJS} from 'immutable';
import createModule from 'redux-modules';
import { DEFAULT_LANGUAGE } from 'app/client_config';
import store from 'store';
const defaultState = fromJS({
current: null,
......@@ -12,6 +13,11 @@ const defaultState = fromJS({
locale: DEFAULT_LANGUAGE
});
if (process.env.BROWSER) {
const locale = store.get('language');
if (locale) defaultState.locale = locale;
}
export default createModule({
name: 'user',
initialState: defaultState,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment