From 1018cdc225f53c8891e32989fcae5591dea90dc6 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 8 Feb 2018 11:49:28 -0500 Subject: [PATCH 1/4] move locale doc to command line switches --- docs/api/app.md | 6 ------ docs/api/chrome-command-line-switches.md | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index 78f22127fd796..04ba49b729d76 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -530,12 +530,6 @@ Returns `String` - The current application locale. Possible return values are do **Note:** On Windows you have to call it after the `ready` events gets emitted. -### `app.setLocale(locale)` - -* `locale` String - -Set the locale of the app (must be called before the `ready` event). - ### `app.addRecentDocument(path)` _macOS_ _Windows_ * `path` String diff --git a/docs/api/chrome-command-line-switches.md b/docs/api/chrome-command-line-switches.md index f3e189fdf43cb..09c24f6c195b2 100644 --- a/docs/api/chrome-command-line-switches.md +++ b/docs/api/chrome-command-line-switches.md @@ -28,6 +28,10 @@ Disables the disk cache for HTTP requests. Disable HTTP/2 and SPDY/3.1 protocols. +## --lang + +Set a custom locale. + ## --inspect=`port` and --inspect-brk=`port` Debug-related flags, see the [Debugging the Main Process][debugging-main-process] guide for details. From e10b5e13e9bb001f33d48a21f780f1979abac142 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 8 Feb 2018 13:00:41 -0500 Subject: [PATCH 2/4] move spec to chromium_spec --- spec/api-app-spec.js | 19 ------------------- spec/chromium-spec.js | 23 ++++++++++++++++++++++- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/spec/api-app-spec.js b/spec/api-app-spec.js index 539cd661dca3a..0eda951b15d6f 100644 --- a/spec/api-app-spec.js +++ b/spec/api-app-spec.js @@ -112,25 +112,6 @@ describe('app module', () => { }) }) - describe('app.setLocale()', () => { - const testLocale = (locale, result, done) => { - const appPath = path.join(__dirname, 'fixtures', 'api', 'locale-check') - const electronPath = remote.getGlobal('process').execPath - let output = '' - let appProcess = ChildProcess.spawn(electronPath, [appPath, `--lang=${locale}`]) - - appProcess.stdout.on('data', (data) => { output += data }) - appProcess.stdout.on('end', () => { - output = output.replace(/(\r\n|\n|\r)/gm, '') - assert.equal(output, result) - done() - }) - } - - it('should set the locale', (done) => testLocale('fr', 'fr', done)) - it('should not set an invalid locale', (done) => testLocale('asdfkl', 'en-US', done)) - }) - describe('app.isInApplicationsFolder()', () => { before(function () { if (process.platform !== 'darwin') { diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index 204cd111b48ee..4e511ad0f0b7d 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -7,7 +7,7 @@ const url = require('url') const {ipcRenderer, remote} = require('electron') const {closeWindow} = require('./window-helpers') -const {app, BrowserWindow, ipcMain, protocol, session, webContents} = remote +const {app, BrowserWindow, ipcMain, protocol, session, webContents, ChildProcess} = remote const isCI = remote.getGlobal('isCi') @@ -26,6 +26,27 @@ describe('chromium feature', () => { listener = null }) + describe('command line switches', () => { + describe('--lang switch', () => { + const testLocale = (locale, result, done) => { + const appPath = path.join(__dirname, 'fixtures', 'api', 'locale-check') + const electronPath = remote.getGlobal('process').execPath + let output = '' + let appProcess = ChildProcess.spawn(electronPath, [appPath, `--lang=${locale}`]) + + appProcess.stdout.on('data', (data) => { output += data }) + appProcess.stdout.on('end', () => { + output = output.replace(/(\r\n|\n|\r)/gm, '') + assert.equal(output, result) + done() + }) + } + + it('should set the locale', (done) => testLocale('fr', 'fr', done)) + it('should not set an invalid locale', (done) => testLocale('asdfkl', 'en-US', done)) + }) + }) + afterEach(() => closeWindow(w).then(() => { w = null })) describe('heap snapshot', () => { From f6d389b159617b5f7c06cd1b0c0498bbbaec06bd Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 8 Feb 2018 13:50:19 -0500 Subject: [PATCH 3/4] fix child process import --- spec/chromium-spec.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index 4e511ad0f0b7d..395dca5700a98 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -4,10 +4,11 @@ const http = require('http') const path = require('path') const ws = require('ws') const url = require('url') +const ChildProcess = require('child_process') const {ipcRenderer, remote} = require('electron') const {closeWindow} = require('./window-helpers') -const {app, BrowserWindow, ipcMain, protocol, session, webContents, ChildProcess} = remote +const {app, BrowserWindow, ipcMain, protocol, session, webContents} = remote const isCI = remote.getGlobal('isCi') @@ -26,7 +27,7 @@ describe('chromium feature', () => { listener = null }) - describe('command line switches', () => { + describe.only('command line switches', () => { describe('--lang switch', () => { const testLocale = (locale, result, done) => { const appPath = path.join(__dirname, 'fixtures', 'api', 'locale-check') From 1e090b9ee78350b108b215c823fb97f7448094c0 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 8 Feb 2018 13:50:44 -0500 Subject: [PATCH 4/4] remove .only --- spec/chromium-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index 395dca5700a98..2d388ca3b5744 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -27,7 +27,7 @@ describe('chromium feature', () => { listener = null }) - describe.only('command line switches', () => { + describe('command line switches', () => { describe('--lang switch', () => { const testLocale = (locale, result, done) => { const appPath = path.join(__dirname, 'fixtures', 'api', 'locale-check')