fix(type_widgets/doc): import i18next

since we don't export the full i18n object (not sure why?),
I had to add an additional export "getCurrentLanguage"

-> needs to be a function, because otherwise it will be a static value (being set to undefined),
which is *not* what we want
This commit is contained in:
Panagiotis Papadopoulos 2025-02-28 08:30:35 +01:00
parent f3148bf478
commit d3283746fc
2 changed files with 3 additions and 1 deletions

View File

@ -16,3 +16,4 @@ export async function initLocale() {
}
export const t = i18next.t;
export const getCurrentLanguage = () => i18next.language;

View File

@ -2,6 +2,7 @@ import type { EventData } from "../../components/app_context.js";
import type FNote from "../../entities/fnote.js";
import { applySyntaxHighlight } from "../../services/syntax_highlight.js";
import TypeWidget from "./type_widget.js";
import { getCurrentLanguage } from "../../services/i18n.js";
const TPL = `<div class="note-detail-doc note-detail-printable">
<style>
@ -77,7 +78,7 @@ export default class DocTypeWidget extends TypeWidget {
if (docName) {
// find doc based on language
const url = this.#getUrl(docName, i18next.language);
const url = this.#getUrl(docName, getCurrentLanguage());
this.$content.load(url, (response, status) => {
// fallback to english doc if no translation available
if (status === "error") {