diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-01-23 20:28:38 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-01-24 20:15:25 -0500 |
commit | 538d83c5a6d846adfd275462910888572d52caf1 (patch) | |
tree | 226992f969a3a9fbf38b12d68b9f8158b68cfbff /ext | |
parent | 317bf35bc039fb82b558c66adac236ff6a84d762 (diff) |
Reorganized variants to better reflect usage order
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bg/data/options-schema.json | 14 | ||||
-rw-r--r-- | ext/bg/js/options.js | 4 | ||||
-rw-r--r-- | ext/bg/js/settings/main.js | 4 | ||||
-rw-r--r-- | ext/bg/js/translator.js | 14 | ||||
-rw-r--r-- | ext/bg/settings.html | 16 |
5 files changed, 28 insertions, 24 deletions
diff --git a/ext/bg/data/options-schema.json b/ext/bg/data/options-schema.json index c65a40df..8385d638 100644 --- a/ext/bg/data/options-schema.json +++ b/ext/bg/data/options-schema.json @@ -354,17 +354,12 @@ "translation": { "type": "object", "required": [ - "convertKatakanaToHiragana", "convertHalfWidthCharacters", "convertNumericCharacters", - "convertAlphabeticCharacters" + "convertAlphabeticCharacters", + "convertKatakanaToHiragana" ], "properties": { - "convertKatakanaToHiragana": { - "type": "string", - "enum": ["false", "true", "variant"], - "default": "variant" - }, "convertHalfWidthCharacters": { "type": "string", "enum": ["false", "true", "variant"], @@ -379,6 +374,11 @@ "type": "string", "enum": ["false", "true", "variant"], "default": "false" + }, + "convertKatakanaToHiragana": { + "type": "string", + "enum": ["false", "true", "variant"], + "default": "variant" } } }, diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index c4ccd450..fd67ca70 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -320,10 +320,10 @@ function profileOptionsCreateDefaults() { }, translation: { - convertKatakanaToHiragana: 'variant', convertHalfWidthCharacters: 'false', convertNumericCharacters: 'false', - convertAlphabeticCharacters: 'false' + convertAlphabeticCharacters: 'false', + convertKatakanaToHiragana: 'variant' }, dictionaries: {}, diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js index 2130dd5a..900a0a09 100644 --- a/ext/bg/js/settings/main.js +++ b/ext/bg/js/settings/main.js @@ -72,10 +72,10 @@ async function formRead(options) { options.scanning.modifier = $('#scan-modifier-key').val(); options.scanning.popupNestingMaxDepth = parseInt($('#popup-nesting-max-depth').val(), 10); - options.translation.convertKatakanaToHiragana = $('#translation-convert-katakana-to-hiragana').val(); options.translation.convertHalfWidthCharacters = $('#translation-convert-half-width-characters').val(); options.translation.convertNumericCharacters = $('#translation-convert-numeric-characters').val(); options.translation.convertAlphabeticCharacters = $('#translation-convert-alphabetic-characters').val(); + options.translation.convertKatakanaToHiragana = $('#translation-convert-katakana-to-hiragana').val(); options.parsing.enableScanningParser = $('#parsing-scan-enable').prop('checked'); options.parsing.enableMecabParser = $('#parsing-mecab-enable').prop('checked'); @@ -145,10 +145,10 @@ async function formWrite(options) { $('#scan-modifier-key').val(options.scanning.modifier); $('#popup-nesting-max-depth').val(options.scanning.popupNestingMaxDepth); - $('#translation-convert-katakana-to-hiragana').val(options.translation.convertKatakanaToHiragana); $('#translation-convert-half-width-characters').val(options.translation.convertHalfWidthCharacters); $('#translation-convert-numeric-characters').val(options.translation.convertNumericCharacters); $('#translation-convert-alphabetic-characters').val(options.translation.convertAlphabeticCharacters); + $('#translation-convert-katakana-to-hiragana').val(options.translation.convertKatakanaToHiragana); $('#parsing-scan-enable').prop('checked', options.parsing.enableScanningParser); $('#parsing-mecab-enable').prop('checked', options.parsing.enableMecabParser); diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index cda1099f..6ddf5431 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -323,27 +323,31 @@ class Translator { getAllDeinflections(text, options) { const translationOptions = options.translation; const textOptionVariantArray = [ - Translator.getTextOptionEntryVariants(translationOptions.convertKatakanaToHiragana), Translator.getTextOptionEntryVariants(translationOptions.convertHalfWidthCharacters), Translator.getTextOptionEntryVariants(translationOptions.convertNumericCharacters), - Translator.getTextOptionEntryVariants(translationOptions.convertAlphabeticCharacters) + Translator.getTextOptionEntryVariants(translationOptions.convertAlphabeticCharacters), + Translator.getTextOptionEntryVariants(translationOptions.convertKatakanaToHiragana) ]; const deinflections = []; const used = new Set(); - for (const [hiragana, halfWidth, numeric, alphabetic] of Translator.getArrayVariants(textOptionVariantArray)) { + for (const [halfWidth, numeric, alphabetic, hiragana] of Translator.getArrayVariants(textOptionVariantArray)) { let text2 = text; let sourceMapping = null; if (halfWidth) { if (sourceMapping === null) { sourceMapping = Translator.createTextSourceMapping(text2); } text2 = jpConvertHalfWidthKanaToFullWidth(text2, sourceMapping); } - if (numeric) { text2 = jpConvertNumericTofullWidth(text2); } + if (numeric) { + text2 = jpConvertNumericTofullWidth(text2); + } if (alphabetic) { if (sourceMapping === null) { sourceMapping = Translator.createTextSourceMapping(text2); } text2 = jpConvertAlphabeticToKana(text2, sourceMapping); } - if (hiragana) { text2 = jpKatakanaToHiragana(text2); } + if (hiragana) { + text2 = jpKatakanaToHiragana(text2); + } for (let i = text2.length; i > 0; --i) { const text2Substring = text2.substring(0, i); diff --git a/ext/bg/settings.html b/ext/bg/settings.html index d5b53a80..fdc4298b 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -401,8 +401,8 @@ <h3>Translation Options</h3> <div class="form-group"> - <label for="translation-convert-katakana-to-hiragana">Convert katakana to hiragana <span class="label-light">(ヨミチャン → よみちゃん)</span></label> - <select class="form-control" id="translation-convert-katakana-to-hiragana"> + <label for="translation-convert-half-width-characters">Convert half width characters to full width <span class="label-light">(ヨミチャン → ヨミチャン)</span></label> + <select class="form-control" id="translation-convert-half-width-characters"> <option value="false">Disabled</option> <option value="true">Enabled</option> <option value="variant">Use both variants</option> @@ -410,8 +410,8 @@ </div> <div class="form-group"> - <label for="translation-convert-half-width-characters">Convert half width characters to full width <span class="label-light">(ヨミチャン → ヨミチャン)</span></label> - <select class="form-control" id="translation-convert-half-width-characters"> + <label for="translation-convert-numeric-characters">Convert numeric characters to full width <span class="label-light">(1234 → 1234)</span></label> + <select class="form-control" id="translation-convert-numeric-characters"> <option value="false">Disabled</option> <option value="true">Enabled</option> <option value="variant">Use both variants</option> @@ -419,8 +419,8 @@ </div> <div class="form-group"> - <label for="translation-convert-numeric-characters">Convert numeric characters to full width <span class="label-light">(1234 → 1234)</span></label> - <select class="form-control" id="translation-convert-numeric-characters"> + <label for="translation-convert-alphabetic-characters">Convert alphabetic characters to hiragana <span class="label-light">(yomichan → よみちゃん)</span></label> + <select class="form-control" id="translation-convert-alphabetic-characters"> <option value="false">Disabled</option> <option value="true">Enabled</option> <option value="variant">Use both variants</option> @@ -428,8 +428,8 @@ </div> <div class="form-group"> - <label for="translation-convert-alphabetic-characters">Convert alphabetic characters to hiragana <span class="label-light">(yomichan → よみちゃん)</span></label> - <select class="form-control" id="translation-convert-alphabetic-characters"> + <label for="translation-convert-katakana-to-hiragana">Convert katakana to hiragana <span class="label-light">(ヨミチャン → よみちゃん)</span></label> + <select class="form-control" id="translation-convert-katakana-to-hiragana"> <option value="false">Disabled</option> <option value="true">Enabled</option> <option value="variant">Use both variants</option> |