Some i18n

This commit is contained in:
Eric Bailey
2024-01-17 15:30:52 -06:00
parent d76ca60839
commit 13409f889c
3 changed files with 25 additions and 16 deletions
+6 -5
View File
@@ -2,6 +2,8 @@ import React, {useImperativeHandle} from 'react'
import {View, TouchableWithoutFeedback} from 'react-native' import {View, TouchableWithoutFeedback} from 'react-native'
import {FocusScope} from '@tamagui/focus-scope' import {FocusScope} from '@tamagui/focus-scope'
import Animated, {FadeInDown, FadeIn} from 'react-native-reanimated' import Animated, {FadeInDown, FadeIn} from 'react-native-reanimated'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useTheme, atoms as a, useBreakpoints, web} from '#/alf' import {useTheme, atoms as a, useBreakpoints, web} from '#/alf'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
@@ -22,6 +24,7 @@ export function Outer({
onClose, onClose,
children, children,
}: React.PropsWithChildren<DialogOuterProps>) { }: React.PropsWithChildren<DialogOuterProps>) {
const {_} = useLingui()
const t = useTheme() const t = useTheme()
const {gtMobile} = useBreakpoints() const {gtMobile} = useBreakpoints()
const [isOpen, setIsOpen] = React.useState(false) const [isOpen, setIsOpen] = React.useState(false)
@@ -74,7 +77,7 @@ export function Outer({
<Context.Provider value={context}> <Context.Provider value={context}>
<TouchableWithoutFeedback <TouchableWithoutFeedback
accessibilityHint={undefined} accessibilityHint={undefined}
accessibilityLabel="Close active dialog" accessibilityLabel={_(msg`Close active dialog`)}
onPress={close}> onPress={close}>
<View <View
style={[ style={[
@@ -170,6 +173,7 @@ export function Handle() {
} }
export function Close() { export function Close() {
const {_} = useLingui()
const t = useTheme() const t = useTheme()
const {close} = useDialogContext() const {close} = useDialogContext()
return ( return (
@@ -182,10 +186,7 @@ export function Close() {
right: a.pr_lg.paddingRight, right: a.pr_lg.paddingRight,
}, },
]}> ]}>
<Button <Button onPress={close} label={_(msg`Close active dialog`)}>
onPress={close}
accessibilityLabel="Close dialog"
accessibilityHint="Clicking this button will close the current dialog.">
{() => ( {() => (
<View <View
style={[ style={[
+6 -2
View File
@@ -1,5 +1,7 @@
import React from 'react' import React from 'react'
import {View, PressableProps} from 'react-native' import {View, PressableProps} from 'react-native'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useTheme, atoms as a} from '#/alf' import {useTheme, atoms as a} from '#/alf'
import {H4, P} from '#/components/Typography' import {H4, P} from '#/components/Typography'
@@ -80,13 +82,14 @@ export function Actions({children}: React.PropsWithChildren<{}>) {
export function Cancel({ export function Cancel({
children, children,
}: React.PropsWithChildren<{onPress?: PressableProps['onPress']}>) { }: React.PropsWithChildren<{onPress?: PressableProps['onPress']}>) {
const {_} = useLingui()
const {close} = Dialog.useDialogContext() const {close} = Dialog.useDialogContext()
return ( return (
<Button <Button
variant="solid" variant="solid"
color="secondary" color="secondary"
size="small" size="small"
label="Cancel" label={_(msg`Cancel`)}
onPress={close}> onPress={close}>
{children} {children}
</Button> </Button>
@@ -97,6 +100,7 @@ export function Action({
children, children,
onPress, onPress,
}: React.PropsWithChildren<{onPress?: () => void}>) { }: React.PropsWithChildren<{onPress?: () => void}>) {
const {_} = useLingui()
const {close} = Dialog.useDialogContext() const {close} = Dialog.useDialogContext()
const handleOnPress = React.useCallback(() => { const handleOnPress = React.useCallback(() => {
close() close()
@@ -107,7 +111,7 @@ export function Action({
variant="solid" variant="solid"
color="primary" color="primary"
size="small" size="small"
label="Confirm" label={_(msg`Confirm`)}
onPress={handleOnPress}> onPress={handleOnPress}>
{children} {children}
</Button> </Button>
+13 -9
View File
@@ -163,15 +163,6 @@ export function Forms() {
<Toggle.Switch /> <Toggle.Switch />
<Toggle.Label>Click me</Toggle.Label> <Toggle.Label>Click me</Toggle.Label>
</Toggle.Item> </Toggle.Item>
<Button
variant="solid"
color="primary"
size="small"
label="Reset"
onPress={() => setToggleGroupAValues(['a'])}>
Reset
</Button>
</View> </View>
</Toggle.Group> </Toggle.Group>
@@ -235,6 +226,19 @@ export function Forms() {
</Toggle.Group> </Toggle.Group>
</View> </View>
<Button
variant="gradient"
color="gradient_nordic"
size="small"
label="Reset all toggles"
onPress={() => {
setToggleGroupAValues(['a'])
setToggleGroupBValues(['a', 'b'])
setToggleGroupCValues(['a'])
}}>
Reset all toggles
</Button>
<View style={[a.gap_md, a.align_start, a.w_full]}> <View style={[a.gap_md, a.align_start, a.w_full]}>
<H3>ToggleButton</H3> <H3>ToggleButton</H3>