Skip to content

Commit 80b4fe9

Browse files
authored
refactor: translate() to t() (#777)
* refactor: redo relative time translations * refactor: migrate from translate() to t() * refactor: migrate from translate() to t() * feat: sort alphabetically * fix: handle numbers in interpolation, also accept {{ }} * fix: get rid of {{ }} to avoid problems with react-native-i18n * refactor: migrate relative time translations * fix: every child in an array needs to have a key prop * refactor: remove untranslated strings * refactor: remove untranslated strings * refactor: hold typeof in a const * refactor: use String.replace() callback instead of while(re.exec) * chore: run files through prettier [skip-ci] * fix: disable i18n defaultSeparator
1 parent 39d0de4 commit 80b4fe9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4067
-6435
lines changed

ios/ip.txt

Whitespace-only changes.

routes.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Icon } from 'react-native-elements';
1010

1111
import { NotificationIcon } from 'components';
1212
import { colors } from 'config';
13-
import { translate } from 'utils';
13+
import { t } from 'utils';
1414

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

149148
return {
150149
title: `${langTitle} #${number}`,

scripts/extract-i18n.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,18 @@ const generateFiles = (config, messages) => {
113113
}
114114
});
115115

116+
const ordered = {};
117+
118+
Object.keys(newMessages)
119+
.sort()
120+
.forEach(key => {
121+
ordered[key] = newMessages[key];
122+
});
123+
116124
// Write the new message file
117125
fs.writeFile(
118126
filepath,
119-
`module.exports = ${JSON.stringify(newMessages, null, 2)};`,
127+
`module.exports = ${JSON.stringify(ordered, null, 2)};`,
120128
'utf8',
121129
err => {
122130
if (err) throw err;

src/auth/screens/auth-profile.screen.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
} from 'components';
2121
import { colors, fonts, normalize } from 'config';
2222
import { getUser, getOrgs, getStarCount } from 'auth';
23-
import { emojifyText, openURLInView, translate } from 'utils';
23+
import { emojifyText, openURLInView, t } from 'utils';
2424

2525
const mapStateToProps = state => ({
2626
user: state.auth.user,
@@ -132,8 +132,9 @@ class AuthProfile extends Component {
132132
menuIcon="gear"
133133
menuAction={() =>
134134
navigation.navigate('UserOptions', {
135-
title: translate('auth.userOptions.title', locale),
136-
})}
135+
title: t('Options', locale),
136+
})
137+
}
137138
>
138139
{isPending && (
139140
<ActivityIndicator
@@ -146,7 +147,7 @@ class AuthProfile extends Component {
146147
{hasInitialUser &&
147148
user.bio &&
148149
user.bio !== '' && (
149-
<SectionList title={translate('common.bio', locale)}>
150+
<SectionList title={t('BIO', locale)}>
150151
<BioListItem
151152
titleNumberOfLines={0}
152153
title={emojifyText(user.bio)}
@@ -167,9 +168,9 @@ class AuthProfile extends Component {
167168
{!isPending && (
168169
<View>
169170
<SectionList
170-
title={translate('common.orgs', locale)}
171+
title={t('ORGANIZATIONS', locale)}
171172
noItems={orgs.length === 0}
172-
noItemsMessage={translate('common.noOrgsMessage', locale)}
173+
noItemsMessage={t('No organizations', locale)}
173174
>
174175
{orgs.map(item => (
175176
<UserListItem
@@ -179,16 +180,14 @@ class AuthProfile extends Component {
179180
/>
180181
))}
181182
<Note>
182-
{translate('auth.profile.orgsRequestApprovalTop', locale)}
183+
{t("Can't see all your organizations?", locale)}
183184
{'\n'}
184185
<NoteLink
185186
onPress={() =>
186-
openURLInView('https://github.com/settings/applications')}
187+
openURLInView('https://github.com/settings/applications')
188+
}
187189
>
188-
{translate(
189-
'auth.profile.orgsRequestApprovalBottom',
190-
locale
191-
)}
190+
{t('You may have to request approval for them.', locale)}
192191
</NoteLink>
193192
</Note>
194193
</SectionList>

src/auth/screens/language-setting.screen.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ListItem } from 'react-native-elements';
77
import { colors, fonts } from 'config';
88
import { changeLocale } from 'auth';
99
import { bindActionCreators } from 'redux';
10-
import { emojifyText, translate } from 'utils';
10+
import { emojifyText, t } from 'utils';
1111
import { NavigationActions } from 'react-navigation';
1212
import { ViewContainer } from 'components';
1313
import languages from './language-settings';
@@ -51,7 +51,7 @@ class LanguageSettings extends Component {
5151
if (nextState.locale !== this.props.locale) {
5252
const navigationParams = NavigationActions.setParams({
5353
params: {
54-
title: translate('auth.userOptions.language', nextState.locale),
54+
title: t('Language', nextState.locale),
5555
},
5656
key: nextState.navigation.state.key,
5757
});

src/auth/screens/login.screen.js

+26-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ViewContainer, ErrorScreen } from 'components';
1212
import { colors, fonts, normalize } from 'config';
1313
import { CLIENT_ID } from 'api';
1414
import { auth, getUser } from 'auth';
15-
import { openURLInView, translate, resetNavigationTo } from 'utils';
15+
import { openURLInView, t, resetNavigationTo } from 'utils';
1616
import styled from 'styled-components';
1717

1818
let stateRandom = Math.random().toString();
@@ -182,7 +182,7 @@ class Login extends Component {
182182
modalVisible: false,
183183
cancelDisabled: false,
184184
showLoader: true,
185-
loaderText: translate('auth.login.connectingToGitHub', this.locale),
185+
loaderText: t('Connecting to GitHub...', this.locale),
186186
asyncStorageChecked: false,
187187
};
188188
}
@@ -240,7 +240,7 @@ class Login extends Component {
240240
this.setState({
241241
code,
242242
showLoader: true,
243-
loaderText: translate('auth.login.preparingGitPoint', this.locale),
243+
loaderText: t('Preparing GitPoint...', this.locale),
244244
});
245245

246246
stateRandom = Math.random().toString();
@@ -286,37 +286,49 @@ class Login extends Component {
286286
<SlideWelcome>
287287
<GitPointLogo />
288288
<SlideTitle>
289-
{translate('auth.login.welcomeTitle', locale)}
289+
{t('Welcome to GitPoint', locale)}
290290
</SlideTitle>
291291
<SlideText>
292-
{translate('auth.login.welcomeMessage', locale)}
292+
{t(
293+
'One of the most feature-rich GitHub clients that is 100% free',
294+
locale
295+
)}
293296
</SlideText>
294297
</SlideWelcome>
295298
<SlideNotifications>
296299
<SlideIcon name="bell" />
297300
<SlideTitle>
298-
{translate('auth.login.notificationsTitle', locale)}
301+
{t('Control notifications', locale)}
299302
</SlideTitle>
300303
<SlideText>
301-
{translate('auth.login.notificationsMessage', locale)}
304+
{t(
305+
'View and control all of your unread and participating notifications',
306+
locale
307+
)}
302308
</SlideText>
303309
</SlideNotifications>
304310
<SlideReposAndUsers>
305311
<SlideIcon name="repo" />
306312
<SlideTitle>
307-
{translate('auth.login.reposTitle', locale)}
313+
{t('Repositories and Users', locale)}
308314
</SlideTitle>
309315
<SlideText>
310-
{translate('auth.login.reposMessage', locale)}
316+
{t(
317+
'Easily obtain repository, user and organization information',
318+
locale
319+
)}
311320
</SlideText>
312321
</SlideReposAndUsers>
313322
<SlideIssuesAndPrs>
314323
<SlideIcon name="git-pull-request" />
315324
<SlideTitle>
316-
{translate('auth.login.issuesTitle', locale)}
325+
{t('Issues and Pull Requests', locale)}
317326
</SlideTitle>
318327
<SlideText>
319-
{translate('auth.login.issuesMessage', locale)}
328+
{t(
329+
'Communicate on conversations, merge pull requests and more',
330+
locale
331+
)}
320332
</SlideText>
321333
</SlideIssuesAndPrs>
322334
</Swiper>
@@ -325,7 +337,7 @@ class Login extends Component {
325337
<SignInContainer>
326338
<SignInButton
327339
raised
328-
title={translate('auth.login.signInButton', locale)}
340+
title={t('SIGN IN', locale)}
329341
onPress={() => this.setModalVisible(true)}
330342
/>
331343
</SignInContainer>
@@ -353,13 +365,13 @@ class Login extends Component {
353365
</BrowserSection>
354366
<MiniSection>
355367
<BaseButton
356-
title={translate('auth.login.cancel', locale)}
368+
title={t('CANCEL', locale)}
357369
disabled={this.state.cancelDisabled}
358370
onPress={() => this.setModalVisible(!this.state.modalVisible)}
359371
/>
360372
{Platform.OS === 'android' && (
361373
<TroublesLink onPress={() => openURLInView(loginUrl)}>
362-
{translate('auth.login.troubles', locale)}
374+
{t("Can't login?", locale)}
363375
</TroublesLink>
364376
)}
365377
</MiniSection>

src/auth/screens/privacy-policy.screen.js

+45-27
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styled from 'styled-components';
33
import { ScrollView } from 'react-native';
44

55
import { ViewContainer } from 'components';
6-
import { translate } from 'utils';
6+
import { t } from 'utils';
77
import { colors, fonts, normalize } from 'config';
88
import { v3 } from 'api';
99

@@ -56,76 +56,94 @@ export class PrivacyPolicyScreen extends Component {
5656
<ViewContainer>
5757
<ScrollView>
5858
<Container>
59-
<Title>
60-
{translate('auth.privacyPolicy.effectiveDate', locale)}
61-
</Title>
59+
<Title>{t('Last updated: July 15, 2017', locale)}</Title>
6260

6361
<Section>
6462
<StyledText>
65-
{translate('auth.privacyPolicy.introduction', locale)}
63+
{t(
64+
"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.",
65+
locale
66+
)}
6667
</StyledText>
6768
</Section>
6869

6970
<Section>
70-
<SectionTitle>
71-
{translate('auth.privacyPolicy.userDataTitle', locale)}
72-
</SectionTitle>
71+
<SectionTitle>{t('USER DATA', locale)}</SectionTitle>
7372

7473
<StyledText>
75-
{translate('auth.privacyPolicy.userData1', locale)}
74+
{t(
75+
"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.",
76+
locale
77+
)}
7678
</StyledText>
7779

7880
<StyledText>
79-
{translate('auth.privacyPolicy.userData2', locale)}
81+
{t(
82+
"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.",
83+
locale
84+
)}
8085
</StyledText>
8186
</Section>
8287

8388
<Section>
84-
<SectionTitle>
85-
{translate('auth.privacyPolicy.analyticsInfoTitle', locale)}
86-
</SectionTitle>
89+
<SectionTitle>{t('ANALYTICS INFORMATION', locale)}</SectionTitle>
8790

8891
<StyledText>
89-
{translate('auth.privacyPolicy.analyticsInfo1', locale)}
92+
{t(
93+
'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.',
94+
locale
95+
)}
9096
</StyledText>
9197

9298
<StyledText>
93-
{translate('auth.privacyPolicy.analyticsInfo2', locale)}
99+
{t(
100+
"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.",
101+
locale
102+
)}
94103
</StyledText>
95104
</Section>
96105

97106
<Section>
98-
<SectionTitle>
99-
{translate('auth.privacyPolicy.openSourceTitle', locale)}
100-
</SectionTitle>
107+
<SectionTitle>{t('OPEN SOURCE', locale)}</SectionTitle>
101108

102109
<StyledText>
103-
{translate('auth.privacyPolicy.openSource1', locale)}
110+
{t(
111+
'GitPoint is open source and the history of contributions to the platform will always be visible to the public.',
112+
locale
113+
)}
104114
</StyledText>
105115

106116
<StyledText>
107-
{translate('auth.privacyPolicy.openSource2', locale)}
117+
{t(
118+
'With each contribution to the app, code review is always performed to prevent anybody from including malicious code of any kind.',
119+
locale
120+
)}
108121
</StyledText>
109122
</Section>
110123

111124
<Section>
112-
<SectionTitle>
113-
{translate('auth.privacyPolicy.contactTitle', locale)}
114-
</SectionTitle>
125+
<SectionTitle>{t('CONTACT', locale)}</SectionTitle>
115126

116127
<StyledText>
117-
{translate('auth.privacyPolicy.contact1', locale)}
128+
{t(
129+
'Thank you for reading our Privacy Policy. We hope you enjoy using GitPoint as much as we enjoyed building it.',
130+
locale
131+
)}
118132
</StyledText>
119133

120134
<StyledText>
121-
{translate('auth.privacyPolicy.contact2', locale)}{' '}
135+
{t(
136+
'If you have any questions about this Privacy Policy or GitPoint in general, please file an issue in the',
137+
locale
138+
)}{' '}
122139
<Link
123140
onPress={() =>
124141
navigation.navigate('Repository', {
125142
repositoryUrl: `${v3.root}/repos/gitpoint/git-point`,
126-
})}
143+
})
144+
}
127145
>
128-
{translate('auth.privacyPolicy.contactLink', locale)}
146+
{t('GitPoint repository', locale)}
129147
</Link>
130148
</StyledText>
131149
</Section>

0 commit comments

Comments
 (0)