1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

vue ui i18n: added current locale as private member + public getter

This commit is contained in:
Ivan Velev 2022-02-08 04:22:29 -08:00
parent ccfcb2bf52
commit 7d8fdd0989
4 changed files with 10 additions and 5 deletions

View File

@ -82,7 +82,7 @@ html, body
{% if ui.vue_timeline_banner %}
<div id="app" style="width: 100%; height: 200px"></div>
<script>
VueUI.main("{{ static_prefix }}", "{{ url }}", "{{ wb_prefix }}", "{{ timestamp }}", "{{ ui.logo }}", i18nStrings);
VueUI.main("{{ static_prefix }}", "{{ url }}", "{{ wb_prefix }}", "{{ timestamp }}", "{{ ui.logo }}", "{{ env.pywb_lang | default('en') }}", i18nStrings);
</script>
{% endif %}

View File

@ -128,7 +128,7 @@
renderCal.init();
{% else %}
VueUI.main("{{ static_prefix }}", "{{ url }}", "{{ prefix }}", undefined, "{{ ui.logo }}", i18nStrings);
VueUI.main("{{ static_prefix }}", "{{ url }}", "{{ prefix }}", undefined, "{{ ui.logo }}", "{{ env.pywb_lang | default('en') }}", i18nStrings);
{% endif %}

View File

@ -1,8 +1,13 @@
export class PywbI18N {
static init = config => {
static #locale = ''; // private (can only be set here)
static getLocale() { // get via public static method
return PywbI18N.#locale;
}
static init = (locale, config) => {
if (PywbI18N.instance) {
throw new Error('cannot instantiate PywbI18N twice');
}
PywbI18N.#locale = locale;
PywbI18N.instance = new PywbI18N(config);
}

View File

@ -7,8 +7,8 @@ import Vue from "vue/dist/vue.esm.browser";
// ===========================================================================
export function main(staticPrefix, url, prefix, timestamp, logoUrl, i18nStrings) {
PywbI18N.init(i18nStrings);
export function main(staticPrefix, url, prefix, timestamp, logoUrl, locale, i18nStrings) {
PywbI18N.init(locale, i18nStrings);
const loadingSpinner = new LoadingSpinner({text: PywbI18N.instance?.getText('Loading...')}); // bootstrap loading-spinner EARLY ON
new CDXLoader(staticPrefix, url, prefix, timestamp, logoUrl, loadingSpinner);
}