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: suggested words marking #315

Closed
wants to merge 15 commits into 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 @@ -12,6 +12,7 @@ import { getCaseTips } from 'utils/getCaseTips';
import { getCyrillic } from 'utils/getCyrillic';
import { getGlagolitic } from 'utils/getGlagolitic';
import { getLatin } from 'utils/getLatin';
import { removeExclamationMark } from 'utils/removeExclamationMark';
import {
getGender,
getNumeralType,
Expand Down Expand Up @@ -618,8 +619,10 @@ function mapStateToProps({
interfaceLang,
orderOfCases,
}: IMainState) {
const { word, add, details } = modalDialog.data;

const word = removeExclamationMark(modalDialog.data.word);
const add = modalDialog.data.add;
const details = modalDialog.data.details;

return {
word,
add,
Expand Down
22 changes: 19 additions & 3 deletions src/components/Modals/TranslationsModal/TranslationsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { useModalDialog } from 'hooks/useModalDialog';
import { useResults } from 'hooks/useResults';
import { getCyrillic } from 'utils/getCyrillic';
import { getLatin } from 'utils/getLatin';
import { findIntelligibilityIssues } from "utils/intelligibilityIssues";
import { estimateIntelligibility, findIntelligibilityIssues, hasIntelligibilityIssues } from "utils/intelligibilityIssues";
import { removeExclamationMark } from 'utils/removeExclamationMark';

import { Table } from 'components/Table';

Expand Down Expand Up @@ -59,9 +60,11 @@ export const TranslationsModal =
const intelligibility = Dictionary.getField(item.raw, 'intelligibility');
const marks = findIntelligibilityIssues(intelligibility);
const tableData = allLangs.reduce((arr, lang) => {
const translate = Dictionary.getField(item.raw, lang).toString();
let translate = Dictionary.getField(item.raw, lang).toString();

if (lang === 'isv') {
translate = removeExclamationMark(translate);

return [
[
`{${t('isvEtymologicLatinLang')}}[B]@ts;b;sw=130px;nowrap`,
Expand Down Expand Up @@ -104,6 +107,9 @@ export const TranslationsModal =
🚫 – {t('translationsLegendIntelligibilityNone')}.<br/>
</>);

const intelligibilityVector = estimateIntelligibility(Dictionary.getField(item.raw, 'intelligibility'));
const suggestedChanges = Dictionary.suggestedChanges(item.raw);

return (
<>
<div className="modal-dialog__header">
Expand All @@ -119,7 +125,17 @@ export const TranslationsModal =
</button>
</div>
<div className="modal-dialog__body">
<Table data={tableData}/>
{hasIntelligibilityIssues(intelligibilityVector) &&
<div className="modal-dialog__warning">
⚠️ {t('intelligibilityIssues')}
</div>}
{suggestedChanges &&
<div className="modal-dialog__warning">
{suggestedChanges === 'suggestedNewWord' ? '🌱' : suggestedChanges === 'suggestedForRemoval' ? '⛔️' : ''}
{' '}
{t(suggestedChanges)}
</div>}
{<Table data={tableData}/>}
</div>
<footer className="modal-dialog__footer">
<div className="modal-legend">
Expand Down
13 changes: 13 additions & 0 deletions src/components/ResultsCard/ResultsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const ResultsCard =
const dispatch = useDispatch();
const intelligibility = Dictionary.getField(item.raw, 'intelligibility');
const intelligibilityVector = estimateIntelligibility(intelligibility);
const suggestedChanges = Dictionary.suggestedChanges(item.raw);
const lang = useLang();

const cardBiInfo: ICardAnalytics = useMemo(() => (
Expand Down Expand Up @@ -218,6 +219,18 @@ export const ResultsCard =
title={t('intelligibilityIssues')}>⚠️</button>
: undefined
}
{ suggestedChanges
? <button
key={suggestedChanges}
onClick={showTranslations}
className={classNames({ 'results-card__status': true })}
title={t(suggestedChanges)}>
{suggestedChanges === 'suggestedNewWord' ? '🌱' :
suggestedChanges === 'suggestedForRemoval' ? '⛔️' :
''}
</button>
: undefined
}
{item.to === 'isv' && short && (
<>
&nbsp;
Expand Down
9 changes: 6 additions & 3 deletions src/services/dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class DictionaryClass {
let fromField = this.getField(item, lang === 'isv-src' ? 'isv' : lang);
fromField = removeBrackets(fromField, '[', ']');
fromField = removeBrackets(fromField, '(', ')');

fromField = removeExclamationMark(fromField);
let splittedField;

switch (lang) {
Expand All @@ -237,7 +237,6 @@ class DictionaryClass {
;
break;
default:
fromField = removeExclamationMark(fromField);
splittedField = this.splitWords(fromField).map((word) => this.searchPrepare(lang, word));
break;
}
Expand Down Expand Up @@ -511,7 +510,7 @@ class DictionaryClass {
caseQuestions?: boolean
): ITranslateResult[] {
return results.map((item) => {
const isv = this.getField(item, 'isv');
const isv = removeExclamationMark(this.getField(item, 'isv'));
const addArray = this.getField(item, 'addition').match(/\(.+?\)/) || [];
const add = addArray.find((elem) => !elem.startsWith('(+')) || '';
let caseInfo = convertCases(addArray.find((elem) => elem.startsWith('(+'))?.slice(1,-1) || '');
Expand Down Expand Up @@ -655,6 +654,10 @@ class DictionaryClass {

return text;
}
public suggestedChanges(item: string[]): string {
return this.getField(item, 'id').substring(0,1) === '-' ? 'suggestedNewWord' :
this.getField(item, 'isv').substring(0,1) === '!' ? 'suggestedForRemoval' : '';
}
}

export const Dictionary = DictionaryClass.getInstance();
32 changes: 31 additions & 1 deletion src/translations/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3408,7 +3408,7 @@
},
"intelligibilityIssues": {
"en": "The word is not universally intelligible across Slavic languages",
"isv": "Slovo ne je universalno razumljivo vo vsih slovjanskyh jezykah",
"isv": "Slovo ne je universalno razumlivo vo vsih slovjanskyh jezykah",
"ru": "Слово не является универсально понятным во всех славянских языках",
"uk": "Слово не є універсально зрозумілим у всіх слов'янських мовах",
"be": "Слова не з’яўляецца ўніверсальна зразумелым ва ўсіх славянскіх мовах",
Expand All @@ -3420,5 +3420,35 @@
"sr": "Реч није универзално разумљива у свим словенским језицима",
"mk": "Зборот не е универзално разбирлив во сите словенски јазици",
"bg": "Думата не е универсално разбираема във всички слаавянски езици"
},
"suggestedNewWord": {
"en": "The word was recently added and has not yet been approved",
"isv": "Slovo bylo dodano nedavno i ješče ne jest odobrjeno",
"ru": "Слово добавлено недавно и ещё не утверждено",
"uk": "Слово було нещодавно додано та ще не затверджено",
"be": "Слова было нядаўна дададзена і яшчэ не зацверджана",
"pl": "Słowo zostało dodane niedawno i jeszcze nie zostało zatwierdzone",
"cs": "Slovo bylo nedávno přidáno a ještě nebylo schváleno",
"sk": "Slovo bolo nedávno pridané a ešte nebolo schválené",
"sl": "Beseda je bila nedavno dodana in še ni bila odobrena",
"hr": "Riječ je nedavno dodana i još nije odobrena",
"sr": "Реч је недавно додата и још увек није одобрена",
"mk": "Зборот неодамна беше додаден и сè уште не е одобрен",
"bg": "Думата беше добавена наскоро и все още не е одобрена"
},
"suggestedForRemoval": {
"en": "Suggested for removal from the dictionary",
"isv": "Prědloženo do udaljeńja iz slovnika",
"ru": "Предложено для удаления из словаря",
"uk": "Пропонується видалити зі словника",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"uk": "Пропонується видалити зі словника",
"uk": "Пропонується до видалення зі словника",

"be": "Прапануецца выдаліць са слоўніка",
"pl": "Sugerowane usunięcie ze słownika",
"cs": "Doporučeno k odstranění ze slovníku",
"sk": "Navrhnuté na odstránenie zo slovníka",
"sl": "Predlagano za odstranitev iz slovarja",
"hr": "Predloženo za uklanjanje iz rječnika",
"sr": "Предложено за уклањање из речника",
"mk": "Предложено за отстранување од речникот",
"bg": "Предлага се за премахване от речника"
}
}
Loading