ver1.2.1
This commit is contained in:
parent
cf55776396
commit
e9516278ef
|
@ -26,6 +26,12 @@
|
||||||
"ifShowMenuLabel":{
|
"ifShowMenuLabel":{
|
||||||
"message": "Display context menu"
|
"message": "Display context menu"
|
||||||
},
|
},
|
||||||
|
"ifChangeSecondLangLabel":{
|
||||||
|
"message": "Switch to the second language if the input text of the tool bar translation panel is the same as the target language"
|
||||||
|
},
|
||||||
|
"secondTargetLangLabel":{
|
||||||
|
"message": "Second language"
|
||||||
|
},
|
||||||
"translatePageMenu":{
|
"translatePageMenu":{
|
||||||
"message": "Translate this page"
|
"message": "Translate this page"
|
||||||
},
|
},
|
||||||
|
|
|
@ -26,6 +26,12 @@
|
||||||
"ifShowMenuLabel":{
|
"ifShowMenuLabel":{
|
||||||
"message": "コンテキストメニューを表示する"
|
"message": "コンテキストメニューを表示する"
|
||||||
},
|
},
|
||||||
|
"ifChangeSecondLangLabel":{
|
||||||
|
"message": "ツールバー翻訳パネルの入力テキストが翻訳先言語と同じ場合は第二言語に切り替える"
|
||||||
|
},
|
||||||
|
"secondTargetLangLabel":{
|
||||||
|
"message": "第二言語"
|
||||||
|
},
|
||||||
"translatePageMenu":{
|
"translatePageMenu":{
|
||||||
"message": "ページ全体を翻訳"
|
"message": "ページ全体を翻訳"
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,7 +3,7 @@ browser.storage.onChanged.addListener(getSetting)
|
||||||
|
|
||||||
//設定の読み出し
|
//設定の読み出し
|
||||||
function getSetting() {
|
function getSetting() {
|
||||||
browser.storage.sync.get(["targetLang", "ifShowButton", "ifCheckLang", "ifShowMenu"], function (value) {
|
browser.storage.local.get(["targetLang", "ifShowButton", "ifCheckLang", "ifShowMenu"], function (value) {
|
||||||
if (value.targetLang == undefined) initialSetting(); //初回起動時
|
if (value.targetLang == undefined) initialSetting(); //初回起動時
|
||||||
targetLang = value.targetLang;
|
targetLang = value.targetLang;
|
||||||
ifShowButton = value.ifShowButton;
|
ifShowButton = value.ifShowButton;
|
||||||
|
@ -27,7 +27,7 @@ function initialSetting() {
|
||||||
targetLang = "en";
|
targetLang = "en";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
browser.storage.sync.set({
|
browser.storage.local.set({
|
||||||
'targetLang': targetLang,
|
'targetLang': targetLang,
|
||||||
'ifShowButton': true,
|
'ifShowButton': true,
|
||||||
'ifCheckLang': true,
|
'ifCheckLang': true,
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
{
|
{
|
||||||
|
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"version": "1.1.3",
|
"version": "1.2.1",
|
||||||
|
|
||||||
"name": "__MSG_extName__",
|
"name": "__MSG_extName__",
|
||||||
"description": "__MSG_extDescription__",
|
"description": "__MSG_extDescription__",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
|
|
||||||
|
|
||||||
"applications": {
|
"applications": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "simple-translate@sienori"
|
"id": "simple-translate@sienori"
|
||||||
|
|
6
simple-translate/options/options.css
Normal file
6
simple-translate/options/options.css
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
hr{
|
||||||
|
width: 100%;
|
||||||
|
background-color: #d7d7db;
|
||||||
|
height: 1px;
|
||||||
|
border: none;
|
||||||
|
}
|
|
@ -3,25 +3,39 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
<link rel="stylesheet" type="text/css" href="options.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<p>
|
<p>
|
||||||
<label id=targetLangLabel>翻訳先の言語:</label>
|
<label><span id=targetLangLabel>翻訳先の言語:</span>
|
||||||
<select id="targetLang"></select>
|
<select id="targetLang"></select></label>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<input type="checkbox" name="ifShowButton" value="1">
|
<label><input type="checkbox" name="ifShowButton" value="1">
|
||||||
<label id=ifShowButtonLabel>テキスト選択時にボタンを表示する</label>
|
<span id=ifShowButtonLabel>テキスト選択時にボタンを表示する</span></label>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<input type="checkbox" name="ifCheckLang" value="1">
|
<label><input type="checkbox" name="ifCheckLang" value="1">
|
||||||
<label id=ifCheckLangLabel>選択したテキストが翻訳先言語と同じ時はボタンを表示しない</label>
|
<span id=ifCheckLangLabel>選択したテキストが翻訳先言語と同じ時はボタンを表示しない</span></label>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<input type="checkbox" name="ifShowMenu" value="1">
|
<label><input type="checkbox" name="ifShowMenu" value="1">
|
||||||
<label id=ifShowMenuLabel>コンテキストメニューを表示する</label>
|
<span id=ifShowMenuLabel>コンテキストメニューを表示する</span></label>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<p>
|
||||||
|
<label><input type="checkbox" name="ifChangeSecondLang" value="1">
|
||||||
|
<span id=ifChangeSecondLangLabel>ツールバー翻訳パネルの入力テキストが翻訳先言語と同じ場合は第2言語に切り替える</span></label>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label><span id=secondTargetLangLabel>第2言語:</span>
|
||||||
|
<select id="secondTargetLang"></select></label>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript" src="options.js"></script>
|
<script type="text/javascript" src="options.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
@ -2,27 +2,37 @@ var targetLang = document.getElementById("targetLang");
|
||||||
var ifShowButton = document.getElementsByName("ifShowButton").item(0);
|
var ifShowButton = document.getElementsByName("ifShowButton").item(0);
|
||||||
var ifCheckLang = document.getElementsByName("ifCheckLang").item(0);
|
var ifCheckLang = document.getElementsByName("ifCheckLang").item(0);
|
||||||
var ifShowMenu = document.getElementsByName("ifShowMenu").item(0);
|
var ifShowMenu = document.getElementsByName("ifShowMenu").item(0);
|
||||||
|
var ifChangeSecondLang = document.getElementsByName("ifChangeSecondLang").item(0);
|
||||||
|
var secondTargetLang = document.getElementById("secondTargetLang");
|
||||||
|
|
||||||
targetLang.innerHTML=browser.i18n.getMessage("langList");
|
targetLang.innerHTML=browser.i18n.getMessage("langList");
|
||||||
|
secondTargetLang.innerHTML=browser.i18n.getMessage("langList");
|
||||||
|
|
||||||
document.getElementById("targetLangLabel").innerHTML=browser.i18n.getMessage("langListLabel");
|
document.getElementById("targetLangLabel").innerHTML=browser.i18n.getMessage("langListLabel");
|
||||||
document.getElementById("ifShowButtonLabel").innerHTML=browser.i18n.getMessage("ifShowButtonLabel");
|
document.getElementById("ifShowButtonLabel").innerHTML=browser.i18n.getMessage("ifShowButtonLabel");
|
||||||
document.getElementById("ifCheckLangLabel").innerHTML=browser.i18n.getMessage("ifCheckLangLabel");
|
document.getElementById("ifCheckLangLabel").innerHTML=browser.i18n.getMessage("ifCheckLangLabel");
|
||||||
document.getElementById("ifShowMenuLabel").innerHTML=browser.i18n.getMessage("ifShowMenuLabel");
|
document.getElementById("ifShowMenuLabel").innerHTML=browser.i18n.getMessage("ifShowMenuLabel");
|
||||||
|
document.getElementById("ifChangeSecondLangLabel").innerHTML=browser.i18n.getMessage("ifChangeSecondLangLabel");
|
||||||
|
document.getElementById("secondTargetLangLabel").innerHTML=browser.i18n.getMessage("secondTargetLangLabel");
|
||||||
|
|
||||||
//設定を読み込んで反映
|
//設定を読み込んで反映
|
||||||
browser.storage.sync.get(["targetLang", "ifShowButton", "ifCheckLang", "ifShowMenu"], function (value) {
|
browser.storage.local.get(["targetLang", "ifShowButton", "ifCheckLang", "ifShowMenu", "ifChangeSecondLang", "secondTargetLang"], function (value) {
|
||||||
targetLang.value = value.targetLang;
|
targetLang.value = value.targetLang;
|
||||||
ifShowButton.checked=value.ifShowButton;
|
ifShowButton.checked=value.ifShowButton;
|
||||||
ifCheckLang.checked=value.ifCheckLang;
|
ifCheckLang.checked=value.ifCheckLang;
|
||||||
ifShowMenu.checked=value.ifShowMenu;
|
ifShowMenu.checked=value.ifShowMenu;
|
||||||
|
ifChangeSecondLang.checked=value.ifChangeSecondLang;
|
||||||
|
secondTargetLang.value=value.secondTargetLang;
|
||||||
});
|
});
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
browser.storage.sync.set({
|
browser.storage.local.set({
|
||||||
'targetLang': targetLang.value,
|
'targetLang': targetLang.value,
|
||||||
'ifShowButton': ifShowButton.checked,
|
'ifShowButton': ifShowButton.checked,
|
||||||
'ifCheckLang': ifCheckLang.checked,
|
'ifCheckLang': ifCheckLang.checked,
|
||||||
'ifShowMenu': ifShowMenu.checked
|
'ifShowMenu': ifShowMenu.checked,
|
||||||
|
'ifChangeSecondLang': ifChangeSecondLang.checked,
|
||||||
|
'secondTargetLang': secondTargetLang.value
|
||||||
}, function () {});
|
}, function () {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,3 +40,5 @@ targetLang.addEventListener("change", save);
|
||||||
ifShowButton.addEventListener("change", save);
|
ifShowButton.addEventListener("change", save);
|
||||||
ifCheckLang.addEventListener("change", save);
|
ifCheckLang.addEventListener("change", save);
|
||||||
ifShowMenu.addEventListener("change", save);
|
ifShowMenu.addEventListener("change", save);
|
||||||
|
ifChangeSecondLang.addEventListener("change", save);
|
||||||
|
secondTargetLang.addEventListener("change", save);
|
|
@ -7,14 +7,20 @@ langList.innerHTML = browser.i18n.getMessage("langList");
|
||||||
textarea.innerText = initialText;
|
textarea.innerText = initialText;
|
||||||
|
|
||||||
let targetLang;
|
let targetLang;
|
||||||
|
let secondTargetLang;
|
||||||
|
let defaultTargetLang;
|
||||||
|
let ifChangeSecondLang;
|
||||||
let sourceWord = "";
|
let sourceWord = "";
|
||||||
|
|
||||||
browser.storage.onChanged.addListener(getTargetLang);
|
browser.storage.onChanged.addListener(getTargetLang);
|
||||||
getTargetLang(); //翻訳先言語初期化
|
getTargetLang(); //翻訳先言語初期化
|
||||||
//設定を読み出し
|
//設定を読み出し
|
||||||
function getTargetLang() {
|
function getTargetLang() {
|
||||||
browser.storage.sync.get("targetLang", function (value) {
|
browser.storage.local.get(["targetLang", "secondTargetLang","ifChangeSecondLang"], function (value) {
|
||||||
|
defaultTargetLang = value.targetLang;
|
||||||
targetLang = value.targetLang;
|
targetLang = value.targetLang;
|
||||||
|
secondTargetLang = value.secondTargetLang;
|
||||||
|
ifChangeSecondLang=value.ifChangeSecondLang;
|
||||||
langList.value = targetLang; //リスト初期値をセット
|
langList.value = targetLang; //リスト初期値をセット
|
||||||
langList.addEventListener("change", changeLang);
|
langList.addEventListener("change", changeLang);
|
||||||
});
|
});
|
||||||
|
@ -88,8 +94,8 @@ function textAreaClick() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
textarea.addEventListener("keyup", function(event){
|
textarea.addEventListener("keyup", function (event) {
|
||||||
if(event.keyCode==13) resize();
|
if (event.keyCode == 13) resize();
|
||||||
inputText();
|
inputText();
|
||||||
});
|
});
|
||||||
//文字入力時の処理
|
//文字入力時の処理
|
||||||
|
@ -129,11 +135,33 @@ function getRequest(word) {
|
||||||
function showResult(results) {
|
function showResult(results) {
|
||||||
target.innerText = "";
|
target.innerText = "";
|
||||||
let resultText = "";
|
let resultText = "";
|
||||||
|
|
||||||
|
//第二言語に変更
|
||||||
|
if (ifChangeSecondLang) {
|
||||||
|
let lang = results[0].response[2];
|
||||||
|
let percentage = results[0].response[6];
|
||||||
|
if (targetLang == defaultTargetLang && lang == defaultTargetLang && percentage > 0 && !changeLangFlag) changeSecondLang();
|
||||||
|
else if ((lang != defaultTargetLang || percentage == 0) && changeLangFlag) unchangeSecondLang();
|
||||||
|
}
|
||||||
for (let j = 0; j < results.length; j++) {
|
for (let j = 0; j < results.length; j++) {
|
||||||
for (let i = 0; i < results[j].response[0].length; i++) {
|
for (let i = 0; i < results[j].response[0].length; i++) {
|
||||||
resultText += results[j].response[0][i][0];
|
resultText += results[j].response[0][i][0];
|
||||||
}
|
}
|
||||||
resultText += "\n"; //
|
resultText += "\n";
|
||||||
}
|
}
|
||||||
target.innerText = resultText;
|
target.innerText = resultText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let changeLangFlag = false;
|
||||||
|
|
||||||
|
function changeSecondLang() {
|
||||||
|
changeLangFlag = true;
|
||||||
|
langList.value = secondTargetLang;
|
||||||
|
changeLang();
|
||||||
|
}
|
||||||
|
|
||||||
|
function unchangeSecondLang() {
|
||||||
|
changeLangFlag = false;
|
||||||
|
langList.value = defaultTargetLang;
|
||||||
|
changeLang();
|
||||||
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ getSetting();
|
||||||
browser.storage.onChanged.addListener(getSetting);
|
browser.storage.onChanged.addListener(getSetting);
|
||||||
//設定を読み出し
|
//設定を読み出し
|
||||||
function getSetting() {
|
function getSetting() {
|
||||||
browser.storage.sync.get(["targetLang", "ifShowButton", "ifCheckLang"], function (value) {
|
browser.storage.local.get(["targetLang", "ifShowButton", "ifCheckLang"], function (value) {
|
||||||
targetLang = value.targetLang;
|
targetLang = value.targetLang;
|
||||||
ifShowButton = value.ifShowButton;
|
ifShowButton = value.ifShowButton;
|
||||||
ifCheckLang = value.ifCheckLang;
|
ifCheckLang = value.ifCheckLang;
|
||||||
|
|
BIN
simple-translate/web-ext-artifacts/simple_translate-1.2.0.zip
Normal file
BIN
simple-translate/web-ext-artifacts/simple_translate-1.2.0.zip
Normal file
Binary file not shown.
BIN
simple-translate/web-ext-artifacts/simple_translate-1.2.1.zip
Normal file
BIN
simple-translate/web-ext-artifacts/simple_translate-1.2.1.zip
Normal file
Binary file not shown.
Loading…
Reference in a new issue