Skip to content

Commit 3e6cc66

Browse files
committed
feat: internationalize new copy
1 parent 69003dd commit 3e6cc66

File tree

6 files changed

+22
-4
lines changed

6 files changed

+22
-4
lines changed

src/Date/CalendarHeader.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { StyleSheet, View } from 'react-native'
33
import { IconButton, useTheme } from 'react-native-paper'
44
import DayNames, { dayNamesHeight } from './DayNames'
55
import type { DisableWeekDaysType } from './dateUtils'
6+
import { getTranslation } from '../translations/utils'
67

78
const buttonContainerHeight = 56
89
const buttonContainerMarginTop = 4
@@ -48,7 +49,7 @@ function CalendarHeader({
4849
>
4950
<IconButton
5051
icon="chevron-left"
51-
accessibilityLabel="Previous"
52+
accessibilityLabel={getTranslation(locale, 'previous')}
5253
onPress={onPrev}
5354
// RN types bug
5455
hasTVPreferredFocus={undefined}
@@ -64,7 +65,7 @@ function CalendarHeader({
6465
>
6566
<IconButton
6667
icon="chevron-right"
67-
accessibilityLabel="Next"
68+
accessibilityLabel={getTranslation(locale, 'next')}
6869
onPress={onNext}
6970
// RN types bug
7071
hasTVPreferredFocus={undefined}

src/Date/DatePickerModalContentHeader.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ export default function DatePickerModalContentHeader(
8080
<IconButton
8181
icon={collapsed ? 'pencil' : 'calendar'}
8282
accessibilityLabel={
83-
collapsed ? 'Type in date' : 'Pick date from calendar'
83+
collapsed
84+
? getTranslation(props.locale, 'typeInDate')
85+
: getTranslation(props.locale, 'pickDateFromCalendar')
8486
}
8587
color={color}
8688
onPress={onToggle}

src/Date/DatePickerModalHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function DatePickerModalHeader(
3131
<Appbar style={styles.appbarHeader}>
3232
<Appbar.Action
3333
icon="close"
34-
accessibilityLabel="Close"
34+
accessibilityLabel={getTranslation(locale, 'close')}
3535
onPress={props.onDismiss}
3636
color={color}
3737
testID="react-native-paper-dates-close"

src/translations/en.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@ const en: TranslationsType = {
1111
mustBeLowerThan: 'Must be earlier then',
1212
mustBeBetween: 'Must be between',
1313
dateIsDisabled: 'Day is not allowed',
14+
previous: 'Previous',
15+
next: 'Next',
16+
typeInDate: 'Type in date',
17+
pickDateFromCalendar: 'Pick date from calendar',
18+
close: 'Close',
1419
}
1520
export default en

src/translations/enGB.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@ const enGB: TranslationsType = {
1111
mustBeLowerThan: 'Must be earlier then',
1212
mustBeBetween: 'Must be between',
1313
dateIsDisabled: 'Day is not allowed',
14+
previous: 'Previous',
15+
next: 'Next',
16+
typeInDate: 'Type in date',
17+
pickDateFromCalendar: 'Pick date from calendar',
18+
close: 'Close',
1419
}
1520
export default enGB

src/translations/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ export type TranslationsType = {
88
mustBeLowerThan: string
99
mustBeBetween: string
1010
dateIsDisabled: string
11+
previous: string
12+
next: string
13+
typeInDate: string
14+
pickDateFromCalendar: string
15+
close: string
1116
}
1217

1318
let translationsPerLocale: Record<string, TranslationsType> = {}

0 commit comments

Comments
 (0)