aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/language')
-rw-r--r--ext/js/language/translator.js44
1 files changed, 39 insertions, 5 deletions
diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js
index 45909940..733955c2 100644
--- a/ext/js/language/translator.js
+++ b/ext/js/language/translator.js
@@ -964,7 +964,7 @@ export class Translator {
case 'pitch':
{
if (data.reading !== reading) { continue; }
- /** @type {import('dictionary').TermPitch[]} */
+ /** @type {import('dictionary').PitchAccent[]} */
const pitches = [];
for (const {position, tags, nasal, devoice} of data.pitches) {
/** @type {import('dictionary').Tag[]} */
@@ -974,7 +974,13 @@ export class Translator {
}
const nasalPositions = this._toNumberArray(nasal);
const devoicePositions = this._toNumberArray(devoice);
- pitches.push({position, nasalPositions, devoicePositions, tags: tags2});
+ pitches.push({
+ type: 'pitch-accent',
+ position,
+ nasalPositions,
+ devoicePositions,
+ tags: tags2
+ });
}
for (const {pronunciations, headwordIndex} of targets) {
pronunciations.push(this._createTermPronunciation(
@@ -988,6 +994,34 @@ export class Translator {
}
}
break;
+ case 'ipa':
+ {
+ if (data.reading !== reading) { continue; }
+ /** @type {import('dictionary').PhoneticTranscription[]} */
+ const phoneticTranscriptions = [];
+ for (const {ipa, tags} of data.transcriptions) {
+ /** @type {import('dictionary').Tag[]} */
+ const tags2 = [];
+ if (Array.isArray(tags)) {
+ tagAggregator.addTags(tags2, dictionary, tags);
+ }
+ phoneticTranscriptions.push({
+ type: 'phonetic-transcription',
+ ipa,
+ tags: tags2
+ });
+ }
+ for (const {pronunciations, headwordIndex} of targets) {
+ pronunciations.push(this._createTermPronunciation(
+ pronunciations.length,
+ headwordIndex,
+ dictionary,
+ dictionaryIndex,
+ dictionaryPriority,
+ phoneticTranscriptions
+ ));
+ }
+ }
}
}
}
@@ -1341,11 +1375,11 @@ export class Translator {
* @param {string} dictionary
* @param {number} dictionaryIndex
* @param {number} dictionaryPriority
- * @param {import('dictionary').TermPitch[]} pitches
+ * @param {import('dictionary').Pronunciation[]} pronunciations
* @returns {import('dictionary').TermPronunciation}
*/
- _createTermPronunciation(index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pitches) {
- return {index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pitches};
+ _createTermPronunciation(index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations) {
+ return {index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations};
}
/**