Skip to content

Commit 57ba7a3

Browse files
committed
fix: translate bundled application names
1 parent acfe7ce commit 57ba7a3

File tree

3 files changed

+31
-38
lines changed

3 files changed

+31
-38
lines changed

i18n/en.pot

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ msgstr ""
55
"Content-Type: text/plain; charset=utf-8\n"
66
"Content-Transfer-Encoding: 8bit\n"
77
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
8-
"POT-Creation-Date: 2021-03-17T12:13:51.869Z\n"
9-
"PO-Revision-Date: 2021-03-17T12:13:51.869Z\n"
8+
"POT-Creation-Date: 2021-03-17T14:45:51.504Z\n"
9+
"PO-Revision-Date: 2021-03-17T14:45:51.504Z\n"
1010

1111
msgid "No apps found"
1212
msgstr ""

src/components/AppList/index.js

+1-28
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import i18n from '@dhis2/d2-i18n'
22
import { PropTypes } from '@dhis2/prop-types'
3-
import {
4-
NoticeBox,
5-
CenteredContent,
6-
CircularLoader,
7-
InputField,
8-
} from '@dhis2/ui'
3+
import { InputField } from '@dhis2/ui'
94
import React from 'react'
105
import { useHistory } from 'react-router-dom'
116
import { useQueryParam, StringParam, withDefault } from 'use-query-params'
@@ -89,11 +84,8 @@ AllApps.propTypes = {
8984
}
9085

9186
const AppList = ({
92-
error,
93-
loading,
9487
apps,
9588
appsWithUpdates,
96-
errorLabel,
9789
updatesAvailableLabel,
9890
allAppsLabel,
9991
searchLabel,
@@ -106,22 +98,6 @@ const AppList = ({
10698
setQuery(value, 'replaceIn')
10799
}
108100

109-
if (error) {
110-
return (
111-
<NoticeBox error title={errorLabel}>
112-
{error.message}
113-
</NoticeBox>
114-
)
115-
}
116-
117-
if (loading) {
118-
return (
119-
<CenteredContent>
120-
<CircularLoader />
121-
</CenteredContent>
122-
)
123-
}
124-
125101
const searchFilter = app =>
126102
!query ||
127103
app.name.toLocaleLowerCase().includes(query.toLocaleLowerCase())
@@ -147,13 +123,10 @@ const AppList = ({
147123

148124
AppList.propTypes = {
149125
allAppsLabel: PropTypes.string.isRequired,
150-
errorLabel: PropTypes.string.isRequired,
151126
searchLabel: PropTypes.string.isRequired,
152127
updatesAvailableLabel: PropTypes.string.isRequired,
153128
apps: PropTypes.array,
154129
appsWithUpdates: PropTypes.array,
155-
error: PropTypes.object,
156-
loading: PropTypes.bool,
157130
}
158131

159132
export default AppList

src/components/CoreApps/CoreApps.js

+28-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useDataQuery, useConfig } from '@dhis2/app-runtime'
22
import i18n from '@dhis2/d2-i18n'
3+
import { NoticeBox, CenteredContent, CircularLoader } from '@dhis2/ui'
34
import React from 'react'
45
import getLatestVersion from '../../get-latest-version'
56
import AppList from '../AppList'
@@ -63,7 +64,28 @@ export const CoreApps = () => {
6364
const { baseUrl } = useConfig()
6465
const { loading, error, data } = useDataQuery(query)
6566

66-
const overridenCoreApps = data?.coreApps.filter(app => app.bundled)
67+
if (error) {
68+
return (
69+
<NoticeBox
70+
error
71+
title={i18n.t(
72+
'Something went wrong whilst loading your core apps'
73+
)}
74+
>
75+
{error.message}
76+
</NoticeBox>
77+
)
78+
}
79+
80+
if (loading) {
81+
return (
82+
<CenteredContent>
83+
<CircularLoader />
84+
</CenteredContent>
85+
)
86+
}
87+
88+
const overridenCoreApps = data.coreApps.filter(app => app.bundled)
6789
const apps = coreApps
6890
.map(coreApp => {
6991
const overridenApp = overridenCoreApps?.find(
@@ -72,13 +94,16 @@ export const CoreApps = () => {
7294
if (overridenApp) {
7395
return overridenApp
7496
}
75-
const iconUrl = data?.modules.modules.find(
97+
const module = data.modules.modules.find(
7698
m => m.name === `dhis-web-${coreApp.short_name}`
77-
)?.icon
99+
)
100+
const iconUrl = module?.icon
78101
const icons = iconUrl ? { 48: iconUrl } : {}
102+
const name = module?.displayName || coreApp.name
79103
return {
80104
...coreApp,
81105
baseUrl: `${baseUrl}/dhis-web-${coreApp.short_name}`,
106+
name,
82107
icons,
83108
}
84109
})
@@ -95,13 +120,8 @@ export const CoreApps = () => {
95120

96121
return (
97122
<AppList
98-
error={error}
99-
loading={loading}
100123
apps={apps}
101124
appsWithUpdates={appsWithUpdates}
102-
errorLabel={i18n.t(
103-
'Something went wrong whilst loading your core apps'
104-
)}
105125
updatesAvailableLabel={i18n.t('Core apps with updates available')}
106126
allAppsLabel={i18n.t('All core apps')}
107127
searchLabel={i18n.t('Search core apps')}

0 commit comments

Comments
 (0)