Add convertHiraganaToKatakana option

This commit is contained in:
toasted-nutbread 2020-01-23 20:49:41 -05:00
parent 538d83c5a6
commit 67759b7aa3
5 changed files with 23 additions and 1 deletions

View File

@ -357,6 +357,7 @@
"convertHalfWidthCharacters", "convertHalfWidthCharacters",
"convertNumericCharacters", "convertNumericCharacters",
"convertAlphabeticCharacters", "convertAlphabeticCharacters",
"convertHiraganaToKatakana",
"convertKatakanaToHiragana" "convertKatakanaToHiragana"
], ],
"properties": { "properties": {
@ -375,6 +376,11 @@
"enum": ["false", "true", "variant"], "enum": ["false", "true", "variant"],
"default": "false" "default": "false"
}, },
"convertHiraganaToKatakana": {
"type": "string",
"enum": ["false", "true", "variant"],
"default": "false"
},
"convertKatakanaToHiragana": { "convertKatakanaToHiragana": {
"type": "string", "type": "string",
"enum": ["false", "true", "variant"], "enum": ["false", "true", "variant"],

View File

@ -323,6 +323,7 @@ function profileOptionsCreateDefaults() {
convertHalfWidthCharacters: 'false', convertHalfWidthCharacters: 'false',
convertNumericCharacters: 'false', convertNumericCharacters: 'false',
convertAlphabeticCharacters: 'false', convertAlphabeticCharacters: 'false',
convertHiraganaToKatakana: 'false',
convertKatakanaToHiragana: 'variant' convertKatakanaToHiragana: 'variant'
}, },

View File

@ -75,6 +75,7 @@ async function formRead(options) {
options.translation.convertHalfWidthCharacters = $('#translation-convert-half-width-characters').val(); options.translation.convertHalfWidthCharacters = $('#translation-convert-half-width-characters').val();
options.translation.convertNumericCharacters = $('#translation-convert-numeric-characters').val(); options.translation.convertNumericCharacters = $('#translation-convert-numeric-characters').val();
options.translation.convertAlphabeticCharacters = $('#translation-convert-alphabetic-characters').val(); options.translation.convertAlphabeticCharacters = $('#translation-convert-alphabetic-characters').val();
options.translation.convertHiraganaToKatakana = $('#translation-convert-hiragana-to-katakana').val();
options.translation.convertKatakanaToHiragana = $('#translation-convert-katakana-to-hiragana').val(); options.translation.convertKatakanaToHiragana = $('#translation-convert-katakana-to-hiragana').val();
options.parsing.enableScanningParser = $('#parsing-scan-enable').prop('checked'); options.parsing.enableScanningParser = $('#parsing-scan-enable').prop('checked');
@ -148,6 +149,7 @@ async function formWrite(options) {
$('#translation-convert-half-width-characters').val(options.translation.convertHalfWidthCharacters); $('#translation-convert-half-width-characters').val(options.translation.convertHalfWidthCharacters);
$('#translation-convert-numeric-characters').val(options.translation.convertNumericCharacters); $('#translation-convert-numeric-characters').val(options.translation.convertNumericCharacters);
$('#translation-convert-alphabetic-characters').val(options.translation.convertAlphabeticCharacters); $('#translation-convert-alphabetic-characters').val(options.translation.convertAlphabeticCharacters);
$('#translation-convert-hiragana-to-katakana').val(options.translation.convertHiraganaToKatakana);
$('#translation-convert-katakana-to-hiragana').val(options.translation.convertKatakanaToHiragana); $('#translation-convert-katakana-to-hiragana').val(options.translation.convertKatakanaToHiragana);
$('#parsing-scan-enable').prop('checked', options.parsing.enableScanningParser); $('#parsing-scan-enable').prop('checked', options.parsing.enableScanningParser);

View File

@ -326,12 +326,13 @@ class Translator {
Translator.getTextOptionEntryVariants(translationOptions.convertHalfWidthCharacters), Translator.getTextOptionEntryVariants(translationOptions.convertHalfWidthCharacters),
Translator.getTextOptionEntryVariants(translationOptions.convertNumericCharacters), Translator.getTextOptionEntryVariants(translationOptions.convertNumericCharacters),
Translator.getTextOptionEntryVariants(translationOptions.convertAlphabeticCharacters), Translator.getTextOptionEntryVariants(translationOptions.convertAlphabeticCharacters),
Translator.getTextOptionEntryVariants(translationOptions.convertHiraganaToKatakana),
Translator.getTextOptionEntryVariants(translationOptions.convertKatakanaToHiragana) Translator.getTextOptionEntryVariants(translationOptions.convertKatakanaToHiragana)
]; ];
const deinflections = []; const deinflections = [];
const used = new Set(); const used = new Set();
for (const [halfWidth, numeric, alphabetic, hiragana] of Translator.getArrayVariants(textOptionVariantArray)) { for (const [halfWidth, numeric, alphabetic, katakana, hiragana] of Translator.getArrayVariants(textOptionVariantArray)) {
let text2 = text; let text2 = text;
let sourceMapping = null; let sourceMapping = null;
if (halfWidth) { if (halfWidth) {
@ -345,6 +346,9 @@ class Translator {
if (sourceMapping === null) { sourceMapping = Translator.createTextSourceMapping(text2); } if (sourceMapping === null) { sourceMapping = Translator.createTextSourceMapping(text2); }
text2 = jpConvertAlphabeticToKana(text2, sourceMapping); text2 = jpConvertAlphabeticToKana(text2, sourceMapping);
} }
if (katakana) {
text2 = jpHiraganaToKatakana(text2);
}
if (hiragana) { if (hiragana) {
text2 = jpKatakanaToHiragana(text2); text2 = jpKatakanaToHiragana(text2);
} }

View File

@ -427,6 +427,15 @@
</select> </select>
</div> </div>
<div class="form-group">
<label for="translation-convert-hiragana-to-katakana">Convert hiragana to katakana <span class="label-light">(よみちゃん &rarr; ヨミチャン)</span></label>
<select class="form-control" id="translation-convert-hiragana-to-katakana">
<option value="false">Disabled</option>
<option value="true">Enabled</option>
<option value="variant">Use both variants</option>
</select>
</div>
<div class="form-group"> <div class="form-group">
<label for="translation-convert-katakana-to-hiragana">Convert katakana to hiragana <span class="label-light">(ヨミチャン &rarr; よみちゃん)</span></label> <label for="translation-convert-katakana-to-hiragana">Convert katakana to hiragana <span class="label-light">(ヨミチャン &rarr; よみちゃん)</span></label>
<select class="form-control" id="translation-convert-katakana-to-hiragana"> <select class="form-control" id="translation-convert-katakana-to-hiragana">