diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-01-28 07:22:47 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-28 12:22:47 +0000 |
commit | acc013a1a8051d34322f0f5f91d7bdecc0a18843 (patch) | |
tree | 601344b2f047f395548ddfb16a83319af10464f9 /ext/js/data | |
parent | a51f1ab2dc675a49bfeeb08cc24b97eb8d888e4a (diff) |
JapaneseUtil refactor (#555)
* Copy functions from JapaneseUtil
* Remove JapaneseUtil
* Update usages of JapaneseUtil functions
Diffstat (limited to 'ext/js/data')
-rw-r--r-- | ext/js/data/anki-note-builder.js | 12 | ||||
-rw-r--r-- | ext/js/data/sandbox/anki-note-data-creator.js | 12 |
2 files changed, 7 insertions, 17 deletions
diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js index 48564d54..815e7f3f 100644 --- a/ext/js/data/anki-note-builder.js +++ b/ext/js/data/anki-note-builder.js @@ -16,20 +16,18 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import {deferPromise} from '../core/utilities.js'; import {ExtensionError} from '../core/extension-error.js'; +import {deferPromise} from '../core/utilities.js'; +import {convertHiraganaToKatakana, convertKatakanaToHiragana} from '../language/japanese.js'; import {yomitan} from '../yomitan.js'; import {AnkiUtil} from './anki-util.js'; export class AnkiNoteBuilder { /** * Initiate an instance of AnkiNoteBuilder. - * @param {import('../language/sandbox/japanese-util.js').JapaneseUtil} japaneseUtil * @param {import('../templates/template-renderer-proxy.js').TemplateRendererProxy|import('../templates/sandbox/template-renderer.js').TemplateRenderer} templateRenderer */ - constructor(japaneseUtil, templateRenderer) { - /** @type {import('../language/sandbox/japanese-util.js').JapaneseUtil} */ - this._japaneseUtil = japaneseUtil; + constructor(templateRenderer) { /** @type {RegExp} */ this._markerPattern = AnkiUtil.cloneFieldMarkerPattern(true); /** @type {import('../templates/template-renderer-proxy.js').TemplateRendererProxy|import('../templates/sandbox/template-renderer.js').TemplateRenderer} */ @@ -530,9 +528,9 @@ export class AnkiNoteBuilder { _convertReading(reading, readingMode) { switch (readingMode) { case 'hiragana': - return this._japaneseUtil.convertKatakanaToHiragana(reading); + return convertKatakanaToHiragana(reading); case 'katakana': - return this._japaneseUtil.convertHiraganaToKatakana(reading); + return convertHiraganaToKatakana(reading); default: return reading; } diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index 5a608cd2..fc787a66 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -17,6 +17,7 @@ */ import {DictionaryDataUtil} from '../../dictionary/dictionary-data-util.js'; +import {distributeFurigana} from '../../language/japanese.js'; /** * This class is used to convert the internal dictionary entry format to the @@ -24,15 +25,6 @@ import {DictionaryDataUtil} from '../../dictionary/dictionary-data-util.js'; */ export class AnkiNoteDataCreator { /** - * Creates a new instance. - * @param {import('../../language/sandbox/japanese-util.js').JapaneseUtil} japaneseUtil An instance of `JapaneseUtil`. - */ - constructor(japaneseUtil) { - /** @type {import('../../language/sandbox/japanese-util.js').JapaneseUtil} */ - this._japaneseUtil = japaneseUtil; - } - - /** * Creates a compatibility representation of the specified data. * @param {string} marker The marker that is being used for template rendering. * @param {import('anki-templates-internal').CreateDetails} details Information which is used to generate the data. @@ -860,7 +852,7 @@ export class AnkiNoteDataCreator { _getTermHeadwordFuriganaSegments(term, reading) { /** @type {import('anki-templates').FuriganaSegment[]} */ const result = []; - for (const {text, reading: reading2} of this._japaneseUtil.distributeFurigana(term, reading)) { + for (const {text, reading: reading2} of distributeFurigana(term, reading)) { result.push({text, furigana: reading2}); } return result; |