Merge branch '511-use-translation-library-for-license-component' into 'master'

Use translation library for license component

Closes #511

See merge request bloodyhealth/drip!373
This commit is contained in:
Lisa
2022-03-26 10:21:26 +00:00
5 changed files with 28 additions and 26 deletions
@@ -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>
+1 -1
View File
@@ -9,7 +9,7 @@ import { openDb } from '../db'
import App from './app'
import AppLoadingView from './common/app-loading'
import AppStatusBar from './common/app-status-bar'
import License from './license'
import License from './License'
import PasswordPrompt from './password-prompt'
import store from "../store"
+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>
)