mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 02:02:29 +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.
|
||||
interface Locale {
|
||||
export interface Locale {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
@ -1,17 +1,43 @@
|
||||
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 = `
|
||||
<div class="options-section">
|
||||
<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>
|
||||
`;
|
||||
|
||||
export default class LanguageOptions extends OptionsWidget {
|
||||
|
||||
private $languagesContainer!: JQuery<HTMLElement>;
|
||||
|
||||
doRender() {
|
||||
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