aboutsummaryrefslogtreecommitdiff
path: root/ext/js/display
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/display')
-rw-r--r--ext/js/display/query-parser.js26
1 files changed, 23 insertions, 3 deletions
diff --git a/ext/js/display/query-parser.js b/ext/js/display/query-parser.js
index 0acf6ec8..cbcf7cff 100644
--- a/ext/js/display/query-parser.js
+++ b/ext/js/display/query-parser.js
@@ -208,8 +208,6 @@ class QueryParser extends EventDispatcher {
}
_createParseResult(data) {
- const jp = this._japaneseUtil;
- const readingMode = this._readingMode;
const fragment = document.createDocumentFragment();
for (const term of data) {
const termNode = document.createElement('span');
@@ -218,7 +216,7 @@ class QueryParser extends EventDispatcher {
if (reading.length === 0) {
termNode.appendChild(document.createTextNode(text));
} else {
- const reading2 = jp.convertReading(text, reading, readingMode);
+ const reading2 = this._convertReading(text, reading);
termNode.appendChild(this._createSegment(text, reading2));
}
}
@@ -245,4 +243,26 @@ class QueryParser extends EventDispatcher {
return segmentNode;
}
+
+ _convertReading(term, reading) {
+ switch (this._readingMode) {
+ case 'hiragana':
+ return this._japaneseUtil.convertKatakanaToHiragana(reading);
+ case 'katakana':
+ return this._japaneseUtil.convertHiraganaToKatakana(reading);
+ case 'romaji':
+ if (this._japaneseUtil.convertToRomajiSupported()) {
+ if (reading.length > 0) {
+ return this._japaneseUtil.convertToRomaji(reading);
+ } else if (this._japaneseUtil.isStringEntirelyKana(term)) {
+ return this._japaneseUtil.convertToRomaji(term);
+ }
+ }
+ return reading;
+ case 'none':
+ return '';
+ default:
+ return reading;
+ }
+ }
}