Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
0b447178
Commit
0b447178
authored
3 years ago
by
Lisa Hillebrand
Browse files
Options
Downloads
Patches
Plain Diff
162 Use hook to merge component path with translation key
parent
f3cabe5c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/Home.js
+5
-5
5 additions, 5 deletions
components/Home.js
hooks/useComponentTranslation.js
+11
-0
11 additions, 0 deletions
hooks/useComponentTranslation.js
with
16 additions
and
5 deletions
components/Home.js
+
5
−
5
View file @
0b447178
...
...
@@ -16,11 +16,11 @@ import { determinePredictionText, formatWithOrdinalSuffix } from './helpers/home
import
{
Colors
,
Fonts
,
Sizes
,
Spacing
}
from
'
../styles
'
import
{
LocalDate
}
from
'
js-joda
'
import
{
useTranslation
}
from
'
react-i18next
'
import
use
Component
Translation
from
'
../hooks/useComponentTranslation
'
const
Home
=
({
navigate
,
setDate
})
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
use
Component
Translation
(
'
components.Home
'
);
function
navigateToCycleDayView
()
{
setDate
(
todayDateString
)
...
...
@@ -46,14 +46,14 @@ const Home = ({ navigate, setDate }) => {
{
cycleDayNumber
&&
<
View
style
=
{
styles
.
line
}
>
<
AppText
style
=
{
styles
.
whiteSubtitle
}
>
{
cycleDayText
}
<
/AppText
>
<
AppText
style
=
{
styles
.
turquoiseText
}
>
{
t
(
'
components.Home.
cycleDay
'
)}
<
/AppText
>
<
AppText
style
=
{
styles
.
turquoiseText
}
>
{
t
(
'
cycleDay
'
)}
<
/AppText
>
<
/View
>
}
{
phase
&&
<
View
style
=
{
styles
.
line
}
>
<
AppText
style
=
{
styles
.
whiteSubtitle
}
>
{
formatWithOrdinalSuffix
(
phase
)}
<
/AppText
>
<
AppText
style
=
{
styles
.
turquoiseText
}
>
{
t
(
'
components.Home.
cyclePhase
'
)}
{
t
(
'
cyclePhase
'
)}
<
/AppText
>
<
AppText
style
=
{
styles
.
turquoiseText
}
>
{
status
}
<
/AppText
>
<
Asterisk
/>
...
...
@@ -63,7 +63,7 @@ const Home = ({ navigate, setDate }) => {
<
AppText
style
=
{
styles
.
turquoiseText
}
>
{
prediction
}
<
/AppText
>
<
/View
>
<
Button
isCTA
isSmall
=
{
false
}
onPress
=
{
navigateToCycleDayView
}
>
{
t
(
'
components.Home.
addDataForToday
'
)}
{
t
(
'
addDataForToday
'
)}
<
/Button
>
{
phase
&&
(
<
View
style
=
{
styles
.
asteriskLine
}
>
...
...
This diff is collapsed.
Click to expand it.
hooks/useComponentTranslation.js
0 → 100644
+
11
−
0
View file @
0b447178
import
{
useTranslation
}
from
"
react-i18next
"
export
default
function
useComponentTranslation
(
componentPath
)
{
const
{
t
,
i18n
}
=
useTranslation
();
function
translate
(
code
,
options
)
{
const
mergedPath
=
`
${
componentPath
}
.
${
code
}
`
;
const
translation
=
t
(
mergedPath
,
options
);
return
translation
!==
mergedPath
?
translation
:
t
(
code
,
options
);
}
return
{
t
:
translate
,
i18n
};
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment