Skip to content

Commit

Permalink
feat(translations): menu translations
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed May 17, 2018
1 parent d24c793 commit 8f76005
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 34 deletions.
1 change: 0 additions & 1 deletion src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class App extends Component {
return (
<MuiThemeProvider>
<div>
{ __('welcome') }
{
((window.currentWindow && !window.currentWindow.isModal()) || typeof WEB !== 'undefined')
&&
Expand Down
8 changes: 4 additions & 4 deletions src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import createWindow from "./helpers/window";
import { autoUpdater } from 'electron-updater'

import { devMenuTemplate } from "./menu/dev_menu_template";
import { editMenuTemplate } from "./menu/edit_menu_template";
import { editMenuTemplateFunc } from "./menu/edit_menu_template";
import { settingsMenuTemplateFunc } from "./menu/config_menu_template";
import { aboutMenuTemplate } from "./menu/about_menu_template";
import { manageMenuTemplate } from "./menu/manage_menu_template";
import { aboutMenuTemplateFunc } from "./menu/about_menu_template";
import { manageMenuTemplateFunc } from "./menu/manage_menu_template";

// Special module holding environment variables which you declared
// in config/env_xxx.json file.
Expand Down Expand Up @@ -58,7 +58,7 @@ const setApplicationMenu = () => {
// update menu translation
changeLanguage(lang, () => setApplicationMenu())
})
const menus = [editMenuTemplate, manageMenuTemplate, settingsMenuTemplate, aboutMenuTemplate];
const menus = [editMenuTemplateFunc(), manageMenuTemplateFunc(), settingsMenuTemplate, aboutMenuTemplateFunc()];

if (env.name !== "production") {
menus.push(devMenuTemplate);
Expand Down
19 changes: 10 additions & 9 deletions src/background/menu/about_menu_template.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { app, BrowserWindow, shell } from "electron";
import path from "path";
import url from "url";
import __ from '../../app/translation'

export const aboutMenuTemplate = {
label: "About",
export const aboutMenuTemplateFunc = () => ({
label: __("About"),
submenu: [
{
label: "Changelog",
label: __("Changelog"),
accelerator: "CmdOrCtrl+]",
click: () => {
const win = new BrowserWindow({
Expand Down Expand Up @@ -35,14 +36,14 @@ export const aboutMenuTemplate = {
},
},
{
label: "Bug Report",
label: __("Bug Report"),
accelerator: "CmdOrCtrl+[",
click: () => {
shell.openExternal('https://github.com/DEgITx/rats-search/issues')
},
},
{
label: "Donate",
label: __("Donate"),
accelerator: "CmdOrCtrl+*",
click: () => {
const win = new BrowserWindow({
Expand Down Expand Up @@ -72,25 +73,25 @@ export const aboutMenuTemplate = {
},
},
{
label: "Help (Documentation)",
label: __("Help (Documentation)"),
accelerator: "CmdOrCtrl+?",
click: () => {
shell.openExternal('https://github.com/DEgITx/rats-search/blob/master/docs/MANUAL.md')
},
},
{
label: "Support (Discussion)",
label: __("Support (Discussion)"),
accelerator: "CmdOrCtrl+>",
click: () => {
shell.openExternal('https://discord.gg/t9GQtxA')
},
},
{
label: "About (GitHub)",
label: __("About (GitHub)"),
accelerator: "CmdOrCtrl+<",
click: () => {
shell.openExternal('https://github.com/DEgITx/rats-search')
},
}
]
};
});
6 changes: 3 additions & 3 deletions src/background/menu/config_menu_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import path from 'path'
import __, { translationsDir } from '../../app/translation'

export const settingsMenuTemplateFunc = (config, onLanguageChange) => ({
label: "Settings",
label: __("Settings"),
submenu: [
{
label: "Main settings",
label: __("Main Settings"),
accelerator: "CmdOrCtrl+O",
click: () => {
BrowserWindow.getFocusedWindow().webContents.send('url', '/config')
}
},
{
label: "Torrents filters",
label: __("Torrents Filters"),
accelerator: "CmdOrCtrl+\\",
click: () => {
BrowserWindow.getFocusedWindow().webContents.send('url', '/filters')
Expand Down
20 changes: 11 additions & 9 deletions src/background/menu/edit_menu_template.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
export const editMenuTemplate = {
label: "Edit",
import __ from '../../app/translation'

export const editMenuTemplateFunc = () => ({
label: __("Edit"),
submenu: [
{ label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" },
{ label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" },
{ label: __("Undo"), accelerator: "CmdOrCtrl+Z", selector: "undo:" },
{ label: __("Redo"), accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" },
{ type: "separator" },
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
{ label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" }
{ label: __("Cut"), accelerator: "CmdOrCtrl+X", selector: "cut:" },
{ label: __("Copy"), accelerator: "CmdOrCtrl+C", selector: "copy:" },
{ label: __("Paste"), accelerator: "CmdOrCtrl+V", selector: "paste:" },
{ label: __("Select All"), accelerator: "CmdOrCtrl+A", selector: "selectAll:" }
]
};
});
13 changes: 7 additions & 6 deletions src/background/menu/manage_menu_template.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import { app, BrowserWindow, shell } from "electron";
import path from "path";
import url from "url";
import __ from '../../app/translation'

export const manageMenuTemplate = {
label: "Manage",
export const manageMenuTemplateFunc = () => ({
label: __("Manage"),
submenu: [
{
label: "Downloads",
label: __("Downloads"),
accelerator: "CmdOrCtrl+d",
click: () => {
BrowserWindow.getFocusedWindow().webContents.send('url', '/downloads')
},
},
{
label: "Search",
label: __("Search"),
accelerator: "CmdOrCtrl+n",
click: () => {
BrowserWindow.getFocusedWindow().webContents.send('url', '/')
},
},
{
label: "Top",
label: __("Top"),
accelerator: "CmdOrCtrl+t",
click: () => {
BrowserWindow.getFocusedWindow().webContents.send('url', '/top')
},
}
]
};
});
22 changes: 21 additions & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
"nameOriginal": "English",
"translations": {
"Language": "Language",
"welcome": "welcome"
"Settings": "Settings",
"Main Settings": "Main Settings",
"Torrents Filters": "Torrents Filters",
"Edit": "Edit",
"Undo": "Undo",
"Redo": "Redo",
"Cut": "Cut",
"Copy": "Copy",
"Paste": "Paste",
"Select All": "Select All",
"Manage": "Manage",
"Downloads": "Downloads",
"Search": "Search",
"Top": "Top",
"About": "About",
"Changelog": "Changelog",
"Bug Report": "Bug Report",
"Donate": "Donate",
"Help (Documentation)": "Help (Documentation)",
"Support (Discussion)": "Support (Discussion)",
"About (GitHub)": "About (GitHub)"
}
}
22 changes: 21 additions & 1 deletion translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
"nameOriginal": "Русский",
"translations": {
"Language": "Язык",
"welcome": "Добро пожаловать"
"Settings": "Настройки",
"Main Settings": "Главные настройки",
"Torrents Filters": "Фильтры торрентов",
"Edit": "Редактировать",
"Undo": "Отменить",
"Redo": "Повторить",
"Cut": "Вырезать",
"Copy": "Копировать",
"Paste": "Вставить",
"Select All": "Выбрать все",
"Manage": "Управление",
"Downloads": "Закачки",
"Search": "Поиск",
"Top": "Топ",
"About": "О программе",
"Changelog": "Список изменений",
"Bug Report": "Сообщить об ошибке",
"Donate": "Пожертвовать на развитие",
"Help (Documentation)": "Помощь (Документация)",
"Support (Discussion)": "Помощь (Обсуждение)",
"About (GitHub)": "О программе (на GitHub)"
}
}

0 comments on commit 8f76005

Please sign in to comment.