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

Add translation for hamburger menu tooltip #4596

Merged
merged 1 commit into from
Mar 30, 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
2 changes: 2 additions & 0 deletions packages/ra-core/src/i18n/TranslationMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface TranslationMessages extends StringMap {
undo: string;
expand: string;
close: string;
open_menu: string;
close_menu: string;
};
boolean: {
[key: string]: StringMap | string;
Expand Down
2 changes: 2 additions & 0 deletions packages/ra-language-english/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const englishMessages: TranslationMessages = {
undo: 'Undo',
expand: 'Expand',
close: 'Close',
open_menu: 'Open menu',
close_menu: 'Close menu',
},
boolean: {
true: 'Yes',
Expand Down
2 changes: 2 additions & 0 deletions packages/ra-language-french/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const frenchMessages: TranslationMessages = {
undo: 'Annuler',
expand: 'Étendre',
close: 'Fermer',
open_menu: 'Ouvrir le menu',
close_menu: 'Fermer le menu',
},
boolean: {
true: 'Oui',
Expand Down
55 changes: 35 additions & 20 deletions packages/ra-ui-materialui/src/layout/AppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import React, { Children, cloneElement } from 'react';
import PropTypes from 'prop-types';
import { useDispatch } from 'react-redux';
import classNames from 'classnames';
import MuiAppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import IconButton from '@material-ui/core/IconButton';
import Typography from '@material-ui/core/Typography';
import { makeStyles } from '@material-ui/core/styles';
import {
AppBar as MuiAppBar,
IconButton,
Toolbar,
Tooltip,
Typography,
makeStyles,
useMediaQuery,
} from '@material-ui/core';
import MenuIcon from '@material-ui/icons/Menu';
import useMediaQuery from '@material-ui/core/useMediaQuery';
import { toggleSidebar } from 'ra-core';
import { toggleSidebar, useTranslate } from 'ra-core';

import LoadingIndicator from './LoadingIndicator';
import DefaultUserMenu from './UserMenu';
Expand Down Expand Up @@ -91,6 +94,7 @@ const AppBar = props => {
const classes = useStyles(props);
const dispatch = useDispatch();
const isXSmall = useMediaQuery(theme => theme.breakpoints.down('xs'));
const translate = useTranslate();

return (
<HideOnScroll>
Expand All @@ -100,20 +104,31 @@ const AppBar = props => {
variant={isXSmall ? 'regular' : 'dense'}
className={classes.toolbar}
>
<IconButton
color="inherit"
aria-label="open drawer"
onClick={() => dispatch(toggleSidebar())}
className={classNames(classes.menuButton)}
<Tooltip
title={translate(
open
? 'ra.action.close_menu'
: 'ra.action.open_menu',
{
_: 'Open/Close menu',
}
)}
enterDelay={500}
>
<MenuIcon
classes={{
root: open
? classes.menuButtonIconOpen
: classes.menuButtonIconClosed,
}}
/>
</IconButton>
<IconButton
color="inherit"
onClick={() => dispatch(toggleSidebar())}
className={classNames(classes.menuButton)}
>
<MenuIcon
classes={{
root: open
? classes.menuButtonIconOpen
: classes.menuButtonIconClosed,
}}
/>
</IconButton>
</Tooltip>
{Children.count(children) === 0 ? (
<Typography
variant="h6"
Expand Down