Skip to content

Build your personal knowledge base with Trilium Notes

feat(note_language): add a button to configure the language

Elian Doran25c9f52cf45d
diff --git a/src/public/app/widgets/note_language.ts b/src/public/app/widgets/note_language.ts
index 7ffd8e2503..77690d708c 100644
--- a/src/public/app/widgets/note_language.ts
+++ b/src/public/app/widgets/note_language.ts
@@ -7,6 +7,7 @@ import type FNote from "../entities/fnote.js";
import attributes from "../services/attributes.js";
import type { Locale } from "../../../services/i18n.js";
import options from "../services/options.js";
+import appContext from "../components/app_context.js";
const TPL = `\
<div class="dropdown note-language-widget">
@@ -62,6 +63,8 @@ export default class NoteLanguageWidget extends NoteContextAwareWidget {
...rightToLeftLanguages
];
}
+
+ this.locales.push("---"); // this will separate the list of languages from the "Configure languages" button.
}
doRender() {
@@ -106,6 +109,11 @@ export default class NoteLanguageWidget extends NoteContextAwareWidget {
this.$noteLanguageDropdown.append('<div class="dropdown-divider"></div>');
}
}
+
+ const $configureLink = $('<a class="dropdown-item">')
+ .append(`<span>${t("note_language.configure-languages")}</span>`)
+ .on("click", () => appContext.tabManager.openContextWithNote("_optionsLocalization", { activate: true }));
+ this.$noteLanguageDropdown.append($configureLink);
}
async save(languageId: string) {
diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json
index b16a223d17..ebd6a734bb 100644
--- a/src/public/translations/en/translation.json
+++ b/src/public/translations/en/translation.json
@@ -1688,6 +1688,7 @@
"unknown_widget": "Unknown widget for \"{{id}}\"."
},
"note_language": {
- "not_set": "Not set"
+ "not_set": "Not set",
+ "configure-languages": "Configure languages..."
}
}