Skip to content

Commit 8cacb3d

Browse files
committed
Register dynamic translation to fix warnings.
1 parent 05158e5 commit 8cacb3d

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

example/src/App.tsx

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,22 @@ import {
2222
DatePickerInput,
2323
// @ts-ignore TODO: try to fix expo to work with local library
2424
} from 'react-native-paper-dates'
25-
import { useCallback, useState } from 'react'
25+
import { useCallback, useEffect, useState } from 'react'
26+
import {
27+
ar,
28+
de,
29+
en,
30+
enGB,
31+
fr,
32+
he,
33+
hi,
34+
ko,
35+
nl,
36+
pl,
37+
pt,
38+
registerTranslation,
39+
tr,
40+
} from '../../src'
2641

2742
function App() {
2843
/** Hooks. */
@@ -78,6 +93,11 @@ function App() {
7893
time.hours !== undefined && timeDate.setHours(time.hours)
7994
time.minutes !== undefined && timeDate.setMinutes(time.minutes)
8095

96+
/** Use effects. */
97+
useEffect(() => {
98+
registerTranslation(locale, getImportTranslation(locale))
99+
}, [locale])
100+
81101
/** Callbacks. */
82102
const onConfirmTime = useCallback(
83103
({ hours, minutes }: any) => {
@@ -120,6 +140,36 @@ function App() {
120140
setRangeOpen(false)
121141
}, [setRangeOpen])
122142

143+
/** Functions. */
144+
const getImportTranslation = (currentLocale: string) => {
145+
switch (currentLocale) {
146+
case 'ar':
147+
return ar
148+
case 'en':
149+
return en
150+
case 'de':
151+
return de
152+
case 'fr':
153+
return fr
154+
case 'he':
155+
return he
156+
case 'hi':
157+
return hi
158+
case 'ko':
159+
return ko
160+
case 'nl':
161+
return nl
162+
case 'pl':
163+
return pl
164+
case 'pt':
165+
return pt
166+
case 'tr':
167+
return tr
168+
default:
169+
return enGB
170+
}
171+
}
172+
123173
return (
124174
<>
125175
<ScrollView

0 commit comments

Comments
 (0)