aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-23 20:49:41 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-24 20:15:25 -0500
commit67759b7aa3e4be1b90d8244b2337288120a42a4e (patch)
tree0685c3d7e8eaac2d98e25dd3ffa41e857f792732
parent538d83c5a6d846adfd275462910888572d52caf1 (diff)
Add convertHiraganaToKatakana option
-rw-r--r--ext/bg/data/options-schema.json6
-rw-r--r--ext/bg/js/options.js1
-rw-r--r--ext/bg/js/settings/main.js2
-rw-r--r--ext/bg/js/translator.js6
-rw-r--r--ext/bg/settings.html9
5 files changed, 23 insertions, 1 deletions
diff --git a/ext/bg/data/options-schema.json b/ext/bg/data/options-schema.json
index 8385d638..c65bb1e9 100644
--- a/ext/bg/data/options-schema.json
+++ b/ext/bg/data/options-schema.json
@@ -357,6 +357,7 @@
"convertHalfWidthCharacters",
"convertNumericCharacters",
"convertAlphabeticCharacters",
+ "convertHiraganaToKatakana",
"convertKatakanaToHiragana"
],
"properties": {
@@ -375,6 +376,11 @@
"enum": ["false", "true", "variant"],
"default": "false"
},
+ "convertHiraganaToKatakana": {
+ "type": "string",
+ "enum": ["false", "true", "variant"],
+ "default": "false"
+ },
"convertKatakanaToHiragana": {
"type": "string",
"enum": ["false", "true", "variant"],
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index fd67ca70..120b34af 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -323,6 +323,7 @@ function profileOptionsCreateDefaults() {
convertHalfWidthCharacters: 'false',
convertNumericCharacters: 'false',
convertAlphabeticCharacters: 'false',
+ convertHiraganaToKatakana: 'false',
convertKatakanaToHiragana: 'variant'
},
diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js
index 900a0a09..6dccc7e0 100644
--- a/ext/bg/js/settings/main.js
+++ b/ext/bg/js/settings/main.js
@@ -75,6 +75,7 @@ async function formRead(options) {
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.convertHiraganaToKatakana = $('#translation-convert-hiragana-to-katakana').val();
options.translation.convertKatakanaToHiragana = $('#translation-convert-katakana-to-hiragana').val();
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-numeric-characters').val(options.translation.convertNumericCharacters);
$('#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);
$('#parsing-scan-enable').prop('checked', options.parsing.enableScanningParser);
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 6ddf5431..0f89111f 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -326,12 +326,13 @@ class Translator {
Translator.getTextOptionEntryVariants(translationOptions.convertHalfWidthCharacters),
Translator.getTextOptionEntryVariants(translationOptions.convertNumericCharacters),
Translator.getTextOptionEntryVariants(translationOptions.convertAlphabeticCharacters),
+ Translator.getTextOptionEntryVariants(translationOptions.convertHiraganaToKatakana),
Translator.getTextOptionEntryVariants(translationOptions.convertKatakanaToHiragana)
];
const deinflections = [];
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 sourceMapping = null;
if (halfWidth) {
@@ -345,6 +346,9 @@ class Translator {
if (sourceMapping === null) { sourceMapping = Translator.createTextSourceMapping(text2); }
text2 = jpConvertAlphabeticToKana(text2, sourceMapping);
}
+ if (katakana) {
+ text2 = jpHiraganaToKatakana(text2);
+ }
if (hiragana) {
text2 = jpKatakanaToHiragana(text2);
}
diff --git a/ext/bg/settings.html b/ext/bg/settings.html
index fdc4298b..e9c4d7eb 100644
--- a/ext/bg/settings.html
+++ b/ext/bg/settings.html
@@ -428,6 +428,15 @@
</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">
<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">
<option value="false">Disabled</option>