Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
st3v3nmw committed Jul 24, 2022
1 parent bce5c22 commit d4c1982
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 74 deletions.
3 changes: 3 additions & 0 deletions src/lang/locale/cz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export default {
TOTAL_CARDS: "Kartiček celkem",
EDIT_LATER: "Upravit později",
RESET_CARD_PROGRESS: "Vynulovat pokrok kartičky",
HARD: "Težké",
GOOD: "Dobré",
EASY: "Jednoduché",
SHOW_ANSWER: "Ukázat odpověď",
CARD_PROGRESS_RESET: "Pokrok kartičky byl vynulován.",

Expand Down
3 changes: 3 additions & 0 deletions src/lang/locale/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default {
TOTAL_CARDS: "Alle Karten",
EDIT_LATER: "Später bearbeiten",
RESET_CARD_PROGRESS: "Kartenfortschritt zurücksetzten",
HARD: "Schwer",
GOOD: "Gut",
EASY: "Einfach",
SHOW_ANSWER: "Zeige Antwort",
CARD_PROGRESS_RESET: "Kartenfortschritt wurde zurückgesetzt.",

Expand Down
3 changes: 3 additions & 0 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export default {
TOTAL_CARDS: "Total Cards",
EDIT_LATER: "Edit Later",
RESET_CARD_PROGRESS: "Reset card's progress",
HARD: "Hard",
GOOD: "Good",
EASY: "Easy",
SHOW_ANSWER: "Show Answer",
CARD_PROGRESS_RESET: "Card's progress has been reset.",

Expand Down
3 changes: 3 additions & 0 deletions src/lang/locale/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export default {
TOTAL_CARDS: "カード合計",
EDIT_LATER: "後で編集",
RESET_CARD_PROGRESS: "カードの進捗をリセット",
HARD: "Hard",
GOOD: "Good",
EASY: "Easy",
SHOW_ANSWER: "解答を表示",
CARD_PROGRESS_RESET: "カードの進捗がリセットされました。",

Expand Down
3 changes: 3 additions & 0 deletions src/lang/locale/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export default {
TOTAL_CARDS: "전체 카드들",
EDIT_LATER: "나중에 편집하기",
RESET_CARD_PROGRESS: "카드의 진행상황을 초기화합니다.",
HARD: "어려움(Hard)",
GOOD: "좋음(Good)",
EASY: "쉬움(Easy)",
SHOW_ANSWER: "정답 확인하기",
CARD_PROGRESS_RESET: "카드의 진행상황이 초기화되었습니다.",

Expand Down
3 changes: 3 additions & 0 deletions src/lang/locale/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default {
TOTAL_CARDS: "Всего карточек",
EDIT_LATER: "Редактировать после",
RESET_CARD_PROGRESS: "Сбросить прогресс карточки",
HARD: "Сложно",
GOOD: "Нормально",
EASY: "Легко",
SHOW_ANSWER: "Показать ответ",
CARD_PROGRESS_RESET: "Сбросить прогресс изучение карточки",

Expand Down
3 changes: 3 additions & 0 deletions src/lang/locale/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export default {
TOTAL_CARDS: "全部卡片",
EDIT_LATER: "稍后编辑",
RESET_CARD_PROGRESS: "重置卡片",
HARD: "较难",
GOOD: "记得",
EASY: "简单",
SHOW_ANSWER: "显示答案",
CARD_PROGRESS_RESET: "卡片已被重置。",

Expand Down
144 changes: 72 additions & 72 deletions src/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export interface SRSettings {

export const DEFAULT_SETTINGS: SRSettings = {
// flashcards
flashcardEasyText: "Easy",
flashcardGoodText: "Good",
flashcardHardText: "Hard",
flashcardEasyText: t("EASY"),
flashcardGoodText: t("GOOD"),
flashcardHardText: t("HARD"),
flashcardTags: ["#flashcards"],
convertFoldersToDecks: false,
cardCommentOnSameLine: false,
Expand Down Expand Up @@ -124,75 +124,6 @@ export class SRSettingTab extends PluginSettingTab {

containerEl.createDiv().innerHTML = <h3>{t("FLASHCARDS")}</h3>;

new Setting(containerEl)
.setName(t("FLASHCARD_EASY_LABEL"))
.setDesc(t("FLASHCARD_EASY_DESC"))
.addText((text) =>
text.setValue(this.plugin.data.settings.flashcardEasyText).onChange((value) => {
applySettingsUpdate(async () => {
this.plugin.data.settings.flashcardEasyText = value;
await this.plugin.savePluginData();
});
})
)
.addExtraButton((button) => {
button
.setIcon("reset")
.setTooltip(t("RESET_DEFAULT"))
.onClick(async () => {
this.plugin.data.settings.flashcardEasyText =
DEFAULT_SETTINGS.flashcardEasyText;
await this.plugin.savePluginData();
this.display();
});
});

new Setting(containerEl)
.setName(t("FLASHCARD_GOOD_LABEL"))
.setDesc(t("FLASHCARD_GOOD_DESC"))
.addText((text) =>
text.setValue(this.plugin.data.settings.flashcardGoodText).onChange((value) => {
applySettingsUpdate(async () => {
this.plugin.data.settings.flashcardGoodText = value;
await this.plugin.savePluginData();
});
})
)
.addExtraButton((button) => {
button
.setIcon("reset")
.setTooltip(t("RESET_DEFAULT"))
.onClick(async () => {
this.plugin.data.settings.flashcardEasyText =
DEFAULT_SETTINGS.flashcardEasyText;
await this.plugin.savePluginData();
this.display();
});
});

new Setting(containerEl)
.setName(t("FLASHCARD_HARD_LABEL"))
.setDesc(t("FLASHCARD_HARD_DESC"))
.addText((text) =>
text.setValue(this.plugin.data.settings.flashcardHardText).onChange((value) => {
applySettingsUpdate(async () => {
this.plugin.data.settings.flashcardHardText = value;
await this.plugin.savePluginData();
});
})
)
.addExtraButton((button) => {
button
.setIcon("reset")
.setTooltip(t("RESET_DEFAULT"))
.onClick(async () => {
this.plugin.data.settings.flashcardEasyText =
DEFAULT_SETTINGS.flashcardEasyText;
await this.plugin.savePluginData();
this.display();
});
});

new Setting(containerEl)
.setName(t("FLASHCARD_TAGS"))
.setDesc(t("FLASHCARD_TAGS_DESC"))
Expand Down Expand Up @@ -441,6 +372,75 @@ export class SRSettingTab extends PluginSettingTab {
});
});

new Setting(containerEl)
.setName(t("FLASHCARD_EASY_LABEL"))
.setDesc(t("FLASHCARD_EASY_DESC"))
.addText((text) =>
text.setValue(this.plugin.data.settings.flashcardEasyText).onChange((value) => {
applySettingsUpdate(async () => {
this.plugin.data.settings.flashcardEasyText = value;
await this.plugin.savePluginData();
});
})
)
.addExtraButton((button) => {
button
.setIcon("reset")
.setTooltip(t("RESET_DEFAULT"))
.onClick(async () => {
this.plugin.data.settings.flashcardEasyText =
DEFAULT_SETTINGS.flashcardEasyText;
await this.plugin.savePluginData();
this.display();
});
});

new Setting(containerEl)
.setName(t("FLASHCARD_GOOD_LABEL"))
.setDesc(t("FLASHCARD_GOOD_DESC"))
.addText((text) =>
text.setValue(this.plugin.data.settings.flashcardGoodText).onChange((value) => {
applySettingsUpdate(async () => {
this.plugin.data.settings.flashcardGoodText = value;
await this.plugin.savePluginData();
});
})
)
.addExtraButton((button) => {
button
.setIcon("reset")
.setTooltip(t("RESET_DEFAULT"))
.onClick(async () => {
this.plugin.data.settings.flashcardGoodText =
DEFAULT_SETTINGS.flashcardGoodText;
await this.plugin.savePluginData();
this.display();
});
});

new Setting(containerEl)
.setName(t("FLASHCARD_HARD_LABEL"))
.setDesc(t("FLASHCARD_HARD_DESC"))
.addText((text) =>
text.setValue(this.plugin.data.settings.flashcardHardText).onChange((value) => {
applySettingsUpdate(async () => {
this.plugin.data.settings.flashcardHardText = value;
await this.plugin.savePluginData();
});
})
)
.addExtraButton((button) => {
button
.setIcon("reset")
.setTooltip(t("RESET_DEFAULT"))
.onClick(async () => {
this.plugin.data.settings.flashcardHardText =
DEFAULT_SETTINGS.flashcardHardText;
await this.plugin.savePluginData();
this.display();
});
});

containerEl.createDiv().innerHTML = <h3>{t("NOTES")}</h3>;

new Setting(containerEl)
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ type Hex = number;

// https://stackoverflow.com/a/69019874
type ObjectType = Record<PropertyKey, unknown>;
type PickByValue<OBJ_T, VALUE_T> = // From https://stackoverflow.com/a/55153000
type PickByValue<OBJ_T, VALUE_T> = // https://stackoverflow.com/a/55153000
Pick<OBJ_T, { [K in keyof OBJ_T]: OBJ_T[K] extends VALUE_T ? K : never }[keyof OBJ_T]>;
type ObjectEntries<OBJ_T> = // From https://stackoverflow.com/a/60142095
type ObjectEntries<OBJ_T> = // https://stackoverflow.com/a/60142095
{ [K in keyof OBJ_T]: [keyof PickByValue<OBJ_T, OBJ_T[K]>, OBJ_T[K]] }[keyof OBJ_T][];
export function getTypedObjectEntries<OBJ_T extends ObjectType>(obj: OBJ_T): ObjectEntries<OBJ_T> {
return Object.entries(obj) as ObjectEntries<OBJ_T>;
Expand Down

0 comments on commit d4c1982

Please sign in to comment.