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

refactor: translate() to t() #777

Merged
merged 16 commits into from
Apr 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
Empty file added ios/ip.txt
Empty file.
5 changes: 2 additions & 3 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Icon } from 'react-native-elements';

import { NotificationIcon } from 'components';
import { colors } from 'config';
import { translate } from 'utils';
import { t } from 'utils';

// Auth
import {
Expand Down Expand Up @@ -143,8 +143,7 @@ const sharedRoutes = {
const issueNumberRegex = /issues\/([0-9]+)(#|$)/;
const { issue, issueURL, isPR, locale } = navigation.state.params;
const number = issue ? issue.number : issueURL.match(issueNumberRegex)[1];
const langKey = isPR ? 'pullRequest' : 'issue';
const langTitle = translate(`issue.main.screenTitles.${langKey}`, locale);
const langTitle = isPR ? t('Pull Request', locale) : t('Issue', locale);

return {
title: `${langTitle} #${number}`,
Expand Down
10 changes: 9 additions & 1 deletion scripts/extract-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,18 @@ const generateFiles = (config, messages) => {
}
});

const ordered = {};

Object.keys(newMessages)
.sort()
.forEach(key => {
ordered[key] = newMessages[key];
});

// Write the new message file
fs.writeFile(
filepath,
`module.exports = ${JSON.stringify(newMessages, null, 2)};`,
`module.exports = ${JSON.stringify(ordered, null, 2)};`,
'utf8',
err => {
if (err) throw err;
Expand Down
23 changes: 11 additions & 12 deletions src/auth/screens/auth-profile.screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from 'components';
import { colors, fonts, normalize } from 'config';
import { getUser, getOrgs, getStarCount } from 'auth';
import { emojifyText, openURLInView, translate } from 'utils';
import { emojifyText, openURLInView, t } from 'utils';

const mapStateToProps = state => ({
user: state.auth.user,
Expand Down Expand Up @@ -132,8 +132,9 @@ class AuthProfile extends Component {
menuIcon="gear"
menuAction={() =>
navigation.navigate('UserOptions', {
title: translate('auth.userOptions.title', locale),
})}
title: t('Options', locale),
})
}
>
{isPending && (
<ActivityIndicator
Expand All @@ -146,7 +147,7 @@ class AuthProfile extends Component {
{hasInitialUser &&
user.bio &&
user.bio !== '' && (
<SectionList title={translate('common.bio', locale)}>
<SectionList title={t('BIO', locale)}>
<BioListItem
titleNumberOfLines={0}
title={emojifyText(user.bio)}
Expand All @@ -167,9 +168,9 @@ class AuthProfile extends Component {
{!isPending && (
<View>
<SectionList
title={translate('common.orgs', locale)}
title={t('ORGANIZATIONS', locale)}
noItems={orgs.length === 0}
noItemsMessage={translate('common.noOrgsMessage', locale)}
noItemsMessage={t('No organizations', locale)}
>
{orgs.map(item => (
<UserListItem
Expand All @@ -179,16 +180,14 @@ class AuthProfile extends Component {
/>
))}
<Note>
{translate('auth.profile.orgsRequestApprovalTop', locale)}
{t("Can't see all your organizations?", locale)}
{'\n'}
<NoteLink
onPress={() =>
openURLInView('https://github.com/settings/applications')}
openURLInView('https://github.com/settings/applications')
}
>
{translate(
'auth.profile.orgsRequestApprovalBottom',
locale
)}
{t('You may have to request approval for them.', locale)}
</NoteLink>
</Note>
</SectionList>
Expand Down
4 changes: 2 additions & 2 deletions src/auth/screens/language-setting.screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ListItem } from 'react-native-elements';
import { colors, fonts } from 'config';
import { changeLocale } from 'auth';
import { bindActionCreators } from 'redux';
import { emojifyText, translate } from 'utils';
import { emojifyText, t } from 'utils';
import { NavigationActions } from 'react-navigation';
import { ViewContainer } from 'components';
import languages from './language-settings';
Expand Down Expand Up @@ -51,7 +51,7 @@ class LanguageSettings extends Component {
if (nextState.locale !== this.props.locale) {
const navigationParams = NavigationActions.setParams({
params: {
title: translate('auth.userOptions.language', nextState.locale),
title: t('Language', nextState.locale),
},
key: nextState.navigation.state.key,
});
Expand Down
40 changes: 26 additions & 14 deletions src/auth/screens/login.screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ViewContainer, ErrorScreen } from 'components';
import { colors, fonts, normalize } from 'config';
import { CLIENT_ID } from 'api';
import { auth, getUser } from 'auth';
import { openURLInView, translate, resetNavigationTo } from 'utils';
import { openURLInView, t, resetNavigationTo } from 'utils';
import styled from 'styled-components';

let stateRandom = Math.random().toString();
Expand Down Expand Up @@ -182,7 +182,7 @@ class Login extends Component {
modalVisible: false,
cancelDisabled: false,
showLoader: true,
loaderText: translate('auth.login.connectingToGitHub', this.locale),
loaderText: t('Connecting to GitHub...', this.locale),
asyncStorageChecked: false,
};
}
Expand Down Expand Up @@ -240,7 +240,7 @@ class Login extends Component {
this.setState({
code,
showLoader: true,
loaderText: translate('auth.login.preparingGitPoint', this.locale),
loaderText: t('Preparing GitPoint...', this.locale),
});

stateRandom = Math.random().toString();
Expand Down Expand Up @@ -286,37 +286,49 @@ class Login extends Component {
<SlideWelcome>
<GitPointLogo />
<SlideTitle>
{translate('auth.login.welcomeTitle', locale)}
{t('Welcome to GitPoint', locale)}
</SlideTitle>
<SlideText>
{translate('auth.login.welcomeMessage', locale)}
{t(
'One of the most feature-rich GitHub clients that is 100% free',
locale
)}
</SlideText>
</SlideWelcome>
<SlideNotifications>
<SlideIcon name="bell" />
<SlideTitle>
{translate('auth.login.notificationsTitle', locale)}
{t('Control notifications', locale)}
</SlideTitle>
<SlideText>
{translate('auth.login.notificationsMessage', locale)}
{t(
'View and control all of your unread and participating notifications',
locale
)}
</SlideText>
</SlideNotifications>
<SlideReposAndUsers>
<SlideIcon name="repo" />
<SlideTitle>
{translate('auth.login.reposTitle', locale)}
{t('Repositories and Users', locale)}
</SlideTitle>
<SlideText>
{translate('auth.login.reposMessage', locale)}
{t(
'Easily obtain repository, user and organization information',
locale
)}
</SlideText>
</SlideReposAndUsers>
<SlideIssuesAndPrs>
<SlideIcon name="git-pull-request" />
<SlideTitle>
{translate('auth.login.issuesTitle', locale)}
{t('Issues and Pull Requests', locale)}
</SlideTitle>
<SlideText>
{translate('auth.login.issuesMessage', locale)}
{t(
'Communicate on conversations, merge pull requests and more',
locale
)}
</SlideText>
</SlideIssuesAndPrs>
</Swiper>
Expand All @@ -325,7 +337,7 @@ class Login extends Component {
<SignInContainer>
<SignInButton
raised
title={translate('auth.login.signInButton', locale)}
title={t('SIGN IN', locale)}
onPress={() => this.setModalVisible(true)}
/>
</SignInContainer>
Expand Down Expand Up @@ -353,13 +365,13 @@ class Login extends Component {
</BrowserSection>
<MiniSection>
<BaseButton
title={translate('auth.login.cancel', locale)}
title={t('CANCEL', locale)}
disabled={this.state.cancelDisabled}
onPress={() => this.setModalVisible(!this.state.modalVisible)}
/>
{Platform.OS === 'android' && (
<TroublesLink onPress={() => openURLInView(loginUrl)}>
{translate('auth.login.troubles', locale)}
{t("Can't login?", locale)}
</TroublesLink>
)}
</MiniSection>
Expand Down
72 changes: 45 additions & 27 deletions src/auth/screens/privacy-policy.screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from 'styled-components';
import { ScrollView } from 'react-native';

import { ViewContainer } from 'components';
import { translate } from 'utils';
import { t } from 'utils';
import { colors, fonts, normalize } from 'config';
import { v3 } from 'api';

Expand Down Expand Up @@ -56,76 +56,94 @@ export class PrivacyPolicyScreen extends Component {
<ViewContainer>
<ScrollView>
<Container>
<Title>
{translate('auth.privacyPolicy.effectiveDate', locale)}
</Title>
<Title>{t('Last updated: July 15, 2017', locale)}</Title>

<Section>
<StyledText>
{translate('auth.privacyPolicy.introduction', locale)}
{t(
"We're glad you decided to use GitPoint. This Privacy Policy is here to inform you about what we do \u2014 and do not do \u2014 with our user's data.",
locale
)}
</StyledText>
</Section>

<Section>
<SectionTitle>
{translate('auth.privacyPolicy.userDataTitle', locale)}
</SectionTitle>
<SectionTitle>{t('USER DATA', locale)}</SectionTitle>

<StyledText>
{translate('auth.privacyPolicy.userData1', locale)}
{t(
"We do not do anything with your GitHub information. After authenticating, the user's OAuth token is persisted directly on their device storage. It is not possible for us to retrieve that information. We never view a user's access token nor store it whatsoever.",
locale
)}
</StyledText>

<StyledText>
{translate('auth.privacyPolicy.userData2', locale)}
{t(
"This means that in no way, shape or form do we ever view, use or share a user's GitHub data. If private data ever becomes visible at any point we will not record or view it. If it happens to be accidentally recorded, we will delete it immediately using secure erase methods. Again, we've set up authentication specifically so that this never happens.",
locale
)}
</StyledText>
</Section>

<Section>
<SectionTitle>
{translate('auth.privacyPolicy.analyticsInfoTitle', locale)}
</SectionTitle>
<SectionTitle>{t('ANALYTICS INFORMATION', locale)}</SectionTitle>

<StyledText>
{translate('auth.privacyPolicy.analyticsInfo1', locale)}
{t(
'We currently use Google Analytics and iTunes App Analytics to help us measure traffic and usage trends for the GitPoint. These tools collect information sent by your device including device and platform version, region and referrer. This information cannot reasonably be used to identify any particular individual user and no personal information is extracted.',
locale
)}
</StyledText>

<StyledText>
{translate('auth.privacyPolicy.analyticsInfo2', locale)}
{t(
"If we happen to include another third party platform to collect stack traces, error logs or more analytics information, we'll make sure that user data remains anonymized and encrypted.",
locale
)}
</StyledText>
</Section>

<Section>
<SectionTitle>
{translate('auth.privacyPolicy.openSourceTitle', locale)}
</SectionTitle>
<SectionTitle>{t('OPEN SOURCE', locale)}</SectionTitle>

<StyledText>
{translate('auth.privacyPolicy.openSource1', locale)}
{t(
'GitPoint is open source and the history of contributions to the platform will always be visible to the public.',
locale
)}
</StyledText>

<StyledText>
{translate('auth.privacyPolicy.openSource2', locale)}
{t(
'With each contribution to the app, code review is always performed to prevent anybody from including malicious code of any kind.',
locale
)}
</StyledText>
</Section>

<Section>
<SectionTitle>
{translate('auth.privacyPolicy.contactTitle', locale)}
</SectionTitle>
<SectionTitle>{t('CONTACT', locale)}</SectionTitle>

<StyledText>
{translate('auth.privacyPolicy.contact1', locale)}
{t(
'Thank you for reading our Privacy Policy. We hope you enjoy using GitPoint as much as we enjoyed building it.',
locale
)}
</StyledText>

<StyledText>
{translate('auth.privacyPolicy.contact2', locale)}{' '}
{t(
'If you have any questions about this Privacy Policy or GitPoint in general, please file an issue in the',
locale
)}{' '}
<Link
onPress={() =>
navigation.navigate('Repository', {
repositoryUrl: `${v3.root}/repos/gitpoint/git-point`,
})}
})
}
>
{translate('auth.privacyPolicy.contactLink', locale)}
{t('GitPoint repository', locale)}
</Link>
</StyledText>
</Section>
Expand Down
Loading