Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return actual translation strings in default metadata [v33] #976

Merged
merged 1 commit into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 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-05-13T12:10:52.295Z\n"
"PO-Revision-Date: 2020-05-13T12:10:52.295Z\n"
"POT-Creation-Date: 2020-05-13T19:08:48.461Z\n"
"PO-Revision-Date: 2020-05-13T19:08:48.461Z\n"

msgid "Rename successful"
msgstr ""
Expand Down Expand Up @@ -468,9 +468,6 @@ msgstr ""
msgid "Last 6 months"
msgstr ""

msgid "Last 12 months"
msgstr ""

msgid "Months this year"
msgstr ""

Expand Down Expand Up @@ -528,6 +525,9 @@ msgstr ""
msgid "Weeks per year"
msgstr ""

msgid "Last 12 months"
msgstr ""

msgid "Months per year"
msgstr ""

Expand Down
7 changes: 6 additions & 1 deletion packages/app/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,14 @@ export class App extends Component {

const rootOrgUnit = this.props.settings.rootOrganisationUnit;

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
2 changes: 0 additions & 2 deletions packages/app/src/components/Layout/Chip.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { setDataTransfer } from '../../modules/dnd';
import { sGetDimensions } from '../../reducers/dimensions';
import { sGetUiItemsByDimension, sGetUiType } from '../../reducers/ui';
import DynamicDimensionIcon from '../../assets/DynamicDimensionIcon';
import { sGetMetadata } from '../../reducers/metadata';
import { styles } from './styles/Chip.style';
import { isSingleValue } from '../../modules/chartTypes';

Expand Down Expand Up @@ -149,7 +148,6 @@ class Chip extends React.Component {
const mapStateToProps = (state, ownProps) => ({
dimensionName: (sGetDimensions(state)[ownProps.dimensionId] || {}).name,
items: sGetUiItemsByDimension(state, ownProps.dimensionId) || emptyItems,
metadata: sGetMetadata(state),
type: sGetUiType(state),
});

Expand Down
83 changes: 42 additions & 41 deletions packages/app/src/modules/metadata.js
Original file line number Diff line number Diff line change
@@ -1,45 +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'),
};

// return {name: <string>} as value
export default (function() {
return Object.entries({
...relativePeriods,
}).reduce((obj, [key, value]) => ({ ...obj, [key]: { name: value } }), {});
})();
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'),
};

export default Object.assign({}, relativePeriods, organisationUnits);
1 change: 0 additions & 1 deletion packages/plugin/src/ChartPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class ChartPlugin extends Component {

const extraOptions = {
dashboard: forDashboard,
noData: { text: i18n.t('No data') }
};

let responses = [];
Expand Down
1 change: 0 additions & 1 deletion packages/plugin/src/__tests__/ChartPlugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ describe('ChartPlugin', () => {
const expectedExtraOptions = {
yearlySeries: mockYoYSeriesLabels,
xAxisLabels: ['period 1', 'period 2'],
noData: { text: 'No data' },
};

expect(
Expand Down