aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-07-09 17:31:16 -0400
committerGitHub <noreply@github.com>2021-07-09 17:31:16 -0400
commit0d167095479822adf1ed8918e3d1a349b3a53377 (patch)
treed99c720a58451e70d44d4a03b1c2c2c3819328a8 /ext/js/language
parentdaa44a8389806046ca8fde9fa1c96c1e961393f4 (diff)
JapaneseUtil updates (#1813)
* Rename test file * Use shorthand * Add support checking functions * Remove convertReading from JapaneseUtil
Diffstat (limited to 'ext/js/language')
-rw-r--r--ext/js/language/japanese-util.js29
1 files changed, 10 insertions, 19 deletions
diff --git a/ext/js/language/japanese-util.js b/ext/js/language/japanese-util.js
index 7ee726b2..9d7ad0d8 100644
--- a/ext/js/language/japanese-util.js
+++ b/ext/js/language/japanese-util.js
@@ -277,6 +277,10 @@ const JapaneseUtil = (() => {
return this._getWanakana().toKana(text);
}
+ convertToKanaSupported() {
+ return this._wanakana !== null;
+ }
+
convertKatakanaToHiragana(text) {
let result = '';
const offset = (HIRAGANA_CONVERSION_RANGE[0] - KATAKANA_CONVERSION_RANGE[0]);
@@ -315,25 +319,8 @@ const JapaneseUtil = (() => {
return wanakana.toRomaji(text);
}
- convertReading(term, reading, readingMode) {
- switch (readingMode) {
- case 'hiragana':
- return this.convertKatakanaToHiragana(reading);
- case 'katakana':
- return this.convertHiraganaToKatakana(reading);
- case 'romaji':
- if (reading.length > 0) {
- return this.convertToRomaji(reading);
- } else if (this.isStringEntirelyKana(term)) {
- return this.convertToRomaji(term);
- } else {
- return reading;
- }
- case 'none':
- return '';
- default:
- return reading;
- }
+ convertToRomajiSupported() {
+ return this._wanakana !== null;
}
convertNumericToFullWidth(text) {
@@ -426,6 +413,10 @@ const JapaneseUtil = (() => {
return result;
}
+ convertAlphabeticToKanaSupported() {
+ return this._wanakana !== null;
+ }
+
// Furigana distribution
distributeFurigana(term, reading) {