How to use the react-admin.useTranslate function in react-admin

To help you get started, we’ve selected a few react-admin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marmelab / react-admin / examples / demo / src / visitors / SegmentInput.tsx View on Github external
const SegmentInput: FC = props => {
    const translate = useTranslate();
    const classes = useStyles();
    return (
         ({
                id: segment.id,
                name: translate(segment.name),
            }))}
            className={classes.input}
        />
    );
};
github navidrome / navidrome / ui / src / layout / AppBar.js View on Github external
const CustomUserMenu = ({ onClick, ...rest }) => {
  const translate = useTranslate()
  const resources = useSelector(getResources)
  const classes = useStyles(rest)
  const { permissions } = usePermissions()

  const resourceDefinition = (resourceName) =>
    resources.find((r) => r?.name === resourceName)

  const renderUserMenuItemLink = () => {
    const userResource = resourceDefinition('user')
    if (!userResource) {
      return null
    }
    if (permissions !== 'admin') {
      if (!config.enableUserEditing) {
        return null
      }
github marmelab / react-admin / examples / simple / src / posts / PostList.js View on Github external
const QuickFilter = ({ label }) => {
    const translate = useTranslate();
    const classes = useQuickFilterStyles();
    return ;
};
github navidrome / navidrome / ui / src / layout / PersonalMenu.js View on Github external
const PersonalMenu = forwardRef(({ onClick, sidebarIsOpen, dense }, ref) => {
  const translate = useTranslate()
  const classes = useStyles()
  return (
    }
      onClick={onClick}
      className={classes.menuItem}
      sidebarIsOpen={sidebarIsOpen}
      dense={dense}
    />
  )
})
github navidrome / navidrome / ui / src / album / AlbumActions.js View on Github external
const AlbumActions = ({
  className,
  ids,
  data,
  record,
  permanentFilter,
  ...rest
}) => {
  const dispatch = useDispatch()
  const translate = useTranslate()
  const classes = useStyles()
  const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
  const isNotSmall = useMediaQuery((theme) => theme.breakpoints.up('sm'))

  const handlePlay = React.useCallback(() => {
    dispatch(playTracks(data, ids))
  }, [dispatch, data, ids])

  const handlePlayNext = React.useCallback(() => {
    dispatch(playNext(data, ids))
  }, [dispatch, data, ids])

  const handlePlayLater = React.useCallback(() => {
    dispatch(addTracks(data, ids))
  }, [dispatch, data, ids])
github navidrome / navidrome / ui / src / user / UserEdit.js View on Github external
const UserTitle = ({ record }) => {
  const translate = useTranslate()
  const resourceName = translate('resources.user.name', { smart_count: 1 })
  return <title>
}
</title>
github marmelab / react-admin / examples / demo / src / layout / SubMenu.tsx View on Github external
const SubMenu: FC = ({
    handleToggle,
    sidebarIsOpen,
    isOpen,
    name,
    icon,
    children,
    dense,
}) =&gt; {
    const translate = useTranslate();
    const classes = useStyles();

    const header = (
        <menuitem>
            
                {isOpen ?  : icon}
            
            
                {translate(name)}
            
        </menuitem>
    );

    return (
        
            {sidebarIsOpen || isOpen ? (
github marmelab / react-admin / examples / demo / src / configuration / Configuration.tsx View on Github external
const Configuration = () =&gt; {
    const translate = useTranslate();
    const locale = useLocale();
    const setLocale = useSetLocale();
    const classes = useStyles();
    const theme = useSelector((state: AppState) =&gt; state.theme);
    const dispatch = useDispatch();
    return (
        
            <title title="{translate('pos.configuration')}">
            &lt;CardContent&gt;
                &lt;div className={classes.label}&gt;
                    {translate('pos.theme.name')}
                &lt;/div&gt;
                &lt;Button
                    variant="contained"
                    className={classes.button}
                    color={theme === 'light' ? 'primary' : 'default'}</title>
github navidrome / navidrome / ui / src / album / AlbumListActions.js View on Github external
({ showTitle = true, disableElevation, fullWidth }, ref) =&gt; {
    const dispatch = useDispatch()
    const albumView = useSelector((state) =&gt; state.albumView)
    const classes = useStyles()
    const translate = useTranslate()
    return (
      <div>
        {showTitle &amp;&amp; (
          
            {translate('ra.toggleFieldsMenu.layout')}
          
        )}
        
          </div>
github navidrome / navidrome / ui / src / playlist / PlaylistActions.js View on Github external
const PlaylistActions = ({ className, ids, data, record, ...rest }) => {
  const dispatch = useDispatch()
  const translate = useTranslate()
  const classes = useStyles()
  const dataProvider = useDataProvider()
  const notify = useNotify()
  const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
  const isNotSmall = useMediaQuery((theme) => theme.breakpoints.up('sm'))

  const getAllSongsAndDispatch = React.useCallback(
    (action) => {
      if (ids.length === record.songCount) {
        return dispatch(action(data, ids))
      }

      dataProvider
        .getList('playlistTrack', {
          pagination: { page: 1, perPage: 0 },
          sort: { field: 'id', order: 'ASC' },