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 Seshat;
@ -271,8 +271,8 @@ const warnBeforeExit = (event, input) => {
if (shouldWarnBeforeExit && exitShortcutPressed) {
const shouldCancelCloseRequest = dialog.showMessageBoxSync(mainWindow, {
type: "question",
buttons: [_td("Cancel"), _td("Close Element")],
message: _td("Are you sure you want to quit?"),
buttons: [_t("Cancel"), _t("Close Element")],
message: _t("Are you sure you want to quit?"),
defaultId: 1,
cancelId: 0,
}) === 0;

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@ const url = require('url');
const fs = require('fs');
const request = require('request');
const path = require('path');
const { _td } = require('./language-helper');
const { _t } = require('./language-helper');
const MAILTO_PREFIX = "mailto:";
@ -74,7 +74,7 @@ function onLinkContextMenu(ev, params) {
if (params.hasImageContents) {
popupMenu.append(new MenuItem({
label: _td('Copy image'),
label: _t('Copy image'),
accelerator: 'c',
click() {
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
if (url.startsWith(MAILTO_PREFIX)) {
popupMenu.append(new MenuItem({
label: _td('Copy email address'),
label: _t('Copy email address'),
accelerator: 'a',
click() {
clipboard.writeText(url.substr(MAILTO_PREFIX.length));
@ -95,7 +95,7 @@ function onLinkContextMenu(ev, params) {
}));
} else {
popupMenu.append(new MenuItem({
label: _td('Copy link address'),
label: _t('Copy link address'),
accelerator: 'a',
click() {
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.
if (params.hasImageContents && !url.startsWith('blob:')) {
popupMenu.append(new MenuItem({
label: _td('Save image as...'),
label: _t('Save image as...'),
accelerator: 'a',
async click() {
const targetFileName = params.titleText || "image.png";
@ -128,8 +128,8 @@ function onLinkContextMenu(ev, params) {
console.error(err);
dialog.showMessageBox({
type: "error",
title: _td("Failed to save image"),
message: _td("The image failed to save"),
title: _t("Failed to save image"),
message: _t("The image failed to save"),
});
}
},
@ -156,7 +156,7 @@ function _CutCopyPasteSelectContextMenus(params) {
options.push({
type: 'separator',
}, {
label: _td('Add to dictionary'),
label: _t('Add to dictionary'),
click: (menuItem, browserWindow) => {
browserWindow.webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord);
},
@ -167,17 +167,17 @@ function _CutCopyPasteSelectContextMenus(params) {
options.push({
role: 'cut',
label: _td('Cut'),
label: _t('Cut'),
accelerator: 't',
enabled: params.editFlags.canCut,
}, {
role: 'copy',
label: _td('Copy'),
label: _t('Copy'),
accelerator: 'c',
enabled: params.editFlags.canCopy,
}, {
role: 'paste',
label: _td('Paste'),
label: _t('Paste'),
accelerator: 'p',
enabled: params.editFlags.canPaste,
}, {
@ -185,7 +185,7 @@ function _CutCopyPasteSelectContextMenus(params) {
enabled: params.editFlags.canPaste,
}, {
role: 'selectall',
label: _td("Select All"),
label: _t("Select All"),
accelerator: 'a',
enabled: params.editFlags.canSelectAll,
});