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

feat: translatable parts of speech #286

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
7 changes: 5 additions & 2 deletions src/components/Modals/DetailModal/DetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { t } from 'translations';
import { hideModalDialog, setAlphabetTypeAction } from 'actions';
import { IMainState } from 'reducers';

import { expandAbbr } from "utils/abbreviations";
import { getCaseTips } from 'utils/getCaseTips';
import { getCyrillic } from 'utils/getCyrillic';
import { getGlagolitic } from 'utils/getGlagolitic';
Expand Down Expand Up @@ -59,12 +60,14 @@ class DetailModalInternal extends Component<IDetailModalInternal> {
return null;
}

const pos = getPartOfSpeech(this.props.details);
const { word, add, details } = this.props;

return (
<>
<div className="modal-dialog__header">
{this.renderTitle(pos)}
<span className="modal-dialog__header-title">
{this.formatStr(word)} {this.formatStr(add)} <span className="details">({expandAbbr(details)})</span>
</span>
<button
className="modal-dialog__header-close"
onClick={this.props.close}
Expand Down
15 changes: 11 additions & 4 deletions src/components/ResultsCard/ResultsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Dictionary, ITranslateResult } from 'services/dictionary';
import { useAlphabets } from 'hooks/useAlphabets';
import { useCaseQuestions } from 'hooks/useCaseQuestions';
import { useLang } from 'hooks/useLang';
import { expandAbbr, translateAbbr } from "utils/abbreviations";
import { getWordStatus } from "utils/getWordStatus";
import { toQueryString } from 'utils/toQueryString';
import { getPartOfSpeech } from 'utils/wordDetails';
Expand Down Expand Up @@ -82,7 +83,7 @@ function renderOriginal(item, alphabets, caseQuestions) {
{caseInfo && <span className="caseInfo">({caseInfo})</span>}
</span>
);
})}
})}
{!caseQuestions && item.caseInfo &&
<span className="caseInfo">(+{t(`case${item.caseInfo.slice(1)}`)})</span>
}
Expand Down Expand Up @@ -183,20 +184,26 @@ export const ResultsCard =
{item.to === 'isv' && short && (
<>
&nbsp;
<span className="results-card__details">{item.details}</span>
<abbr title={expandAbbr(item.details)} className="results-card__details">
{translateAbbr(item.details)}
</abbr>
</>
)}
</div>
{!short && (
<span className="results-card__details">{item.details}</span>
<abbr title={expandAbbr(item.details)} className="results-card__details">
{translateAbbr(item.details)}
</abbr>
)}
<div className="results-card__bottom">
<div className="results-card__original">
{item.to === 'isv' ? (
<Clipboard str={item.translate} />
) : renderOriginal(item, alphabets, caseQuestions)}
{item.to !== 'isv' && short && (
<span className="results-card__details">{item.details}</span>
<abbr title={expandAbbr(item.details)} className="results-card__details">
{translateAbbr(item.details)}
</abbr>
)}
</div>
<div className="results-card__actions">
Expand Down
Loading
Loading