import classNames from 'classnames';
import * as React from 'react';
import { addFavorite, removeFavorite } from '../../api/favorites';
-import { translate } from '../../helpers/l10n';
+import { translate, translateWithParameters } from '../../helpers/l10n';
import FavoriteIcon from '../icons/FavoriteIcon';
import { ButtonLink } from './buttons';
import Tooltip from './Tooltip';
interface Props {
className?: string;
component: string;
+ componentName?: string;
favorite: boolean;
qualifier: string;
handleFavorite?: (component: string, isFavorite: boolean) => void;
};
render() {
- const { className, qualifier } = this.props;
+ const { className, componentName, qualifier } = this.props;
const { favorite } = this.state;
- const tooltip = favorite
- ? translate('favorite.current', qualifier)
- : translate('favorite.check', qualifier);
- const ariaLabel = translate('favorite.action', favorite ? 'remove' : 'add');
+ const actionName = favorite ? 'remove' : 'add';
+ const tooltip = componentName
+ ? translateWithParameters(`favorite.action.${qualifier}.${actionName}_x`, componentName)
+ : translate('favorite.action', qualifier, actionName);
return (
<Tooltip overlay={tooltip}>
<ButtonLink
- aria-label={ariaLabel}
innerRef={node => (this.buttonNode = node)}
className={classNames('favorite-link', 'link-no-underline', className)}
onClick={this.toggleFavorite}>
- <FavoriteIcon favorite={favorite} />
+ <FavoriteIcon aria-label={tooltip} favorite={favorite} />
</ButtonLink>
</Tooltip>
);
# FAVORITE
#
#------------------------------------------------------------------------------
-favorite.action.add=Add project to favorites
-favorite.action.remove=Remove project from favorites
-favorite.check.TRK=Click to mark this project as favorite.
-favorite.check.VW=Click to mark this portfolio as favorite.
-favorite.check.SVW=Click to mark this sub-portfolio as favorite.
-favorite.check.APP=Click to mark this application as favorite.
-favorite.check.FIL=Click to mark this file as favorite.
-favorite.check.UTS=Click to mark this test file as favorite.
-
-favorite.current.TRK=This project is marked as favorite.
-favorite.current.VW=This portfolio is marked as favorite.
-favorite.current.SVW=This sub-portfolio is marked as favorite.
-favorite.current.APP=This application is marked as favorite.
-favorite.current.FIL=This file is marked as favorite.
-favorite.current.UTS=This test file is marked as favorite.
-
+favorite.action.TRK.add=Add this project to favorites
+favorite.action.TRK.remove=Remove this project from favorites
+favorite.action.VW.add=Add this portfolio to favorites
+favorite.action.VW.remove=Remove this portfolio from favorites
+favorite.action.SVW.add=Add sub-this portfolio to favorites
+favorite.action.SVW.remove=Remove sub-this portfolio from favorites
+favorite.action.APP.add=Add this application to favorites
+favorite.action.APP.remove=Remove this application from favorites
+favorite.action.TRK.add_x=Add project {0} to favorites
+favorite.action.TRK.remove_x=Remove project {0} from favorites
+favorite.action.VW.add_x=Add portfolio {0} to favorites
+favorite.action.VW.remove_x=Remove portfolio {0} from favorites
+favorite.action.SVW.add_x=Add sub-portfolio {0} to favorites
+favorite.action.SVW.remove_x=Remove sub-portfolio {0} from favorites
+favorite.action.APP.add_x=Add application {0} to favorites
+favorite.action.APP.remove_x=Remove application {0} from favorites
#------------------------------------------------------------------------------