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

Translate message "Nothing to show" #319

Merged
merged 9 commits into from
Jul 20, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ class FileNavigator extends Component {
items={resourceChildren}
layout={listViewLayout}
layoutOptions={viewLayoutOptions}
locale={apiOptions.locale}
>
<Notifications
className="oc-fm--file-navigator__notifications"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const propTypes = {
onSelection: PropTypes.func,
onSort: PropTypes.func,
onKeyDown: PropTypes.func,
onRef: PropTypes.func
onRef: PropTypes.func,
locale: PropTypes.string
};
const defaultProps = {
rowContextMenuId: nanoid(),
Expand All @@ -63,7 +64,8 @@ const defaultProps = {
onSelection: () => {},
onSort: () => {},
onKeyDown: () => {},
onRef: () => {}
onRef: () => {},
locale: 'en'
};

export default
Expand Down Expand Up @@ -250,7 +252,7 @@ class ListView extends Component {
rowRenderer={Row({
selection, lastSelected, loading, contextMenuId: rowContextMenuId, hasTouch: HAS_TOUCH
})}
noRowsRenderer={NoFilesFoundStub}
noRowsRenderer={() => <NoFilesFoundStub locale={this.props.locale}/>}
onRowClick={onRowClick}
onRowRightClick={onRowRightClick}
onRowDoubleClick={onRowDoubleClick}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import React from 'react';
import './NoFilesFoundStub.less';
import Svg from '@opuscapita/react-svg/lib/SVG';
import PropTypes from "prop-types";
const nothingToShowIcon = require('@opuscapita/svg-icons/lib/add_to_photos.svg');

// TODO Add localization
export default () => (
import getMessage from '../../../translations'

import './NoFilesFoundStub.less';

const NoFilesFoundStub = ({ locale }) => (
<div className="oc-fm--no-files-found-stub">
<Svg
className="oc-fm--no-files-found-stub__icon"
svg={nothingToShowIcon}
/>
<div className="oc-fm--no-files-found-stub__title">
Nothing to show
{getMessage(locale, "nothingToShow")}
</div>
<div className="oc-fm--no-files-found-stub__sub-title">
Use toolbar or context menu to perform available actions
{getMessage(locale, "useContextMenu")}
</div>
{/*
<div className="oc-fm--no-files-found-stub__sub-title">
Expand All @@ -23,3 +26,13 @@ export default () => (
*/}
</div>
);

NoFilesFoundStub.propTypes = {
locale: PropTypes.string
};

NoFilesFoundStub.defaultProps = {
locale: 'en',
};

export default NoFilesFoundStub;
5 changes: 5 additions & 0 deletions packages/client-react/src/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ const translations = {
en: {
'common.Toolbar.moveForward': 'Move forward',
'common.Toolbar.moveBack': 'Move back',
'nothingToShow': 'Nothing to show',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rename the key to 'common.NoFilesFoundStub.title' according to convention in the issue https://opuscapita.atlassian.net/browse/EPROC-20549

'useContextMenu': 'Use toolbar or context menu to perform available actions'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rename the key to 'common.NoFilesFoundStub.message' according to convention in the issue https://opuscapita.atlassian.net/browse/EPROC-20549

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

},
fr: {
'common.Toolbar.moveForward': 'Avancer',
'common.Toolbar.moveBack': 'Revenir en arrière',
'nothingToShow': 'Aucun élément à afficher',
'useContextMenu': 'Utilisez la barre d\'outil ou le menu contextuel pour faire une action'
},
zh: {
'common.Toolbar.moveForward': '向前',
Expand Down Expand Up @@ -39,6 +43,7 @@ const translations = {
};

export default function getMessage(locale, key, params) {
console.log(locale, key, params);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that we need to log it for every function call. Maybe remove it?

let translationExists = (translations[locale] && translations[locale][key]);
let translation = translationExists ? translations[locale][key] : translations['en'][key];
if (!params) {
Expand Down