Ray Lothian 2020-09-30 10:27:33 +02:00
parent a0dbb9baa3
commit 249d656ac0
5 changed files with 32 additions and 5 deletions

View file

@ -172,6 +172,9 @@
"uaPlaceholder": {
"message": "Your preferred user-agent string"
},
"noMatch": {
"message": "No matching user-agent string for this query"
},
"ztoa": {
"message": "Z to A"
},
@ -181,6 +184,9 @@
"filterAmong": {
"message": "Filter among $1"
},
"filterAgents": {
"message": "Filter Agents"
},
"msgDefaultUA": {
"message": "Default UA, press the reset button instead"
},
@ -192,5 +198,11 @@
},
"msgDisabled": {
"message": "Disabled. Uses the default user-agent string."
},
"optionsSaved": {
"message": "Options saved."
},
"dbReset": {
"message": "Double-click to reset!"
}
}

View file

@ -89,7 +89,8 @@ function save() {
protected: document.getElementById('protected').value.split(/\s*,\s*/).filter(s => s.length > 4)
}, () => {
restore();
notify('Options saved.');
notify(chrome.i18n.getMessage('optionsSaved'));
chrome.contextMenus.update(document.querySelector('[name="mode"]:checked').value, {
checked: true
});
@ -174,7 +175,7 @@ document.getElementById('donate').addEventListener('click', () => {
document.getElementById('reset').addEventListener('click', e => {
if (e.detail === 1) {
notify('Double-click to reset!');
notify(chrome.i18n.getMessage('dbReset'));
}
else {
localStorage.clear();

View file

@ -130,7 +130,7 @@ select {
background-color: #f5f5f5;
}
#list[data-loading=false] tbody:empty::before {
content: 'No matching user-agent string for this query';
content: attr(data-content);
position: absolute;
left: 0;
top: 0;

View file

@ -38,7 +38,7 @@
</select>
</th>
<th>
<input type="search" id="custom" placeholder="Filter items">&nbsp;
<input type="search" id="custom" data-localized-placeholder="filterAgents" placeholder="Filter Agents">&nbsp;
<select id="sort">
<option value="descending" data-localize="ztoa">Z to A</option>
<option value="ascending" data-localize="atoz">A to Z</option>
@ -63,7 +63,7 @@
<td></td>
</tr>
</template>
<tbody></tbody>
<tbody data-localized-content="noMatch" data-content="No matching user-agent string for this query"></tbody>
</table>
</div>
<div id="view">

View file

@ -15,6 +15,20 @@ document.querySelectorAll('[data-localized-title]').forEach(e => {
e.title = translated;
}
});
document.querySelectorAll('[data-localized-placeholder]').forEach(e => {
const ref = e.dataset.localizedPlaceholder;
const translated = chrome.i18n.getMessage(ref);
if (translated) {
e.placeholder = translated;
}
});
document.querySelectorAll('[data-localized-content]').forEach(e => {
const ref = e.dataset.localizedContent;
const translated = chrome.i18n.getMessage(ref);
if (translated) {
e.dataset.content = translated;
}
});
document.querySelectorAll('[data-localize]').forEach(e => {
const ref = e.dataset.localize;
const translated = chrome.i18n.getMessage(ref);