aboutsummaryrefslogtreecommitdiff
path: root/ext/js/display
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/display')
-rw-r--r--ext/js/display/display-anki.js14
-rw-r--r--ext/js/display/display-audio.js4
-rw-r--r--ext/js/display/display.js14
3 files changed, 29 insertions, 3 deletions
diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js
index fc242549..b3b05408 100644
--- a/ext/js/display/display-anki.js
+++ b/ext/js/display/display-anki.js
@@ -193,7 +193,11 @@ export class DisplayAnki {
*/
_onOptionsUpdated({options}) {
const {
- general: {resultOutputMode, glossaryLayoutMode, compactTags},
+ general: {
+ resultOutputMode,
+ glossaryLayoutMode,
+ compactTags,
+ },
dictionaries,
anki: {
tags,
@@ -883,7 +887,13 @@ export class DisplayAnki {
_getAnkiNoteMediaAudioDetails(details) {
if (details.type !== 'term') { return null; }
const {sources, preferredAudioIndex} = this._displayAudio.getAnkiNoteMediaAudioDetails(details.term, details.reading);
- return {sources, preferredAudioIndex, idleTimeout: this._audioDownloadIdleTimeout};
+ const languageSummary = this._display.getLanguageSummary();
+ return {
+ sources,
+ preferredAudioIndex,
+ idleTimeout: this._audioDownloadIdleTimeout,
+ languageSummary,
+ };
}
// View note functions
diff --git a/ext/js/display/display-audio.js b/ext/js/display/display-audio.js
index c7e08ffe..0d1ca029 100644
--- a/ext/js/display/display-audio.js
+++ b/ext/js/display/display-audio.js
@@ -57,6 +57,7 @@ export class DisplayAudio {
['jpod101', 'JapanesePod101'],
['jpod101-alternate', 'JapanesePod101 (Alternate)'],
['jisho', 'Jisho.org'],
+ ['lingua-libre', 'Lingua Libre'],
['text-to-speech', 'Text-to-speech'],
['text-to-speech-reading', 'Text-to-speech (Kana reading)'],
['custom', 'Custom URL'],
@@ -677,7 +678,8 @@ export class DisplayAudio {
*/
async _getTermAudioInfoList(source, term, reading) {
const sourceData = this._getSourceData(source);
- const infoList = await this._display.application.api.getTermAudioInfoList(sourceData, term, reading);
+ const languageSummary = this._display.getLanguageSummary();
+ const infoList = await this._display.application.api.getTermAudioInfoList(sourceData, term, reading, languageSummary);
return infoList.map((info) => ({info, audioPromise: null, audioResolved: false, audio: null}));
}
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index f86d7b8c..3d18e416 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -192,6 +192,8 @@ export class Display extends EventDispatcher {
this._onMenuButtonMenuCloseBind = this._onMenuButtonMenuClose.bind(this);
/** @type {ThemeController} */
this._themeController = new ThemeController(document.documentElement);
+ /** @type {import('language').LanguageSummary[]} */
+ this._languageSummaries = [];
/* eslint-disable @stylistic/no-multi-spaces */
this._hotkeyHandler.registerActions([
@@ -316,6 +318,8 @@ export class Display extends EventDispatcher {
documentElement.dataset.browser = browser;
}
+ this._languageSummaries = await this._application.api.getLanguageSummaries();
+
// Prepare
await this._hotkeyHelpController.prepare(this._application.api);
await this._displayGenerator.prepare();
@@ -398,6 +402,16 @@ export class Display extends EventDispatcher {
}
/**
+ * @returns {import('language').LanguageSummary}
+ * @throws {Error}
+ */
+ getLanguageSummary() {
+ if (this._options === null) { throw new Error('Options is null'); }
+ const language = this._options.general.language;
+ return /** @type {import('language').LanguageSummary} */ (this._languageSummaries.find(({iso}) => iso === language));
+ }
+
+ /**
* @returns {import('settings').OptionsContext}
*/
getOptionsContext() {