i18n interests, allow for fallbacks (#2692)
This commit is contained in:
parent
4058174678
commit
bb7ce215f7
9 changed files with 103 additions and 56 deletions
|
@ -4,11 +4,13 @@ import {View, ViewStyle, TextStyle} from 'react-native'
|
|||
import {useTheme, atoms as a, native} from '#/alf'
|
||||
import * as Toggle from '#/components/forms/Toggle'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {capitalize} from '#/lib/strings/capitalize'
|
||||
|
||||
import {INTEREST_TO_DISPLAY_NAME} from '#/screens/Onboarding/StepInterests/data'
|
||||
import {Context} from '#/screens/Onboarding/state'
|
||||
|
||||
export function InterestButton({interest}: {interest: string}) {
|
||||
const t = useTheme()
|
||||
const {interestsDisplayNames} = React.useContext(Context)
|
||||
const ctx = Toggle.useItemContext()
|
||||
|
||||
const styles = React.useMemo(() => {
|
||||
|
@ -72,7 +74,7 @@ export function InterestButton({interest}: {interest: string}) {
|
|||
native({paddingTop: 2}),
|
||||
ctx.selected ? styles.textSelected : {},
|
||||
]}>
|
||||
{INTEREST_TO_DISPLAY_NAME[interest]}
|
||||
{interestsDisplayNames[interest] || capitalize(interest)}
|
||||
</Text>
|
||||
</View>
|
||||
)
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
export const INTEREST_TO_DISPLAY_NAME: {
|
||||
[key: string]: string
|
||||
} = {
|
||||
news: 'News',
|
||||
journalism: 'Journalism',
|
||||
nature: 'Nature',
|
||||
art: 'Art',
|
||||
comics: 'Comics',
|
||||
writers: 'Writers',
|
||||
culture: 'Culture',
|
||||
sports: 'Sports',
|
||||
pets: 'Pets',
|
||||
animals: 'Animals',
|
||||
books: 'Books',
|
||||
education: 'Education',
|
||||
climate: 'Climate',
|
||||
science: 'Science',
|
||||
politics: 'Politics',
|
||||
fitness: 'Fitness',
|
||||
tech: 'Tech',
|
||||
dev: 'Software Dev',
|
||||
comedy: 'Comedy',
|
||||
gaming: 'Video Games',
|
||||
food: 'Food',
|
||||
cooking: 'Cooking',
|
||||
}
|
||||
|
||||
export type ApiResponseMap = {
|
||||
interests: string[]
|
||||
suggestedAccountDids: {
|
||||
[key: string]: string[]
|
||||
}
|
||||
suggestedFeedUris: {
|
||||
[key: string]: string[]
|
||||
}
|
||||
}
|
|
@ -17,17 +17,14 @@ import {getAgent} from '#/state/session'
|
|||
import {useAnalytics} from '#/lib/analytics/analytics'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {useOnboardingDispatch} from '#/state/shell'
|
||||
import {capitalize} from '#/lib/strings/capitalize'
|
||||
|
||||
import {Context} from '#/screens/Onboarding/state'
|
||||
import {Context, ApiResponseMap} from '#/screens/Onboarding/state'
|
||||
import {
|
||||
Title,
|
||||
Description,
|
||||
OnboardingControls,
|
||||
} from '#/screens/Onboarding/Layout'
|
||||
import {
|
||||
ApiResponseMap,
|
||||
INTEREST_TO_DISPLAY_NAME,
|
||||
} from '#/screens/Onboarding/StepInterests/data'
|
||||
import {InterestButton} from '#/screens/Onboarding/StepInterests/InterestButton'
|
||||
import {IconCircle} from '#/screens/Onboarding/IconCircle'
|
||||
|
||||
|
@ -36,7 +33,7 @@ export function StepInterests() {
|
|||
const t = useTheme()
|
||||
const {track} = useAnalytics()
|
||||
const {gtMobile} = useBreakpoints()
|
||||
const {state, dispatch} = React.useContext(Context)
|
||||
const {state, dispatch, interestsDisplayNames} = React.useContext(Context)
|
||||
const [saving, setSaving] = React.useState(false)
|
||||
const [interests, setInterests] = React.useState<string[]>(
|
||||
state.interestsStepResults.selectedInterests.map(i => i),
|
||||
|
@ -202,7 +199,9 @@ export function StepInterests() {
|
|||
<Toggle.Item
|
||||
key={interest}
|
||||
name={interest}
|
||||
label={INTEREST_TO_DISPLAY_NAME[interest]}>
|
||||
label={
|
||||
interestsDisplayNames[interest] || capitalize(interest)
|
||||
}>
|
||||
<InterestButton interest={interest} />
|
||||
</Toggle.Item>
|
||||
))}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue