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": { "uaPlaceholder": {
"message": "Your preferred user-agent string" "message": "Your preferred user-agent string"
}, },
"noMatch": {
"message": "No matching user-agent string for this query"
},
"ztoa": { "ztoa": {
"message": "Z to A" "message": "Z to A"
}, },
@ -181,6 +184,9 @@
"filterAmong": { "filterAmong": {
"message": "Filter among $1" "message": "Filter among $1"
}, },
"filterAgents": {
"message": "Filter Agents"
},
"msgDefaultUA": { "msgDefaultUA": {
"message": "Default UA, press the reset button instead" "message": "Default UA, press the reset button instead"
}, },
@ -192,5 +198,11 @@
}, },
"msgDisabled": { "msgDisabled": {
"message": "Disabled. Uses the default user-agent string." "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) protected: document.getElementById('protected').value.split(/\s*,\s*/).filter(s => s.length > 4)
}, () => { }, () => {
restore(); restore();
notify('Options saved.'); notify(chrome.i18n.getMessage('optionsSaved'));
chrome.contextMenus.update(document.querySelector('[name="mode"]:checked').value, { chrome.contextMenus.update(document.querySelector('[name="mode"]:checked').value, {
checked: true checked: true
}); });
@ -174,7 +175,7 @@ document.getElementById('donate').addEventListener('click', () => {
document.getElementById('reset').addEventListener('click', e => { document.getElementById('reset').addEventListener('click', e => {
if (e.detail === 1) { if (e.detail === 1) {
notify('Double-click to reset!'); notify(chrome.i18n.getMessage('dbReset'));
} }
else { else {
localStorage.clear(); localStorage.clear();

View file

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

View file

@ -38,7 +38,7 @@
</select> </select>
</th> </th>
<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"> <select id="sort">
<option value="descending" data-localize="ztoa">Z to A</option> <option value="descending" data-localize="ztoa">Z to A</option>
<option value="ascending" data-localize="atoz">A to Z</option> <option value="ascending" data-localize="atoz">A to Z</option>
@ -63,7 +63,7 @@
<td></td> <td></td>
</tr> </tr>
</template> </template>
<tbody></tbody> <tbody data-localized-content="noMatch" data-content="No matching user-agent string for this query"></tbody>
</table> </table>
</div> </div>
<div id="view"> <div id="view">

View file

@ -15,6 +15,20 @@ document.querySelectorAll('[data-localized-title]').forEach(e => {
e.title = translated; 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 => { document.querySelectorAll('[data-localize]').forEach(e => {
const ref = e.dataset.localize; const ref = e.dataset.localize;
const translated = chrome.i18n.getMessage(ref); const translated = chrome.i18n.getMessage(ref);