summaryrefslogtreecommitdiff
path: root/ext/js/pages/settings
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/pages/settings')
-rw-r--r--ext/js/pages/settings/audio-controller.js34
1 files changed, 24 insertions, 10 deletions
diff --git a/ext/js/pages/settings/audio-controller.js b/ext/js/pages/settings/audio-controller.js
index b89ae2ba..defef16e 100644
--- a/ext/js/pages/settings/audio-controller.js
+++ b/ext/js/pages/settings/audio-controller.js
@@ -47,6 +47,8 @@ export class AudioController extends EventDispatcher {
this._voiceTestTextInput = querySelectorNotNull(document, '#text-to-speech-voice-test-text');
/** @type {import('audio-controller').VoiceInfo[]} */
this._voices = [];
+ /** @type {string} */
+ this._language = 'ja';
}
/** @type {import('./settings-controller.js').SettingsController} */
@@ -121,12 +123,18 @@ export class AudioController extends EventDispatcher {
* @param {import('settings-controller').EventArgument<'optionsChanged'>} details
*/
_onOptionsChanged({options}) {
+ const {
+ general: {language},
+ audio: {sources},
+ } = options;
+
+ this._language = language;
+
for (const entry of this._audioSourceEntries) {
entry.cleanup();
}
this._audioSourceEntries = [];
- const {sources} = options.audio;
for (let i = 0, ii = sources.length; i < ii; ++i) {
this._createAudioSourceEntry(i, sources[i]);
}
@@ -216,15 +224,7 @@ export class AudioController extends EventDispatcher {
* @returns {import('settings').AudioSourceType}
*/
_getUnusedAudioSourceType() {
- /** @type {import('settings').AudioSourceType[]} */
- const typesAvailable = [
- 'jpod101',
- 'jpod101-alternate',
- 'jisho',
- 'lingua-libre',
- 'wiktionary',
- 'custom',
- ];
+ const typesAvailable = this._getAvailableAudioSourceTypes();
for (const type of typesAvailable) {
if (!this._audioSourceEntries.some((entry) => entry.type === type)) {
return type;
@@ -233,6 +233,20 @@ export class AudioController extends EventDispatcher {
return typesAvailable[0];
}
+ /**
+ * @returns {import('settings').AudioSourceType[]}
+ */
+ _getAvailableAudioSourceTypes() {
+ /** @type {import('settings').AudioSourceType[]} */
+ const generalAudioSources = ['lingua-libre', 'wiktionary', 'text-to-speech', 'custom'];
+ if (this._language === 'ja') {
+ /** @type {import('settings').AudioSourceType[]} */
+ const japaneseAudioSources = ['jpod101', 'jpod101-alternate', 'jisho'];
+ return [...japaneseAudioSources, ...generalAudioSources];
+ }
+ return generalAudioSources;
+ }
+
/** */
async _addAudioSource() {
const type = this._getUnusedAudioSourceType();