use _t over _td for consistency with element-web

This commit is contained in:
Germain Souquet 2021-04-26 14:50:18 +01:00
parent c56aa9100f
commit b9510d0a0b
5 changed files with 59 additions and 59 deletions

View File

@ -57,7 +57,7 @@ try {
} }
} }
const { _td, AppLocalization } = require('./language-helper'); const { _t, AppLocalization } = require('./language-helper');
let seshatSupported = false; let seshatSupported = false;
let Seshat; let Seshat;
@ -271,8 +271,8 @@ const warnBeforeExit = (event, input) => {
if (shouldWarnBeforeExit && exitShortcutPressed) { if (shouldWarnBeforeExit && exitShortcutPressed) {
const shouldCancelCloseRequest = dialog.showMessageBoxSync(mainWindow, { const shouldCancelCloseRequest = dialog.showMessageBoxSync(mainWindow, {
type: "question", type: "question",
buttons: [_td("Cancel"), _td("Close Element")], buttons: [_t("Cancel"), _t("Close Element")],
message: _td("Are you sure you want to quit?"), message: _t("Are you sure you want to quit?"),
defaultId: 1, defaultId: 1,
cancelId: 0, cancelId: 0,
}) === 0; }) === 0;

View File

@ -2,8 +2,8 @@ const counterpart = require('counterpart');
const DEFAULT_LOCALE = "en"; const DEFAULT_LOCALE = "en";
function _td(text) { function _t(text) {
return _t(text); return text;
} }
function _t(text, variables = {}) { function _t(text, variables = {}) {
@ -109,5 +109,5 @@ class AppLocalization {
module.exports = { module.exports = {
AppLocalization, AppLocalization,
_t, _t,
_td, _t,
}; };

View File

@ -19,7 +19,7 @@ const {app, Tray, Menu, nativeImage} = require('electron');
const pngToIco = require('png-to-ico'); const pngToIco = require('png-to-ico');
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const { _td } = require('./language-helper'); const { _t } = require('./language-helper');
let trayIcon = null; let trayIcon = null;
@ -98,12 +98,12 @@ function initApplicationMenu() {
const contextMenu = Menu.buildFromTemplate([ const contextMenu = Menu.buildFromTemplate([
{ {
label: _td('Show/Hide'), label: _t('Show/Hide'),
click: toggleWin, click: toggleWin,
}, },
{ type: 'separator' }, { type: 'separator' },
{ {
label: _td('Quit'), label: _t('Quit'),
click: function() { click: function() {
app.quit(); app.quit();
}, },

View File

@ -15,106 +15,106 @@ limitations under the License.
*/ */
const {app, shell, Menu} = require('electron'); const {app, shell, Menu} = require('electron');
const { _td } = require('./language-helper'); const { _t } = require('./language-helper');
function buildMenuTemplate() { function buildMenuTemplate() {
// Menu template from http://electron.atom.io/docs/api/menu/, edited // Menu template from http://electron.atom.io/docs/api/menu/, edited
const template = [ const template = [
{ {
label: _td('Edit'), label: _t('Edit'),
accelerator: 'e', accelerator: 'e',
submenu: [ submenu: [
{ {
role: 'undo', role: 'undo',
label: _td('Undo'), label: _t('Undo'),
}, },
{ {
role: 'redo', role: 'redo',
label: _td('Redo'), label: _t('Redo'),
}, },
{ type: 'separator' }, { type: 'separator' },
{ {
role: 'cut', role: 'cut',
label: _td('Cut'), label: _t('Cut'),
}, },
{ {
role: 'copy', role: 'copy',
label: _td('Copy'), label: _t('Copy'),
}, },
{ {
role: 'paste', role: 'paste',
label: _td('Paste'), label: _t('Paste'),
}, },
{ {
role: 'pasteandmatchstyle', role: 'pasteandmatchstyle',
label: _td('Paste and Match Style'), label: _t('Paste and Match Style'),
}, },
{ {
role: 'delete', role: 'delete',
label: _td('Delete'), label: _t('Delete'),
}, },
{ {
role: 'selectall', role: 'selectall',
label: _td('Select All'), label: _t('Select All'),
}, },
], ],
}, },
{ {
label: _td('View'), label: _t('View'),
accelerator: 'V', accelerator: 'V',
submenu: [ submenu: [
{ type: 'separator' }, { type: 'separator' },
{ {
role: 'resetzoom', role: 'resetzoom',
label: _td('Actual Size'), label: _t('Actual Size'),
}, },
{ {
role: 'zoomin', role: 'zoomin',
accelerator: 'CommandOrControl+=', accelerator: 'CommandOrControl+=',
label: _td('Zoom In'), label: _t('Zoom In'),
}, },
{ {
role: 'zoomout', role: 'zoomout',
label: _td('Zoom Out'), label: _t('Zoom Out'),
}, },
{ type: 'separator' }, { type: 'separator' },
{ {
label: _td('Preferences'), label: _t('Preferences'),
accelerator: 'Command+,', // Mac-only accelerator accelerator: 'Command+,', // Mac-only accelerator
click() { global.mainWindow.webContents.send('preferences'); }, click() { global.mainWindow.webContents.send('preferences'); },
}, },
{ {
role: 'togglefullscreen', role: 'togglefullscreen',
label: _td('Toggle Full Screen'), label: _t('Toggle Full Screen'),
}, },
{ {
role: 'toggledevtools', role: 'toggledevtools',
label: _td('Toggle Developer Tools'), label: _t('Toggle Developer Tools'),
}, },
], ],
}, },
{ {
label: _td('Window'), label: _t('Window'),
accelerator: 'w', accelerator: 'w',
role: 'window', role: 'window',
submenu: [ submenu: [
{ {
role: 'minimize', role: 'minimize',
label: _td('Minimize'), label: _t('Minimize'),
}, },
{ {
role: 'close', role: 'close',
label: _td('Close'), label: _t('Close'),
}, },
], ],
}, },
{ {
label: _td('Help'), label: _t('Help'),
accelerator: 'h', accelerator: 'h',
role: 'help', role: 'help',
submenu: [ submenu: [
{ {
label: _td('Element Help'), label: _t('Element Help'),
click() { shell.openExternal('https://element.io/help'); }, click() { shell.openExternal('https://element.io/help'); },
}, },
], ],
@ -129,31 +129,31 @@ function buildMenuTemplate() {
submenu: [ submenu: [
{ {
role: 'about', role: 'about',
label: _td('About'), label: _t('About'),
}, },
{ type: 'separator' }, { type: 'separator' },
{ {
role: 'services', role: 'services',
label: _td('Services'), label: _t('Services'),
submenu: [], submenu: [],
}, },
{ type: 'separator' }, { type: 'separator' },
{ {
role: 'hide', role: 'hide',
label: _td('Hide'), label: _t('Hide'),
}, },
{ {
role: 'hideothers', role: 'hideothers',
label: _td('Hide Others'), label: _t('Hide Others'),
}, },
{ {
role: 'unhide', role: 'unhide',
label: _td('Unhide'), label: _t('Unhide'),
}, },
{ type: 'separator' }, { type: 'separator' },
{ {
role: 'quit', role: 'quit',
label: _td('Quit'), label: _t('Quit'),
}, },
], ],
}); });
@ -162,15 +162,15 @@ function buildMenuTemplate() {
template[1].submenu.push( template[1].submenu.push(
{ type: 'separator' }, { type: 'separator' },
{ {
label: _td('Speech'), label: _t('Speech'),
submenu: [ submenu: [
{ {
role: 'startspeaking', role: 'startspeaking',
label: _td('Start Speaking'), label: _t('Start Speaking'),
}, },
{ {
role: 'stopspeaking', role: 'stopspeaking',
label: _td('Stop Speaking'), label: _t('Stop Speaking'),
}, },
], ],
}); });
@ -179,40 +179,40 @@ function buildMenuTemplate() {
// This also has specific functionality on macOS // This also has specific functionality on macOS
template[3].submenu = [ template[3].submenu = [
{ {
label: _td('Close'), label: _t('Close'),
accelerator: 'CmdOrCtrl+W', accelerator: 'CmdOrCtrl+W',
role: 'close', role: 'close',
}, },
{ {
label: _td('Minimize'), label: _t('Minimize'),
accelerator: 'CmdOrCtrl+M', accelerator: 'CmdOrCtrl+M',
role: 'minimize', role: 'minimize',
}, },
{ {
label: _td('Zoom'), label: _t('Zoom'),
role: 'zoom', role: 'zoom',
}, },
{ {
type: 'separator', type: 'separator',
}, },
{ {
label: _td('Bring All to Front'), label: _t('Bring All to Front'),
role: 'front', role: 'front',
}, },
]; ];
} else { } else {
template.unshift({ template.unshift({
label: _td('File'), label: _t('File'),
accelerator: 'f', accelerator: 'f',
submenu: [ submenu: [
// For some reason, 'about' does not seem to work on windows. // For some reason, 'about' does not seem to work on windows.
/*{ /*{
role: 'about', role: 'about',
label: _td('About'), label: _t('About'),
},*/ },*/
{ {
role: 'quit', role: 'quit',
label: _td('Quit'), label: _t('Quit'),
}, },
], ],
}); });

View File

@ -3,7 +3,7 @@ const url = require('url');
const fs = require('fs'); const fs = require('fs');
const request = require('request'); const request = require('request');
const path = require('path'); const path = require('path');
const { _td } = require('./language-helper'); const { _t } = require('./language-helper');
const MAILTO_PREFIX = "mailto:"; const MAILTO_PREFIX = "mailto:";
@ -74,7 +74,7 @@ function onLinkContextMenu(ev, params) {
if (params.hasImageContents) { if (params.hasImageContents) {
popupMenu.append(new MenuItem({ popupMenu.append(new MenuItem({
label: _td('Copy image'), label: _t('Copy image'),
accelerator: 'c', accelerator: 'c',
click() { click() {
ev.sender.copyImageAt(params.x, params.y); ev.sender.copyImageAt(params.x, params.y);
@ -87,7 +87,7 @@ function onLinkContextMenu(ev, params) {
// Special-case e-mail URLs to strip the `mailto:` like modern browsers do // Special-case e-mail URLs to strip the `mailto:` like modern browsers do
if (url.startsWith(MAILTO_PREFIX)) { if (url.startsWith(MAILTO_PREFIX)) {
popupMenu.append(new MenuItem({ popupMenu.append(new MenuItem({
label: _td('Copy email address'), label: _t('Copy email address'),
accelerator: 'a', accelerator: 'a',
click() { click() {
clipboard.writeText(url.substr(MAILTO_PREFIX.length)); clipboard.writeText(url.substr(MAILTO_PREFIX.length));
@ -95,7 +95,7 @@ function onLinkContextMenu(ev, params) {
})); }));
} else { } else {
popupMenu.append(new MenuItem({ popupMenu.append(new MenuItem({
label: _td('Copy link address'), label: _t('Copy link address'),
accelerator: 'a', accelerator: 'a',
click() { click() {
clipboard.writeText(url); clipboard.writeText(url);
@ -108,7 +108,7 @@ function onLinkContextMenu(ev, params) {
// only the renderer can resolve them so don't give the user an option to. // only the renderer can resolve them so don't give the user an option to.
if (params.hasImageContents && !url.startsWith('blob:')) { if (params.hasImageContents && !url.startsWith('blob:')) {
popupMenu.append(new MenuItem({ popupMenu.append(new MenuItem({
label: _td('Save image as...'), label: _t('Save image as...'),
accelerator: 'a', accelerator: 'a',
async click() { async click() {
const targetFileName = params.titleText || "image.png"; const targetFileName = params.titleText || "image.png";
@ -128,8 +128,8 @@ function onLinkContextMenu(ev, params) {
console.error(err); console.error(err);
dialog.showMessageBox({ dialog.showMessageBox({
type: "error", type: "error",
title: _td("Failed to save image"), title: _t("Failed to save image"),
message: _td("The image failed to save"), message: _t("The image failed to save"),
}); });
} }
}, },
@ -156,7 +156,7 @@ function _CutCopyPasteSelectContextMenus(params) {
options.push({ options.push({
type: 'separator', type: 'separator',
}, { }, {
label: _td('Add to dictionary'), label: _t('Add to dictionary'),
click: (menuItem, browserWindow) => { click: (menuItem, browserWindow) => {
browserWindow.webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord); browserWindow.webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord);
}, },
@ -167,17 +167,17 @@ function _CutCopyPasteSelectContextMenus(params) {
options.push({ options.push({
role: 'cut', role: 'cut',
label: _td('Cut'), label: _t('Cut'),
accelerator: 't', accelerator: 't',
enabled: params.editFlags.canCut, enabled: params.editFlags.canCut,
}, { }, {
role: 'copy', role: 'copy',
label: _td('Copy'), label: _t('Copy'),
accelerator: 'c', accelerator: 'c',
enabled: params.editFlags.canCopy, enabled: params.editFlags.canCopy,
}, { }, {
role: 'paste', role: 'paste',
label: _td('Paste'), label: _t('Paste'),
accelerator: 'p', accelerator: 'p',
enabled: params.editFlags.canPaste, enabled: params.editFlags.canPaste,
}, { }, {
@ -185,7 +185,7 @@ function _CutCopyPasteSelectContextMenus(params) {
enabled: params.editFlags.canPaste, enabled: params.editFlags.canPaste,
}, { }, {
role: 'selectall', role: 'selectall',
label: _td("Select All"), label: _t("Select All"),
accelerator: 'a', accelerator: 'a',
enabled: params.editFlags.canSelectAll, enabled: params.editFlags.canSelectAll,
}); });