Move "organization" I18n into a reusable hook

This commit is contained in:
Gary Tou 2024-10-25 21:21:31 -07:00
parent 0ba39e2e8b
commit 150cd44689
No known key found for this signature in database
GPG key ID: 1587ABD3593755C3
2 changed files with 13 additions and 5 deletions

View file

@ -4,13 +4,10 @@ import Checkbox from './checkbox'
import Field from './field'
// This is using country-list instead of country-list-js as it has a smaller bundle size
import { getNames } from 'country-list'
import useOrganizationI18n from '../organizationI18n'
export default function OrganizationInfoForm({ requiredFields }) {
const [org, setOrg] = useState('Organization')
useEffect(() => {
if (navigator.language === 'en-GB') setOrg('Organisation')
}, [])
const org = useOrganizationI18n()
return (
<>

View file

@ -0,0 +1,11 @@
import { useState, useEffect } from 'react'
export default function useOrganizationI18n() {
const [org, setOrg] = useState('Organization')
useEffect(() => {
if (navigator.language === 'en-GB') setOrg('Organisation')
}, [])
return org
}