fix i18n calls in constants

This commit is contained in:
Akinwale Ariwodola 2019-12-05 13:09:44 +01:00
parent f2ca5fb53e
commit cdfd1f99d0
14 changed files with 89 additions and 96 deletions

View file

@ -214,7 +214,11 @@ export default class ChannelSelector extends React.PureComponent {
onValueChange={this.handlePickerValueChange}
>
{pickerItems.map(item => (
<Picker.Item label={item} value={item} key={item} />
<Picker.Item
label={[Constants.ITEM_ANONYMOUS, Constants.ITEM_CREATE_A_CHANNEL].includes(item) ? __(item) : item}
value={item}
key={item}
/>
))}
</Picker>

View file

@ -1,7 +1,6 @@
import React from 'react';
import { DrawerItems, SafeAreaView } from 'react-navigation';
import { Image, ScrollView, Text, TouchableOpacity, View } from 'react-native';
import { __ } from 'i18n';
import Button from 'component/button';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Icon from 'react-native-vector-icons/FontAwesome5';
@ -10,23 +9,23 @@ import discoverStyle from 'styles/discover';
const groupedMenuItems = {
'Find content': [
{ icon: 'hashtag', label: __('Your Tags'), route: Constants.DRAWER_ROUTE_DISCOVER },
{ icon: 'heart', solid: true, label: __('Subscriptions'), route: Constants.DRAWER_ROUTE_SUBSCRIPTIONS },
{ icon: 'globe-americas', label: __('All Content'), route: Constants.DRAWER_ROUTE_TRENDING },
{ icon: 'hashtag', label: 'Your Tags', route: Constants.DRAWER_ROUTE_DISCOVER },
{ icon: 'heart', solid: true, label: 'Subscriptions', route: Constants.DRAWER_ROUTE_SUBSCRIPTIONS },
{ icon: 'globe-americas', label: 'All Content', route: Constants.DRAWER_ROUTE_TRENDING },
],
'Your content': [
{ icon: 'at', label: __('Channels'), route: Constants.DRAWER_ROUTE_CHANNEL_CREATOR },
{ icon: 'download', label: __('Library'), route: Constants.DRAWER_ROUTE_MY_LBRY },
{ icon: 'cloud-upload-alt', label: __('Publishes'), route: Constants.DRAWER_ROUTE_PUBLISHES },
{ icon: 'upload', label: __('New Publish'), route: Constants.DRAWER_ROUTE_PUBLISH },
{ icon: 'at', label: 'Channels', route: Constants.DRAWER_ROUTE_CHANNEL_CREATOR },
{ icon: 'download', label: 'Library', route: Constants.DRAWER_ROUTE_MY_LBRY },
{ icon: 'cloud-upload-alt', label: 'Publishes', route: Constants.DRAWER_ROUTE_PUBLISHES },
{ icon: 'upload', label: 'New Publish', route: Constants.DRAWER_ROUTE_PUBLISH },
],
Wallet: [
{ icon: 'wallet', label: __('Wallet'), route: Constants.DRAWER_ROUTE_WALLET },
{ icon: 'award', label: __('Rewards'), route: Constants.DRAWER_ROUTE_REWARDS },
{ icon: 'wallet', label: 'Wallet', route: Constants.DRAWER_ROUTE_WALLET },
{ icon: 'award', label: 'Rewards', route: Constants.DRAWER_ROUTE_REWARDS },
],
Settings: [
{ icon: 'cog', label: __('Settings'), route: Constants.DRAWER_ROUTE_SETTINGS },
{ icon: 'info', label: __('About'), route: Constants.DRAWER_ROUTE_ABOUT },
{ icon: 'cog', label: 'Settings', route: Constants.DRAWER_ROUTE_SETTINGS },
{ icon: 'info', label: 'About', route: Constants.DRAWER_ROUTE_ABOUT },
],
};
@ -151,7 +150,7 @@ class DrawerContent extends React.PureComponent {
return (
<TouchableOpacity
accessible
accessibilityLabel={item.label}
accessibilityLabel={__(item.label)}
style={[
discoverStyle.menuItemTouchArea,
focused ? discoverStyle.menuItemTouchAreaFocused : null,
@ -169,7 +168,7 @@ class DrawerContent extends React.PureComponent {
/>
</View>
<Text style={[discoverStyle.menuItem, focused ? discoverStyle.menuItemFocused : null]}>
{item.label}
{__(item.label)}
</Text>
</TouchableOpacity>
);

View file

@ -46,7 +46,7 @@ export default class ModalPicker extends React.PureComponent {
onPress={() => onItemSelected(item)}
>
{item.icon && <Icon style={modalPickerStyle.itemIcon} name={item.icon} size={16} />}
<Text style={modalPickerStyle.itemLabel}>{item.label}</Text>
<Text style={modalPickerStyle.itemLabel}>{__(item.label)}</Text>
{selectedItem && selectedItem.name === item.name && (
<Icon style={modalPickerStyle.itemSelected} name={'check'} color={Colors.LbryGreen} size={16} />
)}

View file

@ -256,7 +256,7 @@ class UriBar extends React.PureComponent {
this.setSelection();
}}
selectTextOnFocus
placeholder={'Search movies, music, and more'}
placeholder={__('Search movies, music, and more')}
underlineColorAndroid={'transparent'}
numberOfLines={1}
clearButtonMode={'while-editing'}

View file

@ -1,5 +1,3 @@
import { __ } from 'i18n';
const SORT_BY_NEW = 'new';
const SORT_BY_HOT = 'hot';
const SORT_BY_TOP = 'top';
@ -98,8 +96,8 @@ const Constants = {
ROUTE_FILE: 'File',
ITEM_CREATE_A_CHANNEL: __('Create a channel...'),
ITEM_ANONYMOUS: __('Publish anonymously'),
ITEM_CREATE_A_CHANNEL: 'Create a channel...',
ITEM_ANONYMOUS: 'Publish anonymously',
SUBSCRIPTIONS_VIEW_ALL: 'view_all',
SUBSCRIPTIONS_VIEW_LATEST_FIRST: 'view_latest_first',
@ -118,17 +116,17 @@ const Constants = {
TIME_ALL,
CLAIM_SEARCH_SORT_BY_ITEMS: [
{ icon: 'fire-alt', name: SORT_BY_HOT, label: __('Trending content') },
{ icon: 'certificate', name: SORT_BY_NEW, label: __('New content') },
{ icon: 'chart-line', name: SORT_BY_TOP, label: __('Top content') },
{ icon: 'fire-alt', name: SORT_BY_HOT, label: 'Trending content' },
{ icon: 'certificate', name: SORT_BY_NEW, label: 'New content' },
{ icon: 'chart-line', name: SORT_BY_TOP, label: 'Top content' },
],
CLAIM_SEARCH_TIME_ITEMS: [
{ name: TIME_DAY, label: __('Past 24 hours') },
{ name: TIME_WEEK, label: __('Past week') },
{ name: TIME_MONTH, label: __('Past month') },
{ name: TIME_YEAR, label: __('Past year') },
{ name: TIME_ALL, label: __('All time') },
{ name: TIME_DAY, label: 'Past 24 hours' },
{ name: TIME_WEEK, label: 'Past week' },
{ name: TIME_MONTH, label: 'Past month' },
{ name: TIME_YEAR, label: 'Past year' },
{ name: TIME_ALL, label: 'All time' },
],
DEFAULT_ORDER_BY: ['trending_group', 'trending_mixed'],

View file

@ -60,7 +60,6 @@ function checkMessageAndSave(message, messagesFilePath) {
export function __(message, tokens) {
const w = global.window ? global.window : window;
let language = w.language ? w.language : 'en';
console.log('w.language=' + language + '; message=' + message);
if (!isProduction) {
saveMessage(message);

View file

@ -74,12 +74,12 @@ class ChannelPage extends React.PureComponent {
<View style={discoverStyle.pickerRow}>
<View style={discoverStyle.leftPickerRow}>
<TouchableOpacity style={discoverStyle.tagSortBy} onPress={() => this.setState({ showSortPicker: true })}>
<Text style={discoverStyle.tagSortText}>{sortByItem.label.split(' ')[0]}</Text>
<Text style={discoverStyle.tagSortText}>{__(sortByItem.label.split(' ')[0])}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
{Constants.SORT_BY_TOP === sortByItem.name && (
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
<Text style={discoverStyle.tagSortText}>{__(timeItem.label)}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}

View file

@ -261,13 +261,13 @@ class DiscoverPage extends React.PureComponent {
<View style={discoverStyle.pickerRow}>
<View style={discoverStyle.leftPickerRow}>
<TouchableOpacity style={discoverStyle.tagSortBy} onPress={() => this.setState({ showSortPicker: true })}>
<Text style={discoverStyle.tagSortText}>{sortByItem.label.split(' ')[0]}</Text>
<Text style={discoverStyle.tagSortText}>{__(sortByItem.label.split(' ')[0])}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
{Constants.SORT_BY_TOP === sortByItem.name && (
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
<Text style={discoverStyle.tagSortText}>{__(timeItem.label)}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}

View file

@ -46,34 +46,33 @@ import TagSearch from 'component/tagSearch';
import UriBar from 'component/uriBar';
import publishStyle from 'styles/publish';
import { navigateToUri, logPublish, uploadImageAsset } from 'utils/helper';
import { __ } from 'i18n';
const languages = {
en: __('English'),
zh: __('Chinese'),
fr: __('French'),
de: __('German'),
jp: __('Japanese'),
ru: __('Russian'),
es: __('Spanish'),
id: __('Indonesian'),
it: __('Italian'),
nl: __('Dutch'),
tr: __('Turkish'),
pl: __('Polish'),
ms: __('Malay'),
pt: __('Portuguese'),
vi: __('Vietnamese'),
th: __('Thai'),
ar: __('Arabic'),
cs: __('Czech'),
hr: __('Croatian'),
km: __('Cambodian'),
ko: __('Korean'),
no: __('Norwegian'),
ro: __('Romanian'),
hi: __('Hindi'),
el: __('Greek'),
en: 'English',
zh: 'Chinese',
fr: 'French',
de: 'German',
jp: 'Japanese',
ru: 'Russian',
es: 'Spanish',
id: 'Indonesian',
it: 'Italian',
nl: 'Dutch',
tr: 'Turkish',
pl: 'Polish',
ms: 'Malay',
pt: 'Portuguese',
vi: 'Vietnamese',
th: 'Thai',
ar: 'Arabic',
cs: 'Czech',
hr: 'Croatian',
km: 'Cambodian',
ko: 'Korean',
no: 'Norwegian',
ro: 'Romanian',
hi: 'Hindi',
el: 'Greek',
};
class PublishPage extends React.PureComponent {
@ -1155,7 +1154,7 @@ class PublishPage extends React.PureComponent {
onValueChange={this.handleLanguageValueChange}
>
{Object.keys(languages).map(lang => (
<Picker.Item label={languages[lang]} value={lang} key={lang} />
<Picker.Item label={__(languages[lang])} value={lang} key={lang} />
))}
</Picker>
</View>

View file

@ -2,7 +2,6 @@ import React from 'react';
import { SETTINGS } from 'lbry-redux';
import { ActivityIndicator, Picker, Platform, Text, View, ScrollView, Switch, NativeModules } from 'react-native';
import { navigateBack } from 'utils/helper';
import { __ } from 'i18n';
import AsyncStorage from '@react-native-community/async-storage';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
@ -11,17 +10,17 @@ import RNFS from 'react-native-fs';
import settingsStyle from 'styles/settings';
const languageOptions = [
{ code: 'default', name: __('Use device language') },
{ code: 'en', name: __('English') },
{ code: 'gu', name: __('Gujarati') },
{ code: 'hi', name: __('Hindi') },
{ code: 'id', name: __('Indonesian') },
{ code: 'it', name: __('Italian') },
{ code: 'ms', name: __('Malay') },
{ code: 'tr', name: __('Turkish') },
{ code: 'pl', name: __('Polish') },
{ code: 'pt', name: __('Portuguese') },
{ code: 'es', name: __('Spanish') },
{ code: 'default', name: 'Use device language' },
{ code: 'en', name: 'English' },
{ code: 'gu', name: 'Gujarati' },
{ code: 'hi', name: 'Hindi' },
{ code: 'id', name: 'Indonesian' },
{ code: 'it', name: 'Italian' },
{ code: 'ms', name: 'Malay' },
{ code: 'tr', name: 'Turkish' },
{ code: 'pl', name: 'Polish' },
{ code: 'pt', name: 'Portuguese' },
{ code: 'es', name: 'Spanish' },
];
class SettingsPage extends React.PureComponent {
@ -186,7 +185,7 @@ class SettingsPage extends React.PureComponent {
onValueChange={this.handleLanguageValueChange}
>
{languageOptions.map(option => (
<Picker.Item label={option.name} value={option.code} key={option.code} />
<Picker.Item label={__(option.name)} value={option.code} key={option.code} />
))}
</Picker>
</View>

View file

@ -5,7 +5,6 @@ import { ActivityIndicator, DeviceEventEmitter, Linking, NativeModules, Platform
import { NavigationActions, StackActions } from 'react-navigation';
import { decode as atob } from 'base-64';
import { navigateToUri, transformUrl } from 'utils/helper';
import { __ } from 'i18n';
import moment from 'moment';
import AsyncStorage from '@react-native-community/async-storage';
import Button from 'component/button';
@ -18,9 +17,6 @@ import RNFS from 'react-native-fs';
const BLOCK_HEIGHT_INTERVAL = 1000 * 60 * 2.5; // every 2.5 minutes
const testingNetwork = __('Testing network');
const waitingForResolution = __('Waiting for name resolution');
class SplashScreen extends React.PureComponent {
static navigationOptions = {
title: 'Splash',
@ -205,8 +201,8 @@ class SplashScreen extends React.PureComponent {
Lbry.wallet_unlock({ password: password || '' }).then(unlocked => {
if (unlocked) {
this.setState({
message: testingNetwork,
details: waitingForResolution,
message: __('Testing network'),
details: __('Waiting for name resolution'),
});
this.finishSplashScreen();
} else {
@ -215,8 +211,8 @@ class SplashScreen extends React.PureComponent {
});
} else {
this.setState({
message: testingNetwork,
details: waitingForResolution,
message: __('Testing network'),
details: __('Waiting for name resolution'),
});
this.finishSplashScreen();
}
@ -318,8 +314,8 @@ class SplashScreen extends React.PureComponent {
this.setState(
{
accountUnlockFailed: false,
message: testingNetwork,
details: waitingForResolution,
message: __('Testing network'),
details: __('Waiting for name resolution'),
},
() => this.finishSplashScreen()
);

View file

@ -158,7 +158,7 @@ class SubscriptionsPage extends React.PureComponent {
style={subscriptionsStyle.tagSortBy}
onPress={() => this.setState({ showSortPicker: true })}
>
<Text style={subscriptionsStyle.tagSortText}>{currentSortByItem.label.split(' ')[0]}</Text>
<Text style={subscriptionsStyle.tagSortText}>{__(currentSortByItem.label.split(' ')[0])}</Text>
<Icon style={subscriptionsStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
@ -167,7 +167,7 @@ class SubscriptionsPage extends React.PureComponent {
style={subscriptionsStyle.tagSortBy}
onPress={() => this.setState({ showTimePicker: true })}
>
<Text style={subscriptionsStyle.tagSortText}>{timeItem.label}</Text>
<Text style={subscriptionsStyle.tagSortText}>{__(timeItem.label)}</Text>
<Icon style={subscriptionsStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}

View file

@ -105,12 +105,12 @@ class TagPage extends React.PureComponent {
<View style={discoverStyle.pickerRow}>
<View style={discoverStyle.leftPickerRow}>
<TouchableOpacity style={discoverStyle.tagSortBy} onPress={() => this.setState({ showSortPicker: true })}>
<Text style={discoverStyle.tagSortText}>{sortByItem.label.split(' ')[0]}</Text>
<Text style={discoverStyle.tagSortText}>{__(sortByItem.label.split(' ')[0])}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
{Constants.SORT_BY_TOP === sortByItem.name && (
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
<Text style={discoverStyle.tagSortText}>{__(timeItem.label)}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}

View file

@ -15,11 +15,10 @@ import FloatingWalletBalance from 'component/floatingWalletBalance';
import Icon from 'react-native-vector-icons/FontAwesome5';
import UriBar from 'component/uriBar';
import discoverStyle from 'styles/discover';
import { __ } from 'i18n';
const TRENDING_FOR_ITEMS = [
{ icon: 'globe-americas', name: 'everyone', label: __('Everyone') },
{ icon: 'hashtag', name: 'tags', label: __('Tags you follow') },
{ icon: 'globe-americas', name: 'everyone', label: 'Everyone' },
{ icon: 'hashtag', name: 'tags', label: 'Tags you follow' },
];
class TrendingPage extends React.PureComponent {
@ -101,24 +100,24 @@ class TrendingPage extends React.PureComponent {
style={discoverStyle.allTagSortBy}
onPress={() => this.setState({ showSortPicker: true })}
>
<Text style={discoverStyle.tagSortText}>{sortByItem.label.split(' ')[0]}</Text>
<Text style={discoverStyle.tagSortText}>{__(sortByItem.label.split(' ')[0])}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
<Text style={discoverStyle.pickerLabel}>for</Text>
<Text style={discoverStyle.pickerLabel}>{__('for')}</Text>
<TouchableOpacity
style={discoverStyle.allTagSortBy}
onPress={() => this.setState({ showTrendingForPicker: true })}
>
<Text style={discoverStyle.tagSortText}>{currentTrendingForItem.label.split(' ')[0]}</Text>
<Text style={discoverStyle.tagSortText}>{__(currentTrendingForItem.label.split(' ')[0])}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
{sortByTop && <Text style={discoverStyle.pickerLabel}>from</Text>}
{sortByTop && <Text style={discoverStyle.pickerLabel}>{__('from')}</Text>}
{sortByTop && (
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
<Text style={discoverStyle.tagSortText}>{__(timeItem.label)}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}