Skip to content

Commit

Permalink
fix: complete translations [v34] (#1014)
Browse files Browse the repository at this point in the history
Includes:
* Switch to using functions to return the result of i18n.t.
* upgrade d2-ui dependencies to versions with translations
* yarn.lock was regenerated
* In plugin, the option for noData was removed since analytics now sets the default noData option to be "No data".
  • Loading branch information
jenniferarnesen authored May 28, 2020
1 parent 8d93264 commit 9f087a3
Show file tree
Hide file tree
Showing 24 changed files with 3,054 additions and 3,545 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- '8'
- '10'
env:
global:
- CC_TEST_REPORTER_ID=2a6f417bdfe1cdc8e2ec8d3347728fc81e64752286079db5ab17fd65c964b946
Expand Down
31 changes: 29 additions & 2 deletions packages/app/i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2020-04-29T13:10:59.082Z\n"
"PO-Revision-Date: 2020-04-29T13:10:59.082Z\n"
"POT-Creation-Date: 2020-05-25T18:22:35.064Z\n"
"PO-Revision-Date: 2020-05-25T18:22:35.064Z\n"

msgid "Rename successful"
msgstr ""
Expand Down Expand Up @@ -103,18 +103,45 @@ msgstr ""
msgid "Plain data source"
msgstr ""

msgid "JSON"
msgstr ""

msgid "XML"
msgstr ""

msgid "Excel"
msgstr ""

msgid "CSV"
msgstr ""

msgid "Advanced"
msgstr ""

msgid "Metadata ID scheme"
msgstr ""

msgid "ID"
msgstr ""

msgid "Code"
msgstr ""

msgid "Name"
msgstr ""

msgid "Data value set"
msgstr ""

msgid "Other formats"
msgstr ""

msgid "JRXML"
msgstr ""

msgid "Raw data SQL"
msgstr ""

msgid "An error occurred in the DHIS2 Data Visualizer application."
msgstr ""

Expand Down
10 changes: 5 additions & 5 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
"private": true,
"homepage": ".",
"devDependencies": {
"@dhis2/cli-app-scripts": "^3.2.5",
"@dhis2/cli-app-scripts": "^4.0.7",
"cypress": "^3.6.1",
"eslint-plugin-cypress": "^2.7.0",
"redux-mock-store": "^1.5.3"
},
"dependencies": {
"@dhis2/analytics": "4.3.25",
"@dhis2/analytics": "^4.4.2",
"@dhis2/app-runtime": "*",
"@dhis2/d2-i18n": "*",
"@dhis2/d2-ui-core": "^6.5.11",
"@dhis2/d2-ui-file-menu": "^6.5.11",
"@dhis2/d2-ui-interpretations": "^6.5.11",
"@dhis2/d2-ui-core": "^7.0.3",
"@dhis2/d2-ui-file-menu": "^7.0.3",
"@dhis2/d2-ui-interpretations": "^7.0.3",
"@dhis2/data-visualizer-plugin": "34.3.31",
"@dhis2/ui-core": "*",
"@material-ui/core": "^3.1.2",
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/AppWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import metadataMiddleware from './middleware/metadata'
import App from './components/App'
import muiTheme from './modules/theme'

import './locales'

const AppWrapper = () => {
const engine = useDataEngine()
const store = configureStore([
Expand Down
9 changes: 8 additions & 1 deletion packages/app/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,16 @@ export class App extends Component {
const rootOrgUnit = this.props.settings.rootOrganisationUnit

if (rootOrgUnit && rootOrgUnit.id) {
const defaultMetadataWithNames = Object.entries(
defaultMetadata
).reduce(
(acc, [key, value]) => ({ ...acc, [key]: { name: value() } }),
{}
)

store.dispatch(
fromActions.fromMetadata.acAddMetadata({
...defaultMetadata,
...defaultMetadataWithNames,
[rootOrgUnit.id]: {
...rootOrgUnit,
path: `/${rootOrgUnit.id}`,
Expand Down
22 changes: 11 additions & 11 deletions packages/app/src/components/DownloadMenu/DownloadMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class DownloadMenu extends Component {
<ListItemIcon>
<ListIcon />
</ListItemIcon>
<ListItemText>JSON</ListItemText>
<ListItemText>{i18n.t('JSON')}</ListItemText>
<ArrowRightIcon style={styles.arrowIcon} />
</MenuItem>
<MenuItem
Expand All @@ -218,7 +218,7 @@ export class DownloadMenu extends Component {
<ListItemIcon>
<ListIcon />
</ListItemIcon>
<ListItemText>XML</ListItemText>
<ListItemText>{i18n.t('XML')}</ListItemText>
<ArrowRightIcon style={styles.arrowIcon} />
</MenuItem>
<MenuItem
Expand All @@ -233,7 +233,7 @@ export class DownloadMenu extends Component {
<ListItemIcon>
<ListIcon />
</ListItemIcon>
<ListItemText>Excel</ListItemText>
<ListItemText>{i18n.t('Excel')}</ListItemText>
<ArrowRightIcon style={styles.arrowIcon} />
</MenuItem>
<MenuItem
Expand All @@ -248,7 +248,7 @@ export class DownloadMenu extends Component {
<ListItemIcon>
<ListIcon />
</ListItemIcon>
<ListItemText>CSV</ListItemText>
<ListItemText>{i18n.t('CSV')}</ListItemText>
<ArrowRightIcon style={styles.arrowIcon} />
</MenuItem>
<MenuItem
Expand Down Expand Up @@ -278,23 +278,23 @@ export class DownloadMenu extends Component {
'UID'
)}
>
ID
{i18n.t('ID')}
</MenuItem>
<MenuItem
onClick={this.downloadData(
this.state.schemeSubmenu.dataType,
'CODE'
)}
>
Code
{i18n.t('Code')}
</MenuItem>
<MenuItem
onClick={this.downloadData(
this.state.schemeSubmenu.dataType,
'NAME'
)}
>
Name
{i18n.t('Name')}
</MenuItem>
</Menu>
<Menu
Expand All @@ -313,24 +313,24 @@ export class DownloadMenu extends Component {
'dataValueSet'
)}
>
JSON
{i18n.t('JSON')}
</MenuItem>
<MenuItem
onClick={this.downloadData('xml', null, 'dataValueSet')}
>
XML
{i18n.t('XML')}
</MenuItem>
<Divider />
<ListSubheader component="div">
{i18n.t('Other formats')}
</ListSubheader>
<MenuItem onClick={this.downloadData('jrxml')}>
JRXML
{i18n.t('JRXML')}
</MenuItem>
<MenuItem
onClick={this.downloadData('sql', null, 'debug/sql')}
>
Raw data SQL
{i18n.t('Raw data SQL')}
</MenuItem>
</Menu>
</Fragment>
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/components/TitleBar/TitleBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
getVisualizationState,
} from '../../modules/visualization'

export const TITLE_UNSAVED = i18n.t('Unsaved visualization')
export const TITLE_DIRTY = i18n.t('Edited')
export const getTitleUnsaved = () => i18n.t('Unsaved visualization')
export const getTitleDirty = () => i18n.t('Edited')

const defaultTitleStyle = {
...styles.cell,
Expand All @@ -33,7 +33,7 @@ const defaultInterpretationStyle = {
const getTitleText = (titleState, visualization) => {
switch (titleState) {
case STATE_UNSAVED:
return TITLE_UNSAVED
return getTitleUnsaved()
case STATE_SAVED:
case STATE_DIRTY:
return visualization.name
Expand All @@ -60,7 +60,7 @@ const getSuffix = titleState => {
...styles.suffix,
...styles.titleDirty,
}}
>{`- ${TITLE_DIRTY}`}</div>
>{`- ${getTitleDirty()}`}</div>
)
default:
return ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { shallow } from 'enzyme'
import { TitleBar, TITLE_UNSAVED, TITLE_DIRTY } from '../TitleBar'
import { TitleBar, getTitleUnsaved, getTitleDirty } from '../TitleBar'
import {
STATE_EMPTY,
STATE_UNSAVED,
Expand Down Expand Up @@ -35,14 +35,14 @@ describe('TitleBar component', () => {

it('renders "unsaved" state', () => {
props.titleState = STATE_UNSAVED
props.titleText = TITLE_UNSAVED
props.titleText = getTitleUnsaved()
expect(titleBar().find('div')).toHaveLength(2)
expect(
titleBar()
.find('div')
.first()
.text()
).toEqual(TITLE_UNSAVED)
).toEqual(getTitleUnsaved())
})

it('renders "saved" state', () => {
Expand All @@ -66,7 +66,7 @@ describe('TitleBar component', () => {
.find('div')
.first()
.text()
).toEqual(`Yall- ${TITLE_DIRTY}`)
).toEqual(`Yall- ${getTitleDirty()}`)
})

it('renders a <div> containing everything else', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ export class VisualizationOptions extends Component {
}

generateTabContent = sections =>
sections.map(({ key, label, content }) => (
sections.map(({ key, getLabel, content }) => (
<div key={key} className={tabSection.className}>
<FieldSet>
{label ? (
{getLabel ? (
<Legend>
<span className={tabSectionTitle.className}>
{label}
{getLabel()}
</span>
</Legend>
) : null}
Expand All @@ -42,9 +42,9 @@ export class VisualizationOptions extends Component {
))

generateTabs = tabs =>
tabs.map(({ key, label, content }) => ({
tabs.map(({ key, getLabel, content }) => ({
key,
label,
label: getLabel(),
content: this.generateTabContent(content),
}))

Expand Down
86 changes: 40 additions & 46 deletions packages/app/src/modules/metadata.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,46 @@
import i18n from '@dhis2/d2-i18n'

export const relativePeriods = {
TODAY: i18n.t('Today'),
YESTERDAY: i18n.t('Yesterday'),
LAST_3_DAYS: i18n.t('Last 3 days'),
LAST_7_DAYS: i18n.t('Last 7 days'),
LAST_14_DAYS: i18n.t('Last 14 days'),
THIS_WEEK: i18n.t('This week'),
LAST_WEEK: i18n.t('Last week'),
LAST_4_WEEKS: i18n.t('Last 4 weeks'),
LAST_12_WEEKS: i18n.t('Last 12 weeks'),
LAST_52_WEEKS: i18n.t('Last 52 weeks'),
WEEKS_THIS_YEAR: i18n.t('Weeks this year'),
THIS_MONTH: i18n.t('This month'),
LAST_MONTH: i18n.t('Last month'),
LAST_3_MONTHS: i18n.t('Last 3 months'),
LAST_6_MONTHS: i18n.t('Last 6 months'),
LAST_12_MONTHS: i18n.t('Last 12 months'),
MONTHS_THIS_YEAR: i18n.t('Months this year'),
THIS_BIMONTH: i18n.t('This bimonth'),
LAST_BIMONTH: i18n.t('Last bimonth'),
LAST_6_BIMONTHS: i18n.t('Last 6 bimonths'),
BIMONTHS_THIS_YEAR: i18n.t('Bimonths this year'),
THIS_QUARTER: i18n.t('This quarter'),
LAST_QUARTER: i18n.t('Last quarter'),
LAST_4_QUARTERS: i18n.t('Last 4 quarters'),
QUARTERS_THIS_YEAR: i18n.t('Quarters this year'),
THIS_SIX_MONTH: i18n.t('This six-month'),
LAST_SIX_MONTH: i18n.t('Last six-month'),
LAST_2_SIXMONTHS: i18n.t('Last 2 six-months'),
THIS_FINANCIAL_YEAR: i18n.t('This financial year'),
LAST_FINANCIAL_YEAR: i18n.t('Last financial year'),
LAST_5_FINANCIAL_YEARS: i18n.t('Last 5 financial years'),
THIS_YEAR: i18n.t('This year'),
LAST_YEAR: i18n.t('Last year'),
LAST_5_YEARS: i18n.t('Last 5 years'),
const relativePeriods = {
TODAY: () => i18n.t('Today'),
YESTERDAY: () => i18n.t('Yesterday'),
LAST_3_DAYS: () => i18n.t('Last 3 days'),
LAST_7_DAYS: () => i18n.t('Last 7 days'),
LAST_14_DAYS: () => i18n.t('Last 14 days'),
THIS_WEEK: () => i18n.t('This week'),
LAST_WEEK: () => i18n.t('Last week'),
LAST_4_WEEKS: () => i18n.t('Last 4 weeks'),
LAST_12_WEEKS: () => i18n.t('Last 12 weeks'),
LAST_52_WEEKS: () => i18n.t('Last 52 weeks'),
WEEKS_THIS_YEAR: () => i18n.t('Weeks this year'),
THIS_MONTH: () => i18n.t('This month'),
LAST_MONTH: () => i18n.t('Last month'),
LAST_3_MONTHS: () => i18n.t('Last 3 months'),
LAST_6_MONTHS: () => i18n.t('Last 6 months'),
LAST_12_MONTHS: () => i18n.t('Last 12 months'),
MONTHS_THIS_YEAR: () => i18n.t('Months this year'),
THIS_BIMONTH: () => i18n.t('This bimonth'),
LAST_BIMONTH: () => i18n.t('Last bimonth'),
LAST_6_BIMONTHS: () => i18n.t('Last 6 bimonths'),
BIMONTHS_THIS_YEAR: () => i18n.t('Bimonths this year'),
THIS_QUARTER: () => i18n.t('This quarter'),
LAST_QUARTER: () => i18n.t('Last quarter'),
LAST_4_QUARTERS: () => i18n.t('Last 4 quarters'),
QUARTERS_THIS_YEAR: () => i18n.t('Quarters this year'),
THIS_SIX_MONTH: () => i18n.t('This six-month'),
LAST_SIX_MONTH: () => i18n.t('Last six-month'),
LAST_2_SIXMONTHS: () => i18n.t('Last 2 six-months'),
THIS_FINANCIAL_YEAR: () => i18n.t('This financial year'),
LAST_FINANCIAL_YEAR: () => i18n.t('Last financial year'),
LAST_5_FINANCIAL_YEARS: () => i18n.t('Last 5 financial years'),
THIS_YEAR: () => i18n.t('This year'),
LAST_YEAR: () => i18n.t('Last year'),
LAST_5_YEARS: () => i18n.t('Last 5 years'),
}

export const organisationUnits = {
USER_ORGUNIT: i18n.t('User org unit'),
USER_ORGUNIT_CHILDREN: i18n.t('User org unit children'),
USER_ORGUNIT_GRANDCHILDREN: i18n.t('User org unit grand children'),
const organisationUnits = {
USER_ORGUNIT: () => i18n.t('User org unit'),
USER_ORGUNIT_CHILDREN: () => i18n.t('User org unit children'),
USER_ORGUNIT_GRANDCHILDREN: () => i18n.t('User org unit grand children'),
}

// return {name: <string>} as value
export default (function() {
return Object.entries({
...relativePeriods,
...organisationUnits,
}).reduce((obj, [key, value]) => ({ ...obj, [key]: { name: value } }), {})
})()
export default Object.assign({}, relativePeriods, organisationUnits)
Loading

0 comments on commit 9f087a3

Please sign in to comment.