mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
client: Add language switcher in settings
This commit is contained in:
parent
51afb63e25
commit
bc648e981e
@ -32,6 +32,7 @@ import DatabaseAnonymizationOptions from "./options/advanced/database_anonymizat
|
|||||||
import BackendLogWidget from "./content/backend_log.js";
|
import BackendLogWidget from "./content/backend_log.js";
|
||||||
import AttachmentErasureTimeoutOptions from "./options/other/attachment_erasure_timeout.js";
|
import AttachmentErasureTimeoutOptions from "./options/other/attachment_erasure_timeout.js";
|
||||||
import RibbonOptions from "./options/appearance/ribbon.js";
|
import RibbonOptions from "./options/appearance/ribbon.js";
|
||||||
|
import LocalizationOptions from "./options/appearance/i18n.js";
|
||||||
|
|
||||||
const TPL = `<div class="note-detail-content-widget note-detail-printable">
|
const TPL = `<div class="note-detail-content-widget note-detail-printable">
|
||||||
<style>
|
<style>
|
||||||
@ -54,6 +55,7 @@ const TPL = `<div class="note-detail-content-widget note-detail-printable">
|
|||||||
|
|
||||||
const CONTENT_WIDGETS = {
|
const CONTENT_WIDGETS = {
|
||||||
_optionsAppearance: [
|
_optionsAppearance: [
|
||||||
|
LocalizationOptions,
|
||||||
ThemeOptions,
|
ThemeOptions,
|
||||||
FontsOptions,
|
FontsOptions,
|
||||||
ZoomFactorOptions,
|
ZoomFactorOptions,
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
import OptionsWidget from "../options_widget.js";
|
||||||
|
import server from "../../../../services/server.js";
|
||||||
|
import utils from "../../../../services/utils.js";
|
||||||
|
|
||||||
|
const TPL = `
|
||||||
|
<div class="options-section">
|
||||||
|
<h4>Localization</h4>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="col-6">
|
||||||
|
<label>Language</label>
|
||||||
|
<select class="locale-select form-control"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default class LocalizationOptions extends OptionsWidget {
|
||||||
|
doRender() {
|
||||||
|
this.$widget = $(TPL);
|
||||||
|
this.$localeSelect = this.$widget.find(".locale-select");
|
||||||
|
this.$localeSelect.on("change", async() => {
|
||||||
|
const newLocale = this.$localeSelect.val();
|
||||||
|
await server.put(`options/locale/${newLocale}`);
|
||||||
|
utils.reloadFrontendApp("locale change");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async optionsLoaded(options) {
|
||||||
|
const availableLocales = await server.get("options/locales");
|
||||||
|
for (const locale of availableLocales) {
|
||||||
|
this.$localeSelect.append($("<option>")
|
||||||
|
.attr("value", locale.id)
|
||||||
|
.text(locale.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$localeSelect.val(options.locale);
|
||||||
|
}
|
||||||
|
}
|
@ -58,7 +58,8 @@ const ALLOWED_OPTIONS = new Set([
|
|||||||
'customSearchEngineName',
|
'customSearchEngineName',
|
||||||
'customSearchEngineUrl',
|
'customSearchEngineUrl',
|
||||||
'promotedAttributesOpenInRibbon',
|
'promotedAttributesOpenInRibbon',
|
||||||
'editedNotesOpenInRibbon'
|
'editedNotesOpenInRibbon',
|
||||||
|
'locale'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function getOptions() {
|
function getOptions() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user