feat(note_language): add an option for no language set

This commit is contained in:
Elian Doran 2025-03-04 17:48:04 +02:00
parent 5b4d323936
commit acc76f9b74
No known key found for this signature in database
2 changed files with 24 additions and 7 deletions

View File

@ -1,6 +1,7 @@
import { Dropdown } from "bootstrap";
import NoteContextAwareWidget from "./note_context_aware_widget.js";
import { getAvailableLocales, type Locale } from "../services/i18n.js";
import { t } from "i18next";
const TPL = `\
<div class="dropdown note-language-widget">
@ -36,13 +37,26 @@ export default class NoteLanguageWidget extends NoteContextAwareWidget {
return;
}
for (const locale of getAvailableLocales()) {
const locales: (Locale | "---")[] = [
{
id: "",
name: t("note_language.not_set")
},
"---",
...getAvailableLocales()
];
for (const locale of locales) {
if (typeof locale === "object") {
const $title = $("<span>").text(locale.name);
const $link = $('<a class="dropdown-item">')
.attr("data-language", locale.id)
.append('<span class="check">&check;</span> ')
.append($title);
this.$noteLanguageDropdown.append($link);
} else {
this.$noteLanguageDropdown.append('<div class="dropdown-divider"></div>');
}
}
}

View File

@ -1686,5 +1686,8 @@
},
"content_widget": {
"unknown_widget": "Unknown widget for \"{{id}}\"."
},
"note_language": {
"not_set": "Not set"
}
}