Merge pull request #738 from esteemapp/persian

added persian language
This commit is contained in:
uğur erdal 2019-04-07 13:58:20 +03:00 committed by GitHub
commit 266fe95731
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 24 deletions

View File

@ -9,6 +9,7 @@ export default {
'ko-KR': require('./ko-KR.json'), 'ko-KR': require('./ko-KR.json'),
'lt-LT': require('./lt-LT.json'), 'lt-LT': require('./lt-LT.json'),
'pt-PT': require('./pt-PT.json'), 'pt-PT': require('./pt-PT.json'),
'fa-IR': require('./fa-IR.json'),
}; };
export const locales = [ export const locales = [
@ -22,4 +23,5 @@ export const locales = [
{ id: 'ko-KR', name: 'Korean' }, { id: 'ko-KR', name: 'Korean' },
{ id: 'lt-LT', name: 'Lithuanian' }, { id: 'lt-LT', name: 'Lithuanian' },
{ id: 'pt-PT', name: 'Porteguese' }, { id: 'pt-PT', name: 'Porteguese' },
{ id: 'fa-IR', name: 'Persian' },
]; ];

View File

@ -8,6 +8,7 @@ export default [
'Porteguese', 'Porteguese',
'Russian', 'Russian',
'Turkish', 'Turkish',
'Persian',
]; ];
export const VALUE = [ export const VALUE = [
@ -20,4 +21,5 @@ export const VALUE = [
'pt-PT', 'pt-PT',
'ru-RU', 'ru-RU',
'tr-TR', 'tr-TR',
'fa-IR',
]; ];

View File

@ -1,7 +1,5 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { import { Platform, BackHandler, Alert, NetInfo } from 'react-native';
Platform, BackHandler, Alert, NetInfo,
} from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { addLocaleData } from 'react-intl'; import { addLocaleData } from 'react-intl';
import Config from 'react-native-config'; import Config from 'react-native-config';
@ -20,6 +18,8 @@ import tr from 'react-intl/locale-data/tr';
import ko from 'react-intl/locale-data/ko'; import ko from 'react-intl/locale-data/ko';
import lt from 'react-intl/locale-data/lt'; import lt from 'react-intl/locale-data/lt';
import pt from 'react-intl/locale-data/pt'; import pt from 'react-intl/locale-data/pt';
import fa from 'react-intl/locale-data/fa';
import he from 'react-intl/locale-data/he';
// Constants // Constants
import AUTH_TYPE from '../../../constants/authType'; import AUTH_TYPE from '../../../constants/authType';
@ -71,7 +71,7 @@ import {
import ApplicationScreen from '../screen/applicationScreen'; import ApplicationScreen from '../screen/applicationScreen';
import { Launch } from '../..'; import { Launch } from '../..';
addLocaleData([...en, ...ru, ...de, ...id, ...it, ...hu, ...tr, ...ko, ...pt, ...lt]); addLocaleData([...en, ...ru, ...de, ...id, ...it, ...hu, ...tr, ...ko, ...pt, ...lt, ...fa]);
class ApplicationContainer extends Component { class ApplicationContainer extends Component {
constructor() { constructor() {
@ -87,7 +87,7 @@ class ApplicationContainer extends Component {
const { isIos } = this.state; const { isIos } = this.state;
let isConnected; let isConnected;
await NetInfo.isConnected.fetch().then((_isConnected) => { await NetInfo.isConnected.fetch().then(_isConnected => {
isConnected = _isConnected; isConnected = _isConnected;
}); });
@ -104,9 +104,7 @@ class ApplicationContainer extends Component {
}; };
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const { const { isDarkTheme: _isDarkTheme, selectedLanguage, isLogingOut, isConnected } = this.props;
isDarkTheme: _isDarkTheme, selectedLanguage, isLogingOut, isConnected,
} = this.props;
if (_isDarkTheme !== nextProps.isDarkTheme || selectedLanguage !== nextProps.selectedLanguage) { if (_isDarkTheme !== nextProps.isDarkTheme || selectedLanguage !== nextProps.selectedLanguage) {
this.setState({ isRenderRequire: false }, () => this.setState({ isRenderRequire: true })); this.setState({ isRenderRequire: false }, () => this.setState({ isRenderRequire: true }));
@ -136,7 +134,7 @@ class ApplicationContainer extends Component {
await this._getUserData(); await this._getUserData();
}; };
_handleConntectionChange = (status) => { _handleConntectionChange = status => {
const { dispatch, isConnected } = this.props; const { dispatch, isConnected } = this.props;
if (isConnected !== status) { if (isConnected !== status) {
@ -170,19 +168,19 @@ class ApplicationContainer extends Component {
let realmData = []; let realmData = [];
let currentUsername; let currentUsername;
await getAuthStatus().then((res) => { await getAuthStatus().then(res => {
({ currentUsername } = res); ({ currentUsername } = res);
if (res) { if (res) {
getUserData().then(async (userData) => { getUserData().then(async userData => {
if (userData.length > 0) { if (userData.length > 0) {
realmData = userData; realmData = userData;
userData.forEach((accountData, index) => { userData.forEach((accountData, index) => {
if ( if (
!accountData.accessToken !accountData.accessToken &&
&& !accountData.masterKey !accountData.masterKey &&
&& !accountData.postingKey !accountData.postingKey &&
&& !accountData.activeKey !accountData.activeKey &&
&& !accountData.memoKey !accountData.memoKey
) { ) {
realmData.splice(index, 1); realmData.splice(index, 1);
if (realmData.length === 0) { if (realmData.length === 0) {
@ -213,7 +211,7 @@ class ApplicationContainer extends Component {
await switchAccount(realmObject[0].username); await switchAccount(realmObject[0].username);
} }
await getUser(realmObject[0].username) await getUser(realmObject[0].username)
.then(async (accountData) => { .then(async accountData => {
dispatch(login(true)); dispatch(login(true));
const isExistUser = await getExistUser(); const isExistUser = await getExistUser();
@ -227,7 +225,7 @@ class ApplicationContainer extends Component {
} }
this._connectNotificationServer(accountData.name); this._connectNotificationServer(accountData.name);
}) })
.catch((err) => { .catch(err => {
Alert.alert(err); Alert.alert(err);
}); });
} }
@ -239,15 +237,18 @@ class ApplicationContainer extends Component {
_getSettings = () => { _getSettings = () => {
const { dispatch } = this.props; const { dispatch } = this.props;
getSettings().then((response) => { getSettings().then(response => {
if (response) { if (response) {
if (response.isDarkTheme !== '') dispatch(isDarkTheme(response.isDarkTheme)); if (response.isDarkTheme !== '') dispatch(isDarkTheme(response.isDarkTheme));
if (response.language !== '') dispatch(setLanguage(response.language)); if (response.language !== '') dispatch(setLanguage(response.language));
if (response.server !== '') dispatch(setApi(response.server)); if (response.server !== '') dispatch(setApi(response.server));
if (response.upvotePercent !== '') dispatch(setUpvotePercent(Number(response.upvotePercent))); if (response.upvotePercent !== '')
dispatch(setUpvotePercent(Number(response.upvotePercent)));
if (response.isDefaultFooter !== '') dispatch(isDefaultFooter(response.isDefaultFooter)); if (response.isDefaultFooter !== '') dispatch(isDefaultFooter(response.isDefaultFooter));
if (response.notification !== '') { if (response.notification !== '') {
dispatch(changeNotificationSettings({ type: 'notification', action: response.notification })); dispatch(
changeNotificationSettings({ type: 'notification', action: response.notification }),
);
dispatch(changeAllNotificationSettings(response)); dispatch(changeAllNotificationSettings(response));
Push.setEnabled(response.notification); Push.setEnabled(response.notification);
@ -261,7 +262,7 @@ class ApplicationContainer extends Component {
}); });
}; };
_connectNotificationServer = (username) => { _connectNotificationServer = username => {
const { dispatch, unreadActivityCount } = this.props; const { dispatch, unreadActivityCount } = this.props;
const ws = new WebSocket(`${Config.ACTIVITY_WEBSOCKET_URL}?user=${username}`); const ws = new WebSocket(`${Config.ACTIVITY_WEBSOCKET_URL}?user=${username}`);
@ -299,10 +300,10 @@ class ApplicationContainer extends Component {
.catch(() => {}); .catch(() => {});
}; };
_switchAccount = async (targetAccountUsername) => { _switchAccount = async targetAccountUsername => {
const { dispatch } = this.props; const { dispatch } = this.props;
await switchAccount(targetAccountUsername).then((accountData) => { await switchAccount(targetAccountUsername).then(accountData => {
const realmData = getUserDataWithUsername(targetAccountUsername); const realmData = getUserDataWithUsername(targetAccountUsername);
const _currentAccount = accountData; const _currentAccount = accountData;
_currentAccount.username = accountData.name; _currentAccount.username = accountData.name;