feat(note_language): filter by enabled languages

This commit is contained in:
Elian Doran 2025-03-04 21:56:21 +02:00
parent 9f6b97cdfa
commit 775fd3f22b
No known key found for this signature in database

View File

@ -6,6 +6,7 @@ import type { EventData } from "../components/app_context.js";
import type FNote from "../entities/fnote.js"; import type FNote from "../entities/fnote.js";
import attributes from "../services/attributes.js"; import attributes from "../services/attributes.js";
import type { Locale } from "../../../services/i18n.js"; import type { Locale } from "../../../services/i18n.js";
import options from "../services/options.js";
const TPL = `\ const TPL = `\
<div class="dropdown note-language-widget"> <div class="dropdown note-language-widget">
@ -43,9 +44,10 @@ export default class NoteLanguageWidget extends NoteContextAwareWidget {
constructor() { constructor() {
super(); super();
const allLanguages = getAvailableLocales(); const enabledLanguages = JSON.parse(options.get("languages") ?? "[]") as string[];
const leftToRightLanguages = allLanguages.filter((l) => !l.rtl); const filteredLanguages = getAvailableLocales().filter((l) => typeof l !== "object" || enabledLanguages.includes(l.id));
const rightToLeftLanguages = allLanguages.filter((l) => l.rtl); const leftToRightLanguages = filteredLanguages.filter((l) => !l.rtl);
const rightToLeftLanguages = filteredLanguages.filter((l) => l.rtl);
this.locales = [ this.locales = [
DEFAULT_LOCALE, DEFAULT_LOCALE,