From 08b02c4065a5ab1badbfda9971949e661c2b2b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredric=20Bergstr=C3=B6m?= Date: Sat, 13 Feb 2021 17:52:25 +0100 Subject: [PATCH 1/2] Added support for Swedish language in app && client. No website yet. updated tests and snapshots --- app/client/public/locales/sv/translation.json | 45 ++ app/client/src/config/i18n.ts | 2 +- app/configs/app.lang.config.ts | 2 + app/configs/i18next.config.client.spec.ts | 2 + app/configs/i18next.config.client.ts | 2 + app/locales/en/translation.json | 1 + app/locales/ru/translation.json | 1 + app/locales/sv/translation.json | 143 ++++++ app/locales/ua/translation.json | 1 + app/main.dev.spec.ts | 420 +++++++++--------- 10 files changed, 405 insertions(+), 214 deletions(-) create mode 100644 app/client/public/locales/sv/translation.json create mode 100644 app/locales/sv/translation.json diff --git a/app/client/public/locales/sv/translation.json b/app/client/public/locales/sv/translation.json new file mode 100644 index 00000000..bc4ff74d --- /dev/null +++ b/app/client/public/locales/sv/translation.json @@ -0,0 +1,45 @@ +{ + "Waiting for user to click ALLOW button on screen sharing device...": "Väntar på att användaren ska klicka på 'TILLÅT' på skärmdelningsenheten...", + "Waiting for user to select source to share from screen sharing device...": "Väntar på att användaren ska välja källa att dela från skärmdelningsenhet...", + "My Device Info": "Min enhetsinformation", + "Device Type": "Enhetens typ", + "Your Device IP should match with Device IP in alert popup appeared on your computer, where Deskreen is running": "Din enhets IP-adress bör matcha med 'Enhetens IP' i den varnings-popup som dyker upp på din dator där Deskreen körs", + "Device IP": "Enhetens IP", + "Device Browser": "Enhetens webbläsare", + "Device OS": "Enhetens operativsystem", + "These details should match with the ones that you see in alert popup on computer screen, where Deskreen is running": "Dessa uppgifter ska matcha de som du ser i popup-fönstret på skärmdelningsenheten.", + "Deskreen Screen Viewer": "Deskreen skärmvisare", + "Connected!": "Ansluten!", + "Error occurred": "Ett fel inträffade", + "Deskreen Error Dialog": "Deskreen felhanterare", + "Something went wrong": "Något blev fel", + "You may close this browser window then try to connect again": "Stäng det här webbläsarfönstret och försök sedan ansluta igen", + "An unknown error occurred": "Ett okänt fel inträffade", + "You were not allowed to connect": "Du fick inte ansluta", + "You were disconnected": "Du blev nedkopplad", + "WebRTC error occurred": "Ett WebRTC-fel error inträffade", + "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Om du gillar Deskreen, överväg i så fall att ge oss ett ekonomiskt bidrag. Deskreen är open-source. Era donationer motiverar oss att göra Deskreen ännu bättre.", + "Donate": "Donera", + "Video stream is paused": "Videoströmmen är pausad", + "Video stream is playing": "Videoströmmen spelas", + "Pause": "Paus", + "Play": "Kör", + "Video Settings": "Videoinställningar", + "Flip": "Omvänd", + "Video quality has been changed to": "Videokvaliteten har ändrats till", + "Click to Open Video Settings": "Klicka här för att öppna videoinställningarna", + "Click to Enter Full Screen Mode": "Klicka här för att gå in i helskärmsläge", + "Default video player has been turned OFF": "Standardvideospelaren har stängts av", + "Default video player has been turned ON": "Standardvideospelaren har aktiverats", + "ON": "PÅ", + "OFF": "AV", + "Default Video Player": "Standardvideospelare", + "Click to visit our website": "Klicka här för att besöka vår webbplats", + "Video is flipped horizontally": "Videon är vänd horisontellt", + "TRANSLATIONS BELOW ARE NOT ADDED TO UI YET, BUT YOUR TRANSLATIONS ARE WELCOME! THE FEATURES WILL BE ADDED SOON SO YOUR TRANSLATIONS ARE NEEDED": "", + "Click to see connection info": "Klicka här för att visa anslutningsinformationen", + "Pair ID": "ID för sammankopplingen", + "Unpair": "Ta bort sammankopplingen", + "Session ID": "ID för sessionen", + "Click to boost video stream if it is lagging": "Klicka för att öka videoströmmen om den släpar efter" +} diff --git a/app/client/src/config/i18n.ts b/app/client/src/config/i18n.ts index 09ff3be8..c6f3d2a4 100644 --- a/app/client/src/config/i18n.ts +++ b/app/client/src/config/i18n.ts @@ -22,7 +22,7 @@ i18n saveMissingTo: 'all', fallbackLng: 'en', // TODO: to generate missing keys use false as value here, will be useful when custom nodejs server is created to store missing values debug: false, // change to true to see debug message logs in browser console - whitelist: ['en', 'es', 'ru', 'ua', 'zh_CN', 'zh_TW', 'da', 'de', 'fi', 'ko', 'it', 'ja', 'nl', 'fr'], + whitelist: ['en', 'es', 'ru', 'ua', 'zh_CN', 'zh_TW', 'da', 'de', 'fi', 'ko', 'it', 'ja', 'nl', 'fr', 'sv'], backend: { // path where resources get loaded from loadPath: '/locales/{{lng}}/{{ns}}.json', diff --git a/app/configs/app.lang.config.ts b/app/configs/app.lang.config.ts index 37c81c0e..6729ce64 100644 --- a/app/configs/app.lang.config.ts +++ b/app/configs/app.lang.config.ts @@ -18,6 +18,7 @@ export default { 'ja', 'nl', 'fr', + 'sv', ], langISOKeyToLangFullNameMap: { en: 'English', @@ -30,6 +31,7 @@ export default { it: 'Italiano', nl: 'Nederlands', fr: 'Français', + sv: 'Svenska', ko: '한국어', zh_CN: '简体中文', zh_TW: '繁體中文', diff --git a/app/configs/i18next.config.client.spec.ts b/app/configs/i18next.config.client.spec.ts index fc6e9b16..684b1919 100644 --- a/app/configs/i18next.config.client.spec.ts +++ b/app/configs/i18next.config.client.spec.ts @@ -37,6 +37,7 @@ describe('i18next.config.client tests', () => { expectedMap.set('Dansk', 'da'); expectedMap.set('Deutsch', 'de'); expectedMap.set('Nederlands', 'nl'); + expectedMap.set('Svenska', 'sv'); const res = getLangFullNameToLangISOKeyMap(); @@ -58,6 +59,7 @@ describe('i18next.config.client tests', () => { expectedMap.set('da', 'Dansk'); expectedMap.set('de', 'Deutsch'); expectedMap.set('nl', 'Nederlands'); + expectedMap.set('sv', 'Svenska'); const res = getLangISOKeyToLangFullNameMap(); diff --git a/app/configs/i18next.config.client.ts b/app/configs/i18next.config.client.ts index 2bf62306..265da1d4 100644 --- a/app/configs/i18next.config.client.ts +++ b/app/configs/i18next.config.client.ts @@ -22,6 +22,7 @@ import translationIT from '../locales/it/translation.json'; import translationJA from '../locales/ja/translation.json'; import translationNL from '../locales/nl/translation.json'; import translationFR from '../locales/fr/translation.json'; +import translationSV from '../locales/sv/translation.json'; import { IpcEvents } from '../main/IpcEvents.enum'; import { ElectronStoreKeys } from '../enums/ElectronStoreKeys.enum'; import store from '../deskreen-electron-store'; @@ -72,6 +73,7 @@ export const getShuffledArrayOfHello = (): string[] => { res.push(translationJA.Hello); res.push(translationNL.Hello); res.push(translationFR.Hello); + res.push(translationSV.Hello); shuffleArray(res); diff --git a/app/locales/en/translation.json b/app/locales/en/translation.json index 4226c9eb..0ab0a5ea 100644 --- a/app/locales/en/translation.json +++ b/app/locales/en/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "nl": "Nederlands", "fr": "Français", + "sv": "Svenska", "Donate": "Donate", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "If you like Deskreen, consider contributing financially. Deskreen is open-source. Your donations keep us motivated to make Deskreen even better.", "Click to visit our website": "Click to visit our website", diff --git a/app/locales/ru/translation.json b/app/locales/ru/translation.json index fc50ca13..dcc2cf2d 100644 --- a/app/locales/ru/translation.json +++ b/app/locales/ru/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "fr": "Français", "nl": "Nederlands", + "sv": "Svenska", "Donate": "Пожертвовать", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Если вам нравится Deskreen, подумайте о том, чтобы внести финансовый вклад. Deskreen - это оупенсорсный проэкт. Ваши пожертвования позволяют нам делать Deskreen еще лучше.", "Click to visit our website": "Нажмите, чтобы посетить наш сайт", diff --git a/app/locales/sv/translation.json b/app/locales/sv/translation.json new file mode 100644 index 00000000..094c7b4c --- /dev/null +++ b/app/locales/sv/translation.json @@ -0,0 +1,143 @@ +{ + "Hello": "Hej", + "Continue": "Fortsätt", + "Language": "Språk", + "ru": "Русский", + "en": "English", + "ua": "Українська", + "sv": "Svenska", + "Donate": "Donera", + "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Om du gillar Deskreen, överväg i så fall att ge oss ett ekonomiskt bidrag. Deskreen är open-source. Era donationer motiverar oss att göra Deskreen ännu bättre.", + "Click to visit our website": "Klicka här för att komma till vår webbplats", + "Connected Devices": "Anslutna enheter", + "Tutorial": "Handledning", + "Settings": "Inställningar", + "Connect": "Anslut", + "Select": "Välj", + "Confirm": "Bekräfta", + "Scan the QR code": "Skanna QR-koden", + "Make sure your computer and screen viewing device are connected to same Wi-Fi": "Se till att din dator och den enhet du tänker använda för skärmdelning båda är anslutna till samma trådlösa nätverk", + "Or type the following address in browser address bar on any device": "Eller skriv in följande adress i webbläsarens addressrad för någon de enheter du vill ansluta med", + "Someone is trying to connect, do you allow?": "Någon försöker ansluta till Deskreen, Tillåter du det?", + "Click to make bigger": "Klicka för att förstora", + "Click to copy": "Klicka för att kopiera", + "Partner Device Info": "Deltagande enhetens information", + "Device Type": "Enhetens typ", + "Device IP": "Enhetens IP", + "Device Browser": "Enhetens webbläsare", + "Device OS": "Enhetens operativsystem", + "Session ID": "ID för sessionen", + "Allow": "Tillåt", + "Deny": "Neka", + "Device is successfully disconnected by you You can connect a new device": "Du har kopplat från enheten. Du kan nu ansluta en ny enhet.", + "Deskreen Update is Available!": "Det finns en uppdatering till Deskreen!", + "Your current version is": "Din nuvarande version är", + "Click to download new updated version": "Klicka här för att ladda ner en uppdaterad version", + "Connected": "Ansluten", + "Click to see more": "Klicka för att visa mer", + "This should match with Device IP displayed on the screen of device that is trying to connect": "Detta bör matcha med det IP som visas på skärmen på den enhet som försöker ansluta.", + "If IP addresses dont match click Disconnect button": "Om IP-adresserna inte matchar, klicka på knappen 'Koppla ner' för att förhindra obehörig åtkomst till din datorskärm.", + "Disconnect": "Koppla ner", + "choose entire screen or app window you want to share": "välj hela skärmen eller ett applikationsfönster som du vill dela", + "or": "eller", + "Entire Screen": "Hela skärmen", + "Application Window": "Applikationsfönster", + "Check if all is OK and click Confirm": "Säkerställ att allt är okej och tryck på 'Bekräfta'", + "Confirm Button Text": "Bekräfta", + "No, I need to choose other": "Nej, Jag vill välja en annan", + "Done!": "Klart!", + "Now you can see your screen on other device": "Nu kan du visa din skärm på en annan enhet.", + "You can manage connected devices by clicking Connected Devices button in top panel": "Du kan hantera anslutna enheter genom att klicka på knappen 'Ansluta enheter' i toppanelen.", + "Connect New Device": "Anslut ny enhet", + "Select Entire Screen to Share": "Välj att dela hela skärmen", + "Select App Window to Share": "Välj ett applikationsfönster att dela", + "Refresh": "Ladda om", + "Disconnect all devices": "Koppla ner alla anslutna enheter", + "Are you sure you want to disconnect all connected viewing devices?": "Är du säker på att du vill koppla ner alla anslutna enheter?", + "This step can not be undone": "Den här åtgärden kan inte ångras", + "You will have to connect all devices manually again": "Du kommer att behöva ansluta till alla enheter manuellt igen", + "No, Cancel": "Nej, Avbryt", + "Yes, Disconnect All": "Ja, Koppla ner alla", + "A new version of Deskreen is available! Click to download new version": "Det finns en ny version av Deskreen tillgänglig! Klicka här för att ladda ned den nya versionen", + "Security": "Säkerhet", + "General": "Allmänt", + "About": "Om", + "Website": "Webbplats", + "About Deskreen": "Om Deskreen", + "Security Settings": "Säkerhetsinställningar", + "Color Theme": "Färgschema", + "Automatic Updates": "Automatiska uppdateringar", + "General Settings": "Generella inställningar", + "Disabled": "Inaktiverad", + "Version": "Version", + "Copyright": "Upphovsrätt", + "Edit": "Redigera", + "Hide Deskreen": "Dölj Deskreen", + "Hide Others": "Dölj Övriga", + "Show All": "Visa Alla", + "Quit": "Avsluta", + "Undo": "Ångra", + "Redo": "Gör om", + "Cut": "Klipp ut", + "Copy": "Kopiera", + "Paste": "Klistra in", + "Select All": "Select All", + "View": "Visa", + "Reload": "Ladda om", + "Toggle Full Screen": "Växla fullskärmsläge", + "Toggle Developer Tools": "Växla utvecklarverktyg", + "Window": "Fönster", + "Minimize": "Minimera", + "Close": "Stäng", + "Bring All to Front": "Ta fram alla", + "Help": "Hjälp", + "Learn More": "Läs mer", + "Documentation": "Dokumentation", + "Community Discussions": "Gemenskapsdiskussioner", + "Search Issues": "Sök efter problem", + "TRANSLATIONS BELOW ARE NOT ADDED TO UI YET, BUT YOUR TRANSLATIONS ARE WELCOME! THE FEATURES WILL BE ADDED SOON SO YOUR TRANSLATIONS ARE NEEDED": "", + "Available Trusted Devices": "Tillgängliga tillförlitliga enheter", + "Make this device trusted": "Gör den här enheten tillförlitlig", + "Click to select other screen source to share": "Klicka här för att välja en annan skärmkälla att dela", + "Click to edit Device Alias": "Klicka här för att redigera enhetens alias", + "Trusted Device ID": "Tillförlitlig enhets ID", + "Trusted": "Tillförlitlig", + "Make Trusted": "Gör den tillförlitlig", + "Forget This Device": "Glöm bort den här enheten", + "Device Alias": "Enhetens alias", + "Auto share last Entire Screen source when device is available": "Dela den senast använda Helskärmen när enheten är tillgänglig", + "All devices are successfully disconnected": "Alla enheter är nu frånkopplade", + "Device was disconnected": "Enheten är nu frånkopplad", + "Networking": "Nätverk", + "Deskreen Application Port": "Post för Deskreen", + "Port is already used by other App": "Porten används redan av en annan applikation", + "Click to change Deskreen Application Port": "Klicka här för att ange en annan port", + "Type a number from 3000 to 64000 to use as a Deskreen Application Port": "Ange ett nummer mellan 3000 och 64000 för att använda som port för Deskreen", + "Type another number in range from 3000 to 64000": "Ange ett annat nummer mellan 3000 och 64000", + "Select Network Interface": "Välj nätverksgränssnitt", + "I know IP of my computer and I want to type it manually": "Jag känner till mitt IP-nummer och och vill ange det manuellt", + "Type Your Computer IP": "Ange din dators IP-nummer", + "Click to type IP manually": "Klicka här för att ange ditt IP-nummer manuellt", + "Banned IPs": "Blockerade IP-nummer", + "Ban New IP": "Blockera nytt IP-nummer", + "Type the IP you want to ban": "Ange det IP-nummer du vill blockera", + "Unban this IP": "Tillåt det här IP-numret", + "Unban all IPs": "Tillåt alla IP-nummer", + "Reset Deskreen settings to default": "Återställ Deskreen inställningar till standardinställningarna", + "Ask user to enter password when connecting": "Be användaren att ange lösenord vid anslutning", + "Change Password": "Ändra lösenord", + "Type a New Password": "Ange ett nytt lösenord", + "Cancel": "Avbryt", + "Device Status": "Enhetens status", + "Sharing Screen": "Delar skärm", + "Available, no screen sharing": "Tillgängliga, ingen skärmdelning", + "Not Available": "Inte tillgängligt", + "Autostart Deskreen App on login": "Starta Deskreen automatiskt vid inloggning", + "Open Deskreen App window on login": "Öppna Deskreen automatiskt vid inloggning", + "Use system tray": "Use system tray", + "Deskreen System Tray": "Deskreen System Tray", + "Open App Window": "Öppna Applikationsfönstret", + "Minimize To Tray": "Minimize To Tray", + "Show Connected Devices": "Visa Anslutna Enheter", + "Quit Deskreen": "Avsluta Deskreen" +} diff --git a/app/locales/ua/translation.json b/app/locales/ua/translation.json index f645746a..4cdce6e5 100644 --- a/app/locales/ua/translation.json +++ b/app/locales/ua/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "nl": "Nederlands", "fr": "Français", + "sv": "Svenska", "Donate": "Пожертвувати", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Якщо вам подобається Deskreen, подумайте про те, щоб внести фінансовий внесок. Deskreen - це оупенсорсний проект. Ваші пожертвування дозволяють нам робити Deskreen ще краще.", "Click to visit our website": "Натисніть, щоб відвідати наш сайт", diff --git a/app/main.dev.spec.ts b/app/main.dev.spec.ts index 1f9005f7..303044d6 100644 --- a/app/main.dev.spec.ts +++ b/app/main.dev.spec.ts @@ -25,219 +25,213 @@ // { id: 'd2' }, // { id: 'd3' }, // ]; -// const TEST_CONNECTED_DEVICES_SERVICE = ({ -// sdf: 'fda', -// } as unknown) as ConnectedDevicesService; -// const TEST_ROOM_ID_SERVICE = ({ -// a223: '2g2g', -// } as unknown) as ConnectedDevicesService; -// const testMapSharingSessions = new Map(); -// testMapSharingSessions.set('1', { -// denyConnectionForPartner: jest.fn(), -// destroy: jest.fn(), -// }); -// testMapSharingSessions.set('2', { -// denyConnectionForPartner: jest.fn(), -// destroy: jest.fn(), -// }); -// const TEST_SHARING_SESSIONS_SERVICE = ({ -// waitingForConnectionSharingSession: '2342a', -// sharingSessions: testMapSharingSessions, -// } as unknown) as SharingSessionService; -// const testMapHelpers = new Map(); -// testMapHelpers.set('1', { close: jest.fn() }); -// testMapHelpers.set('2', { close: jest.fn() }); -// const TEST_RENDERER_WEBRTC_HELPERS_SERVICE = ({ -// helpers: testMapHelpers, -// } as unknown) as RendererWebrtcHelpersService; -// const mockGlobal = { -// connectedDevicesService: TEST_CONNECTED_DEVICES_SERVICE, -// roomIDService: TEST_ROOM_ID_SERVICE, -// sharingSessionService: TEST_SHARING_SESSIONS_SERVICE, -// rendererWebrtcHelpersService: TEST_RENDERER_WEBRTC_HELPERS_SERVICE, -// }; - -// jest.useFakeTimers(); - -// jest.mock('./utils/installExtensions'); -// jest.mock('./utils/AppUpdater'); -// jest.mock('./main.dev', () => { -// return { -// __esModule: true, // this property makes it work -// default: jest.requireActual('./main.dev').default, -// }; -// }); -// jest.mock('./utils/mainProcessHelpers/getDeskreenGlobal'); -// jest.mock('./utils/mainProcessHelpers/initGlobals'); -// jest.mock('electron', () => { -// return { -// app: { -// quit: jest.fn(), -// on: jest.fn(), -// getName: jest.fn(), -// getVersion: jest.fn(), -// commandLine: { -// appendSwitch: jest.fn(), -// }, -// whenReady: jest -// .fn() -// .mockReturnValue(new Promise((resolve) => resolve(undefined))), -// }, -// ipcMain: { -// handle: jest.fn(), -// on: jest.fn(), -// }, -// screen: { -// getAllDisplays: jest -// .fn() -// .mockReturnValue(TEST_SCREEN_GET_ALL_DISPLAYS_RESULT), -// }, -// BrowserWindow: jest.fn().mockReturnValue({ -// loadURL: jest.fn(), -// on: jest.fn(), -// webContents: { -// on: jest.fn(), -// toggleDevTools: jest.fn(), -// }, -// minimize: jest.fn(), -// show: jest.fn(), -// focus: jest.fn(), -// }), -// }; -// }); -// jest.mock('./server', () => { -// return { -// start: jest.fn(), -// port: TEST_SIGNALING_SERVER_PORT, -// }; -// }); -// jest.mock('source-map-support', () => { -// return { -// install: jest.fn(), -// }; -// }); -// jest.mock('electron-debug'); -// jest.mock('electron-devtools-installer', () => { -// return { -// default: jest.fn(), -// REACT_DEVELOPER_TOOLS: 'REACT_DEVELOPER_TOOLS', -// REDUX_DEVTOOLS: 'REDUX_DEVTOOLS', -// }; -// }); -// jest.mock('./configs/i18next.config', () => { -// return { -// on: jest.fn(), -// changeLanguage: jest.fn(), -// off: jest.fn(), -// language: 'ua', -// }; -// }); -// jest.mock('./menu'); -// jest.mock('electron-settings', () => { -// return { -// set: jest.fn(), -// }; -// }); - -// describe('app main.dev tests', () => { -// let testApp: DeskreenApp; - -// beforeEach(() => { -// jest.clearAllMocks(); -// jest.restoreAllMocks(); -// // @ts-ignore -// MenuBuilder.mockClear(); -// // @ts-ignore -// installExtensions.mockClear(); - -// testApp = new DeskreenApp(); -// }); - -// describe('when DeskreenApp created properly', () => { -// describe('when .start() was called', () => { -// it('should call initGlobals', () => { -// testApp.start(); - -// expect(initGlobals).toBeCalled(); -// }); - -// it('should call signalingServer.start()', () => { -// testApp.start(); - -// expect(signalingServer.start).toBeCalled(); -// }); - -// it('should call .initElectronAppObject()', () => { -// testApp.initElectronAppObject = jest.fn(); - -// testApp.start(); - -// expect(testApp.initElectronAppObject).toBeCalled(); -// }); - -// it('should call .initIpcMain()', () => { -// testApp.initIpcMain = jest.fn(); - -// testApp.start(); - -// expect(testApp.initIpcMain).toBeCalled(); -// }); - -// describe('when initElectronAppObject was called', () => { -// it('should set app.on("window-all-closed" listener', () => { -// testApp.initElectronAppObject(); - -// expect(app.on).toHaveBeenCalledWith( -// 'window-all-closed', -// expect.anything() -// ); -// }); - -// it('should call app.commandLine.appendSwitch with "webrtc-max-cpu-consumption-percentage","100"', () => { -// testApp.initElectronAppObject(); - -// expect(app.commandLine.appendSwitch).toHaveBeenCalledWith( -// 'webrtc-max-cpu-consumption-percentage', -// '100' -// ); -// }); - -// describe('when process.env.E2E_BUILD !== "true"', () => { -// it('should set app.on("ready" listener', () => { -// const processEnvBackup = process.env.E2E_BUILD; -// process.env.E2E_BUILD = 'false'; - -// testApp.initElectronAppObject(); - -// expect(app.on).toHaveBeenCalledWith('ready', expect.anything()); - -// process.env.E2E_BUILD = processEnvBackup; -// }); -// }); - -// describe('when process.env.E2E_BUILD === "true"', () => { -// it('should set app.on("ready" listener', () => { -// const processEnvBackup = process.env.E2E_BUILD; -// process.env.E2E_BUILD = 'true'; - -// testApp.initElectronAppObject(); - -// expect(app.whenReady).toHaveBeenCalled(); - -// process.env.E2E_BUILD = processEnvBackup; -// }); -// }); - -// describe('when app.on("window-all-closed" event occured', () => { -// describe('when running on NOT darwin platform', () => { -// it('should call app.quit()', () => { -// const processBackup = process; -// // @ts-ignore -// // eslint-disable-next-line no-global-assign -// process = { -// ...processBackup, -// platform: 'linux', -// }; +const testMapSharingSessions = new Map(); +testMapSharingSessions.set('1', { + denyConnectionForPartner: jest.fn(), + destroy: jest.fn(), +}); +testMapSharingSessions.set('2', { + denyConnectionForPartner: jest.fn(), + destroy: jest.fn(), +}); +const TEST_SHARING_SESSIONS_SERVICE = ({ + waitingForConnectionSharingSession: '2342a', + sharingSessions: testMapSharingSessions, +} as unknown) as SharingSessionService; +const testMapHelpers = new Map(); +testMapHelpers.set('1', { close: jest.fn() }); +testMapHelpers.set('2', { close: jest.fn() }); +const TEST_RENDERER_WEBRTC_HELPERS_SERVICE = ({ + helpers: testMapHelpers, +} as unknown) as RendererWebrtcHelpersService; +const mockGlobal = { + connectedDevicesService: TEST_CONNECTED_DEVICES_SERVICE, + roomIDService: TEST_ROOM_ID_SERVICE, + sharingSessionService: TEST_SHARING_SESSIONS_SERVICE, + rendererWebrtcHelpersService: TEST_RENDERER_WEBRTC_HELPERS_SERVICE, +}; + +jest.useFakeTimers(); + +jest.mock('./utils/installExtensions'); +jest.mock('./utils/AppUpdater'); +jest.mock('./main.dev', () => { + return { + __esModule: true, // this property makes it work + default: jest.requireActual('./main.dev').default, + }; +}); +jest.mock('./utils/mainProcessHelpers/getDeskreenGlobal'); +jest.mock('./utils/mainProcessHelpers/initGlobals'); +jest.mock('electron', () => { + return { + app: { + quit: jest.fn(), + on: jest.fn(), + getName: jest.fn(), + getVersion: jest.fn(), + commandLine: { + appendSwitch: jest.fn(), + }, + whenReady: jest + .fn() + .mockReturnValue(new Promise((resolve) => resolve(undefined))), + }, + ipcMain: { + handle: jest.fn(), + on: jest.fn(), + }, + screen: { + getAllDisplays: jest + .fn() + .mockReturnValue(TEST_SCREEN_GET_ALL_DISPLAYS_RESULT), + }, + BrowserWindow: jest.fn().mockReturnValue({ + loadURL: jest.fn(), + on: jest.fn(), + webContents: { + on: jest.fn(), + toggleDevTools: jest.fn(), + }, + minimize: jest.fn(), + show: jest.fn(), + focus: jest.fn(), + }), + }; +}); +jest.mock('./server', () => { + return { + start: jest.fn(), + port: TEST_SIGNALING_SERVER_PORT, + }; +}); +jest.mock('source-map-support', () => { + return { + install: jest.fn(), + }; +}); +jest.mock('electron-debug'); +jest.mock('electron-devtools-installer', () => { + return { + default: jest.fn(), + REACT_DEVELOPER_TOOLS: 'REACT_DEVELOPER_TOOLS', + REDUX_DEVTOOLS: 'REDUX_DEVTOOLS', + }; +}); +jest.mock('./configs/i18next.config', () => { + return { + on: jest.fn(), + changeLanguage: jest.fn(), + off: jest.fn(), + language: 'sv', + }; +}); +jest.mock('./menu'); +jest.mock('electron-settings', () => { + return { + set: jest.fn(), + }; +}); + +describe('app main.dev tests', () => { + let testApp: DeskreenApp; + + beforeEach(() => { + jest.clearAllMocks(); + jest.restoreAllMocks(); + // @ts-ignore + MenuBuilder.mockClear(); + // @ts-ignore + installExtensions.mockClear(); + + testApp = new DeskreenApp(); + }); + + describe('when DeskreenApp created properly', () => { + describe('when .start() was called', () => { + it('should call initGlobals', () => { + testApp.start(); + + expect(initGlobals).toBeCalled(); + }); + + it('should call signalingServer.start()', () => { + testApp.start(); + + expect(signalingServer.start).toBeCalled(); + }); + + it('should call .initElectronAppObject()', () => { + testApp.initElectronAppObject = jest.fn(); + + testApp.start(); + + expect(testApp.initElectronAppObject).toBeCalled(); + }); + + it('should call .initIpcMain()', () => { + testApp.initIpcMain = jest.fn(); + + testApp.start(); + + expect(testApp.initIpcMain).toBeCalled(); + }); + + describe('when initElectronAppObject was called', () => { + it('should set app.on("window-all-closed" listener', () => { + testApp.initElectronAppObject(); + + expect(app.on).toHaveBeenCalledWith( + 'window-all-closed', + expect.anything() + ); + }); + + it('should call app.commandLine.appendSwitch with "webrtc-max-cpu-consumption-percentage","100"', () => { + testApp.initElectronAppObject(); + + expect(app.commandLine.appendSwitch).toHaveBeenCalledWith( + 'webrtc-max-cpu-consumption-percentage', + '100' + ); + }); + + describe('when process.env.E2E_BUILD !== "true"', () => { + it('should set app.on("ready" listener', () => { + const processEnvBackup = process.env.E2E_BUILD; + process.env.E2E_BUILD = 'false'; + + testApp.initElectronAppObject(); + + expect(app.on).toHaveBeenCalledWith('ready', expect.anything()); + + process.env.E2E_BUILD = processEnvBackup; + }); + }); + + describe('when process.env.E2E_BUILD === "true"', () => { + it('should set app.on("ready" listener', () => { + const processEnvBackup = process.env.E2E_BUILD; + process.env.E2E_BUILD = 'true'; + + testApp.initElectronAppObject(); + + expect(app.whenReady).toHaveBeenCalled(); + + process.env.E2E_BUILD = processEnvBackup; + }); + }); + + describe('when app.on("window-all-closed" event occured', () => { + describe('when running on NOT darwin platform', () => { + it('should call app.quit()', () => { + const processBackup = process; + // @ts-ignore + // eslint-disable-next-line no-global-assign + process = { + ...processBackup, + platform: 'linux', + }; // testApp.initElectronAppObject(); From 5bfd1b240aa5e5d983f8209bdaca1f50919e8b9c Mon Sep 17 00:00:00 2001 From: Pavlo Buidenkov Date: Fri, 3 Jun 2022 00:19:34 +0200 Subject: [PATCH 2/2] add swedish language --- app/locales/da/translation.json | 1 + app/locales/de/translation.json | 1 + app/locales/es/translation.json | 1 + app/locales/fi/translation.json | 1 + app/locales/fr/translation.json | 1 + app/locales/it/translation.json | 1 + app/locales/ja/translation.json | 1 + app/locales/ko/translation.json | 1 + app/locales/nl/translation.json | 1 + app/locales/sv/translation.json | 11 +++++++++++ app/locales/zh_CN/translation.json | 1 + app/locales/zh_TW/translation.json | 1 + 12 files changed, 22 insertions(+) diff --git a/app/locales/da/translation.json b/app/locales/da/translation.json index dfb85625..d75b7287 100644 --- a/app/locales/da/translation.json +++ b/app/locales/da/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "fr": "Français", "nl": "Nederlands", + "sv": "Svenska", "Donate": "Donér", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Hvis du er vild med Deskreen, så overvej at bidrage til Deskreen financielt. Deskreen er open-source. Dine donationer hjælper os med at forblive motiverede for at gøre Deskreen endnu bedre.", "Click to visit our website": "Klik her for at besøge vores hjemmeside", diff --git a/app/locales/de/translation.json b/app/locales/de/translation.json index 030df0e7..694554cd 100644 --- a/app/locales/de/translation.json +++ b/app/locales/de/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "fr": "Français", "nl": "Nederlands", + "sv": "Svenska", "Donate": "Spenden", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Wenn dir Deskreen gefällt, denke über eine Spende nach. Deskreen ist Open-Source. Spenden motivieren uns, Deskreen noch besser zu machen.", "Click to visit our website": "Klicken um unsere Website zu besuchen", diff --git a/app/locales/es/translation.json b/app/locales/es/translation.json index 32dee0b0..d9048f61 100644 --- a/app/locales/es/translation.json +++ b/app/locales/es/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "fr": "Français", "nl": "Nederlands", + "sv": "Svenska", "Donate": "Donar", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Si te gusta Deskreen, considera la posibilidad de contribuir económicamente. Deskreen es de código abierto. Tus donaciones nos mantienen motivados para hacer que Deskreen sea aún mejor.", "Click to visit our website": "Clic para visitar nuestro sitio web", diff --git a/app/locales/fi/translation.json b/app/locales/fi/translation.json index c360f871..cda92933 100644 --- a/app/locales/fi/translation.json +++ b/app/locales/fi/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "fr": "Français", "nl": "Nederlands", + "sv": "Svenska", "Donate": "Lahjoittaa", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Jos pidät Deskreen, harkitse taloudellista osallistumista. Deskreen on avoimen lähdekoodin lähde. Lahjoituksesi motivoivat meitä tekemään Deskreen entistä paremman.", "Click to visit our website": "Napsauta vieraillaksesi verkkosivuillamme", diff --git a/app/locales/fr/translation.json b/app/locales/fr/translation.json index 9f4637bc..116799f5 100644 --- a/app/locales/fr/translation.json +++ b/app/locales/fr/translation.json @@ -16,6 +16,7 @@ "it": "Italiano", "ja": "日本語", "nl": "Nederlands", + "sv": "Svenska", "Donate": "Donation", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Si vous aimez Deskreen, Vous pouvez contribuer financièrement. Deskreen est open-source. Votre don nous motivera à rendre Deskreen encore meilleur .", "Click to visit our website": "Cliquez ici pour visiter notre site web", diff --git a/app/locales/it/translation.json b/app/locales/it/translation.json index 1f7dea47..eee27144 100644 --- a/app/locales/it/translation.json +++ b/app/locales/it/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "fr": "Français", "nl": "Nederlands", + "sv": "Svenska", "Donate": "Dona", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Se ti piace Deskreen, considera di contribuire finanziariamente. Deskreen è open-source. Le tue donazioni ci motivano a rendere Deskreen ancora migliore.", "Click to visit our website": "Clicca per visitare il nostro sito", diff --git a/app/locales/ja/translation.json b/app/locales/ja/translation.json index 2a5c98f1..8d8d59b0 100644 --- a/app/locales/ja/translation.json +++ b/app/locales/ja/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "fr": "Français", "nl": "Nederlands", + "sv": "Svenska", "Donate": "寄付", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Deskreenを気に入っていただけたなら、資金面での貢献をご検討ください。 Deskreenはオープンソースです。あなたの寄付により、Deskreenをより良くするためのモチベーションが保つことができます。", "Click to visit our website": "クリックするとウェブサイトが開きます。", diff --git a/app/locales/ko/translation.json b/app/locales/ko/translation.json index e55a0d48..ecd438ec 100644 --- a/app/locales/ko/translation.json +++ b/app/locales/ko/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "fr": "Français", "nl": "Nederlands", + "sv": "Svenska", "Donate": "기부하기", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "오픈소스 프로젝트에 재정적으로 기여하는 것은 더 좋은 프로그램 개발 동기를 부여합니다.", "Click to visit our website": "클릭하면 웹 사이트를 방문합니다", diff --git a/app/locales/nl/translation.json b/app/locales/nl/translation.json index 57de84aa..7ab4b097 100644 --- a/app/locales/nl/translation.json +++ b/app/locales/nl/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "fr": "Français", "nl": "Nederlands", + "sv": "Svenska", "Donate": "Doneer", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Als u Deskreen waardeert, overweeg dan een financiële bijdrage. Deskreen is open-source. Uw donaties houden ons gemotiveerd om Deskreen te blijven verbeteren.", "Click to visit our website": "Klik om onze website te bezoeken", diff --git a/app/locales/sv/translation.json b/app/locales/sv/translation.json index 094c7b4c..fee3f50e 100644 --- a/app/locales/sv/translation.json +++ b/app/locales/sv/translation.json @@ -4,7 +4,18 @@ "Language": "Språk", "ru": "Русский", "en": "English", + "es": "Español", "ua": "Українська", + "zh_CN": "简体中文", + "zh_TW": "繁體中文", + "da": "Dansk", + "de": "Deutsch", + "fi": "Suomi", + "ko": "한국어", + "it": "Italiano", + "ja": "日本語", + "fr": "Français", + "nl": "Nederlands", "sv": "Svenska", "Donate": "Donera", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "Om du gillar Deskreen, överväg i så fall att ge oss ett ekonomiskt bidrag. Deskreen är open-source. Era donationer motiverar oss att göra Deskreen ännu bättre.", diff --git a/app/locales/zh_CN/translation.json b/app/locales/zh_CN/translation.json index 389b0ef5..bd92aecf 100644 --- a/app/locales/zh_CN/translation.json +++ b/app/locales/zh_CN/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "fr": "Français", "nl": "Nederlands", + "sv": "Svenska", "Donate": "捐赠", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "如果你喜欢 Deskreen,可以考虑出钱。Deskreen 是开源的。您的捐赠使我们有动力让 Deskreen 变得更好。", "Click to visit our website": "点击访问我们的网站", diff --git a/app/locales/zh_TW/translation.json b/app/locales/zh_TW/translation.json index 4af3a71a..d67b3f91 100644 --- a/app/locales/zh_TW/translation.json +++ b/app/locales/zh_TW/translation.json @@ -16,6 +16,7 @@ "ja": "日本語", "fr": "Français", "nl": "Nederlands", + "sv": "Svenska", "Donate": "捐贈", "If you like Deskreen consider contributing financially Deskreen is open-source Your donations keep us motivated to make Deskreen even better": "如果你喜歡 Deskreen,可以考慮出錢。Deskreen 是開源的。您的捐贈使我們有動力讓 Deskreen 變得更好。", "Click to visit our website": "點選訪問我們的網站",