Skip to content

Commit

Permalink
Card answers translations (#5)
Browse files Browse the repository at this point in the history
* Card answers translations
  • Loading branch information
kubk authored Jan 23, 2024
1 parent 59777c5 commit 2050e38
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 19 deletions.
13 changes: 6 additions & 7 deletions src/screens/deck-form/answer-form-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,22 @@ export const AnswerFormView = observer((props: Props) => {

return (
<Screen
title={cardForm.answerFormType === "new" ? "Add answer" : "Edit answer"}
title={
cardForm.answerFormType === "new" ? t("add_answer") : t("edit_answer")
}
>
<Label text={"Answer text"} isRequired>
<Label text={t("answer_text")} isRequired>
<Input field={answer.text} rows={3} type={"textarea"} />
</Label>

<CardRow>
<span>Is correct</span>
<span>{t("is_correct")}</span>
<RadioSwitcher
isOn={answer.isCorrect.value}
onToggle={onToggleIsCorrect}
/>
</CardRow>
<HintTransparent>
There can only be one correct answer. When you set it here, it will be
removed from all other answers
</HintTransparent>
<HintTransparent>{t("is_correct_explanation")}</HintTransparent>

<ButtonGrid>
{cardForm.answerFormType === "edit" && (
Expand Down
14 changes: 6 additions & 8 deletions src/screens/deck-form/card-form-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const CardFormView = observer((props: Props) => {
</Label>

<CardRow>
<span>Advanced</span>
<span>{t("card_advanced")}</span>
<RadioSwitcher
isOn={localStore.isAdvancedOn.value}
onToggle={localStore.isAdvancedOn.toggle}
Expand All @@ -79,12 +79,10 @@ export const CardFormView = observer((props: Props) => {
<span
className={css({ cursor: "pointer" })}
onClick={() => {
showAlert(
`The type of answer you'll need to provide for this card. Choose "Yes No" if you want to select between "Remember" and "Don't remember". Select "Choice" if you want to select between answers.`,
);
showAlert(t("answer_type_explanation"));
}}
>
Answer{" "}
{t("answer")}{" "}
<i
className={cx(
"mdi mdi-information-outline",
Expand All @@ -101,11 +99,11 @@ export const CardFormView = observer((props: Props) => {
options={[
{
id: "remember",
label: "Yes No",
label: t("yes_no"),
},
{
id: "choice_single",
label: "Choice",
label: t("answer_type_choice"),
},
]}
/>
Expand Down Expand Up @@ -154,7 +152,7 @@ export const CardFormView = observer((props: Props) => {
<i
className={cx("mdi mdi-plus", css({ color: "inherit" }))}
/>{" "}
Add answer
{t("add_answer")}
</span>
</CardRow>
</>
Expand Down
4 changes: 2 additions & 2 deletions src/screens/deck-form/store/deck-form-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ export const createAnswerListField = (

if (value.length > 0) {
if (value.every((item) => !item.isCorrect.value)) {
return "One answer should be selected as correct";
return t('validation_answer_at_least_one_correct');
}
}

if (value.length === 0) {
return "At least one answer should be provided";
return t('validation_at_least_one_answer_required');
}
});
};
Expand Down
12 changes: 10 additions & 2 deletions src/screens/folder-form/store/folder-form-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ const createFolderTitleField = (title: string) => {
return new TextField(title, validators.required(t("validation_required")));
};

const createDecksField = (decks: Array<{ id: number; name: string }>) => {
return new ListField<{ id: number; name: string }>(decks, (value) => {
if (value.length === 0) {
return t("validation_at_least_one_deck");
}
});
};

type FolderForm = {
title: TextField<string>;
description: TextField<string>;
Expand Down Expand Up @@ -53,15 +61,15 @@ export class FolderFormStore {
this.folderForm = {
title: createFolderTitleField(folder.name),
description: new TextField(folder.description ?? ""),
decks: new ListField(
decks: createDecksField(
folder.decks.map((deck) => ({ id: deck.id, name: deck.name })),
),
};
} else {
this.folderForm = {
title: createFolderTitleField(""),
description: new TextField(""),
decks: new ListField<{ id: number; name: string }>([]),
decks: createDecksField([]),
};
}
}
Expand Down
54 changes: 54 additions & 0 deletions src/translations/t.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,41 @@ const en = {
share_no_links_for_folder:
"You haven't created any one-time links for this folder",
go_back: "Go back",
validation_at_least_one_deck: "Please select at least 1 deck",
add_answer: "Add answer",
edit_answer: "Edit answer",
answer_text: "Answer text",
is_correct: "Is correct",
is_correct_explanation: `There can only be one correct answer`,
card_advanced: "Advanced",
answer: 'Answer',
yes_no: "Yes No",
answer_type_choice: "Choice",
answer_type_explanation: `The type of answer you'll need to provide for this card. Choose "Yes No" if you want to select between "Remember" and "Don't remember". Select "Choice" if you want to select between answers.`,
validation_answer_at_least_one_correct:
"One answer should be selected as correct",
validation_at_least_one_answer_required:
"At least one answer should be provided",
delete_folder_confirm:
"Do you want to delete the folder? Deleting folder won't remove decks inside the folder",
};

type Translation = typeof en;

const ru: Translation = {
validation_at_least_one_deck: "Пожалуйста выберите хотя бы 1 колоду",
validation_answer_at_least_one_correct: "Выберите хотя бы 1 правильный ответ",
add_answer: "Добавить ответ",
answer_text: "Текст ответа",
answer_type_choice: "Варианты",
answer: 'Ответ',
answer_type_explanation: `Тип ответа, который вам нужно будет предоставить для этой карточки. Выберите "Да Нет", если хотите выбрать между "Помню" и "Не помню". Выберите "Варианты", если хотите выбирать между вариантами ответа.`,
card_advanced: "Дополнительно",
edit_answer: "Редактировать ответ",
is_correct: "Правильный",
validation_at_least_one_answer_required: "Укажите хотя бы 1 ответ",
yes_no: "Да Нет",
is_correct_explanation: `Может быть только один правильный ответ`,
share_folder_settings: "Настройки шеринга папки",
share_no_links_for_folder:
"Вы еще не создали одноразовых ссылок для этой папки",
Expand Down Expand Up @@ -269,6 +297,19 @@ const ru: Translation = {
};

const es: Translation = {
validation_at_least_one_deck: "Por favor, selecciona al menos 1 mazo",
yes_no: "Sí No",
validation_at_least_one_answer_required: "Se debe proporcionar al menos una respuesta",
is_correct: "Es correcto",
validation_answer_at_least_one_correct: "Se debe seleccionar al menos una respuesta correcta",
edit_answer: "Editar respuesta",
card_advanced: "Avanzado",
answer_type_explanation: `El tipo de respuesta que deberás proporcionar para esta tarjeta. Elige "Sí No" si quieres seleccionar entre "Recuerdo" y "No recuerdo". Selecciona "Elección" si quieres seleccionar entre respuestas.`,
answer: 'Respuesta',
answer_type_choice: "Elección",
answer_text: "Texto de la respuesta",
add_answer: "Añadir respuesta",
is_correct_explanation: `Solo puede haber una respuesta correcta`,
card_preview: "Vista previa",
share_no_links_for_folder:
"No has creado ningún enlace de un solo uso para esta carpeta",
Expand Down Expand Up @@ -405,6 +446,19 @@ const es: Translation = {
};

const ptBr: Translation = {
validation_answer_at_least_one_correct: "Selecione pelo menos uma resposta correta",
is_correct_explanation: `Só pode haver uma resposta correta`,
add_answer: "Adicionar resposta",
answer_text: "Texto da resposta",
answer_type_choice: "Escolha",
answer: 'Resposta',
answer_type_explanation: `O tipo de resposta que você precisará fornecer para este cartão. Escolha "Sim Não" se você quiser selecionar entre "Lembrar" e "Não lembrar". Selecione "Escolha" se você quiser selecionar entre respostas.`,
card_advanced: "Avançado",
edit_answer: "Editar resposta",
is_correct: "É correto",
validation_at_least_one_answer_required: "Pelo menos uma resposta deve ser fornecida",
yes_no: "Sim Não",
validation_at_least_one_deck: "Por favor, selecione pelo menos 1 baralho",
share_folder_settings: "Compartilhar pasta",
share_no_links_for_folder: "Você ainda não criou nenhum link para esta pasta",
card_preview: "Visualização",
Expand Down

0 comments on commit 2050e38

Please sign in to comment.