511 Use translation function in license components

This commit is contained in:
Lisa Hillebrand
2021-08-15 17:08:15 +02:00
parent 4f93d30872
commit 9596f8e52f
4 changed files with 27 additions and 25 deletions
+8 -8
View File
@@ -1,6 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { BackHandler, StyleSheet, View } from 'react-native'
import { useTranslation } from 'react-i18next'
import AppPage from './common/app-page'
import AppText from './common/app-text'
@@ -9,28 +10,27 @@ import Segment from './common/segment'
import { saveLicenseFlag } from '../local-storage'
import { shared } from '../i18n/en/labels'
import settingsLabels from '../i18n/en/settings'
import { Containers } from '../styles'
const labels = settingsLabels.license
export default function License({ setLicense }) {
const onAcceptLicense = async () => {
await saveLicenseFlag()
setLicense()
}
const { t } = useTranslation()
const currentYear = new Date().getFullYear()
return (
<AppPage testID="licensePage">
<Segment last testID="test" title={labels.title}>
<AppText testID="test">{labels.text}</AppText>
<Segment last testID="test" title={t("settings.license.title")}>
<AppText testID="test">{t("settings.license.text", { currentYear })}</AppText>
<View style={styles.container}>
<Button onPress={BackHandler.exitApp} testID="licenseCancelButton">
{shared.cancel}
{t("labels.shared.cancel")}
</Button>
<Button isCTA onPress={onAcceptLicense} testID="licenseOkButton">
{shared.ok}
{t("labels.shared.ok")}
</Button>
</View>
</Segment>
+6 -4
View File
@@ -1,16 +1,18 @@
import React from 'react'
import { useTranslation } from 'react-i18next'
import AppPage from '../common/app-page'
import AppText from '../common/app-text'
import Segment from '../common/segment'
import labels from '../../i18n/en/settings'
const License = () => {
const { t } = useTranslation()
const currentYear = new Date().getFullYear()
return (
<AppPage title={labels.license.title}>
<AppPage title={t("settings.license.title")}>
<Segment last>
<AppText>{labels.license.text}</AppText>
<AppText>{t("settings.license.text", { currentYear })}</AppText>
</Segment>
</AppPage>
)
+13 -3
View File
@@ -1,12 +1,22 @@
{
"labels": {
"bleedingPrediction": {
"noPrediction": "As soon as you have tracked 3 menstrual cycles, drip will make predictions for the next ones."
},
"home": {
"cycleDay": " day of your cycle",
"cyclePhase": " cycle phase - ",
"addDataForToday": "add data for today"
},
"bleedingPrediction": {
"noPrediction": "As soon as you have tracked 3 menstrual cycles, drip will make predictions for the next ones."
},
"shared": {
"cancel": "Cancel",
"ok": "OK"
}
},
"settings": {
"license": {
"title": "drip is an open-source cycle tracking app",
"text": "Copyright (C) {{currentYear}} Bloody Health GbR\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details: https://www.gnu.org/licenses/gpl-3.0.html\n\nYou can contact us by bloodyhealth@mailbox.org."
}
}
}
-10
View File
@@ -1,7 +1,5 @@
import links from './links'
const currentYear = new Date().getFullYear()
export default {
title: 'Settings',
menuItems: {
@@ -118,14 +116,6 @@ export default {
title: 'Remember to think for yourself',
text: `drip makes period predictions for you and helps you apply NFP fertility awareness rules. But please remember that this app is made by humans, and humans make mistakes. Always think for yourself: "Does this make sense?" Remember, you don't need an app to understand your cycle! However, drip wants to support you and make period tracking easier, more transparent and secure.`,
},
license: {
title: 'drip is an open-source cycle tracking app',
text: `Copyright (C) ${currentYear} Bloody Health GbR
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details: https://www.gnu.org/licenses/gpl-3.0.html
You can contact us by bloodyhealth@mailbox.org.`
},
version: {
title: 'Version'
},