Skip to content

Commit

Permalink
feat(forms): add Norwegian translation to country list
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Oct 30, 2023
1 parent 594ea72 commit e6d7467
Show file tree
Hide file tree
Showing 3 changed files with 393 additions and 249 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ function PhoneNumber(props: Props) {
? value.match(/^(\+[^ ]+)? ?(.*)$/)
: [undefined, '', '']

const lang = sharedContext.locale.split('-')[0]
const countryCodeData = useMemo(
() =>
countries.map((country) => ({
selectedKey: `+${country.code}`,
selected_value: `${country.iso} (+${country.code})`,
content: `+${country.code} ${country.name}`,
content: `+${country.code} ${country[lang] ?? country.en}`,
})),
[]
[sharedContext.locale]
)

const handleCountryCodeChange = useCallback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from 'react'
import React, { useContext, useMemo } from 'react'
import Selection, { Props as SelectionProps } from '../Selection'
import Option from '../Option'
import countries from '../../constants/countries'
Expand All @@ -23,17 +23,20 @@ function SelectCountry(props: Props) {
},
}

return (
<Selection {...selectComponentProps}>
{countries.map((country) => (
const lang = sharedContext.locale.split('-')[0]
const countryOptions = useMemo(
() =>
countries.map((country) => (
<Option
key={country.iso}
value={country.iso}
title={country.name}
title={country[lang] ?? country.en}
/>
))}
</Selection>
)),
[sharedContext.locale]
)

return <Selection {...selectComponentProps}>{countryOptions}</Selection>
}

SelectCountry._supportsSpacingProps = true
Expand Down
Loading

0 comments on commit e6d7467

Please sign in to comment.