Skip to content

Commit

Permalink
Localize test strings
Browse files Browse the repository at this point in the history
  • Loading branch information
majakomel committed Jan 13, 2025
1 parent 49d06ed commit e34271a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
10 changes: 6 additions & 4 deletions components/dashboard/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Controller, useForm } from 'react-hook-form'
import { useIntl } from 'react-intl'

import DateRangePicker from 'components/DateRangePicker'
import { SOCIAL_MEDIA_TESTS_STRINGS } from 'pages/social-media'
import { getLocalisedRegionName } from 'utils/i18nCountries'

const cleanedUpData = (values) => {
Expand Down Expand Up @@ -36,8 +37,11 @@ export const Form = ({
}, [domains])

const appOptions = useMemo(() => {
return apps?.map((a) => ({ label: a, value: a }))
}, [apps])
return apps?.map((a) => ({
label: intl.formatMessage({ id: SOCIAL_MEDIA_TESTS_STRINGS[a] }),
value: a,
}))
}, [apps, intl])

// initial placement of query params when they are not defined
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
Expand All @@ -57,8 +61,6 @@ export const Form = ({
router.replace(href, undefined, { shallow: true })
}, [])

console.log('query', query)

// Sync page URL params with changes from form values
const onChange = useCallback(
({ since, until, probe_cc }) => {
Expand Down
16 changes: 15 additions & 1 deletion pages/social-media.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ const SOCIAL_MEDIA_IM_TESTS = [
'facebook_messenger',
]

export const SOCIAL_MEDIA_TESTS_STRINGS = {
telegram: 'Tests.Telegram.Name',
facebook_messenger: 'Tests.Facebook.Name',
whatsapp: 'Tests.WhatsApp.Name',
signal: 'Tests.Signal.Name',
psiphon: 'Tests.Psiphon.Name',
tor: 'Tests.Tor.Name',
torsf: 'Tests.TorSnowflake.Name',
}

export const getServerSideProps = async () => {
try {
const { reports, findings, countries, selectedCountries } =
Expand Down Expand Up @@ -101,7 +111,11 @@ const Page = (props) => {
<ul className="mt-4">
{SOCIAL_MEDIA_IM_TESTS.map((d) => (
<li key={d}>
<a href={`#${d}`}>{d}</a>
<a href={`#${d}`}>
{intl.formatMessage({
id: SOCIAL_MEDIA_TESTS_STRINGS[d],
})}
</a>
</li>
))}
</ul>
Expand Down

0 comments on commit e34271a

Please sign in to comment.