mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-11 11:02:27 +08:00
feat(options/language): display list of languages
This commit is contained in:
parent
73daec6644
commit
bc787213f4
@ -26,7 +26,7 @@ const TPL = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
// TODO: Deduplicate with server.
|
// TODO: Deduplicate with server.
|
||||||
interface Locale {
|
export interface Locale {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,43 @@
|
|||||||
import OptionsWidget from "../options_widget.js";
|
import OptionsWidget from "../options_widget.js";
|
||||||
|
import type { OptionMap } from "../../../../../../services/options_interface.js";
|
||||||
|
import server from "../../../../services/server.js";
|
||||||
|
import type { Locale } from "../appearance/i18n.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="options-section">
|
<div class="options-section">
|
||||||
<h4>Languages</h4>
|
<h4>Languages</h4>
|
||||||
|
|
||||||
The list of languages should go here.
|
<ul class="options-languages">
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
ul.options-languages {
|
||||||
|
list-style-type: none;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default class LanguageOptions extends OptionsWidget {
|
export default class LanguageOptions extends OptionsWidget {
|
||||||
|
|
||||||
|
private $languagesContainer!: JQuery<HTMLElement>;
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
|
this.$languagesContainer = this.$widget.find(".options-languages");
|
||||||
|
}
|
||||||
|
|
||||||
|
async optionsLoaded(options: OptionMap) {
|
||||||
|
const availableLocales = await server.get<Locale[]>("options/locales");
|
||||||
|
|
||||||
|
this.$languagesContainer.empty();
|
||||||
|
for (const locale of availableLocales) {
|
||||||
|
const checkbox = $(`<label class="tn-checkbox">`)
|
||||||
|
.append($('<input type="checkbox" class="form-check-input">'))
|
||||||
|
.append(locale.name);
|
||||||
|
this.$languagesContainer.append($("<li>").append(checkbox));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user