aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language/translator.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-07-15 22:39:33 -0400
committerGitHub <noreply@github.com>2021-07-15 22:39:33 -0400
commit41fc76d6fd6af9a880ac8b75e7b03afd1395780a (patch)
tree902d1d44e83123fdc2fc4eefda9923c9ac500aac /ext/js/language/translator.js
parent25d74140ce9843b4bcb86b1b2bbf644602cdb3d0 (diff)
Devoice and nasal pronunciation info (#1832)
* Update schema to support information about nasal and devoiced mora * Expose nasalPositions and devoicePositions in dictionary entry data * Expose nasalPositions, devoicePositions in grouped pitch info * Update display generator * Update test dictionary data * Update test data
Diffstat (limited to 'ext/js/language/translator.js')
-rw-r--r--ext/js/language/translator.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js
index 8519b728..c35d2203 100644
--- a/ext/js/language/translator.js
+++ b/ext/js/language/translator.js
@@ -828,12 +828,14 @@ class Translator {
{
if (data.reading !== reading) { continue; }
const pitches = [];
- for (const {position, tags} of data.pitches) {
+ for (const {position, tags, nasal, devoice} of data.pitches) {
const tags2 = [];
if (Array.isArray(tags) && tags.length > 0) {
tags2.push(this._createTagGroup(dictionary, tags));
}
- pitches.push({position, tags: tags2});
+ const nasalPositions = this._toNumberArray(nasal);
+ const devoicePositions = this._toNumberArray(devoice);
+ pitches.push({position, nasalPositions, devoicePositions, tags: tags2});
}
for (const {pronunciations, headwordIndex} of targets) {
pronunciations.push(this._createTermPronunciation(
@@ -968,6 +970,10 @@ class Translator {
return JSON.stringify(array);
}
+ _toNumberArray(value) {
+ return Array.isArray(value) ? value : (typeof value === 'number' ? [value] : []);
+ }
+
// Kanji data
_createKanjiStat(name, value, databaseInfo, dictionary) {