Skip to content

Commit 72e9440

Browse files
committed
fix: translation keys
1 parent ce1a639 commit 72e9440

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

frontend/src/modules/details-page/header.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import React, { useState } from 'react'
22
import './style.module.scss'
33
import { Col, Popover, Input, Select, Tooltip, Modal, notification } from 'antd'
44
const { Option } = Select
5-
import { eventTrack } from '../../utils/misc'
5+
import { eventTrack, useTopicNames } from '../../utils/misc'
66
import { PlayCircleTwoTone } from '@ant-design/icons'
7-
import { resourceTypeToTopicType, topicNames } from '../../utils/misc'
7+
import { resourceTypeToTopicType } from '../../utils/misc'
88
import { languageOptions } from '../flexible-forms/view'
99
import classNames from 'classnames'
1010
import Button from '../../components/button'
@@ -40,6 +40,8 @@ const Header = ({
4040
setLikes,
4141
}) => {
4242
const router = useRouter()
43+
const topicNames = useTopicNames()
44+
4345
const bookmarked =
4446
relation &&
4547
relation.association &&

frontend/src/pages/knowledge-hub/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ const KnowledgeHub = ({
108108
const OPTION_PAGE_SIZE = 100
109109

110110
useEffect(() => {
111+
if (!isLoadMore) {
112+
originalResults.current = newResults
113+
}
114+
111115
const translateResults = async () => {
112116
const resultsToTranslate = originalResults.current
113117
if (router.locale !== 'en' && resultsToTranslate.length > 0) {
@@ -131,7 +135,7 @@ const KnowledgeHub = ({
131135
}
132136

133137
translateResults()
134-
}, [newResults, router.locale])
138+
}, [newResults, router.locale, isLoadMore])
135139

136140
useEffect(() => {
137141
setDisplayedOptions(tagOpts.slice(0, OPTION_PAGE_SIZE))

frontend/src/utils/misc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,28 @@ export const topicNames = (topic) => {
6363
return names[humps.camelize(topic)]
6464
}
6565

66+
export const useTopicNames = () => {
67+
const { i18n } = useLingui()
68+
69+
return (topic) => {
70+
const names = {
71+
initiative: i18n._(t`Initiative`),
72+
actionPlan: i18n._(t`Action Plan`),
73+
policy: i18n._(t`Legislation`),
74+
technicalResource: i18n._(t`Technical Resource`),
75+
financingResource: i18n._(t`Financing Resource`),
76+
event: i18n._(t`Event`),
77+
technology: i18n._(t`Technology`),
78+
organisation: i18n._(t`Entity`),
79+
stakeholder: i18n._(t`Individual`),
80+
capacityBuilding: i18n._(t`Capacity Building`),
81+
caseStudy: i18n._(t`Case Study`),
82+
dataCatalog: i18n._(t`Data Portal`),
83+
}
84+
return names[humps.camelize(topic)]
85+
}
86+
}
87+
6688
export const resourceSubTypes = new Set([
6789
'financing_resource',
6890
'technical_resource',

0 commit comments

Comments
 (0)