summaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-27 22:53:45 -0400
committerGitHub <noreply@github.com>2020-03-27 22:53:45 -0400
commita0c4ce779d35cab39c62ca42ad3fe58a82faa1bb (patch)
treecd5cdae9d1a7aa48c11668a30758c72e4decedc7 /ext/bg/js/translator.js
parent08d38d8db2c97ff9f016a6de640f645b609088d1 (diff)
parent780d23b749325da0a95aa9cc7898df19f2ac1b31 (diff)
Merge pull request #413 from toasted-nutbread/japanese-utility
Convert Japanese utilities to a module-like style
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r--ext/bg/js/translator.js24
1 files changed, 9 insertions, 15 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 25da9bf0..6f43f7b0 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -29,13 +29,7 @@
* dictTermsMergeBySequence
* dictTermsSort
* dictTermsUndupe
- * jpConvertAlphabeticToKana
- * jpConvertHalfWidthKanaToFullWidth
- * jpConvertNumericTofullWidth
- * jpDistributeFurigana
- * jpHiraganaToKatakana
- * jpIsCodePointJapanese
- * jpKatakanaToHiragana
+ * jp
* requestJson
*/
@@ -275,7 +269,7 @@ class Translator {
const termTags = await this.expandTags(definition.termTags, definition.dictionary);
const {expression, reading} = definition;
- const furiganaSegments = jpDistributeFurigana(expression, reading);
+ const furiganaSegments = jp.distributeFurigana(expression, reading);
definitions.push({
source: deinflection.source,
@@ -376,20 +370,20 @@ class Translator {
let sourceMapping = null;
if (halfWidth) {
if (sourceMapping === null) { sourceMapping = Translator.createTextSourceMapping(text2); }
- text2 = jpConvertHalfWidthKanaToFullWidth(text2, sourceMapping);
+ text2 = jp.convertHalfWidthKanaToFullWidth(text2, sourceMapping);
}
if (numeric) {
- text2 = jpConvertNumericTofullWidth(text2);
+ text2 = jp.convertNumericToFullWidth(text2);
}
if (alphabetic) {
if (sourceMapping === null) { sourceMapping = Translator.createTextSourceMapping(text2); }
- text2 = jpConvertAlphabeticToKana(text2, sourceMapping);
+ text2 = jp.convertAlphabeticToKana(text2, sourceMapping);
}
if (katakana) {
- text2 = jpHiraganaToKatakana(text2);
+ text2 = jp.convertHiraganaToKatakana(text2);
}
if (hiragana) {
- text2 = jpKatakanaToHiragana(text2);
+ text2 = jp.convertKatakanaToHiragana(text2);
}
for (let i = text2.length; i > 0; --i) {
@@ -590,7 +584,7 @@ class Translator {
}
static createExpression(expression, reading, termTags=null, termFrequency=null) {
- const furiganaSegments = jpDistributeFurigana(expression, reading);
+ const furiganaSegments = jp.distributeFurigana(expression, reading);
return {
expression,
reading,
@@ -639,7 +633,7 @@ class Translator {
if (!options.scanning.alphanumeric) {
let newText = '';
for (const c of text) {
- if (!jpIsCodePointJapanese(c.codePointAt(0))) {
+ if (!jp.isCodePointJapanese(c.codePointAt(0))) {
break;
}
newText += c;