mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
ELECTRON-535 (Add support for screen snippet localization) (#407)
- Bump screen snippet ver to 1.0.2 add support for screen snippet localization - Update getLanguage to return system locale
This commit is contained in:
parent
a26a1d609c
commit
ee321b2b13
@ -11,6 +11,7 @@ const { isMac, isDevEnv } = require('../utils/misc.js');
|
||||
const log = require('../log.js');
|
||||
const logLevels = require('../enums/logLevels.js');
|
||||
const eventEmitter = require('.././eventEmitter');
|
||||
const { getLanguage } = require('../translation/i18n');
|
||||
|
||||
// static ref to child process, only allow one screen snippet at time, so
|
||||
// hold ref to prev, so can kill before starting next snippet.
|
||||
@ -77,7 +78,7 @@ class ScreenSnippet {
|
||||
}
|
||||
}
|
||||
|
||||
captureUtilArgs = [outputFileName];
|
||||
captureUtilArgs = [outputFileName, getLanguage()];
|
||||
}
|
||||
|
||||
log.send(logLevels.INFO, 'ScreenSnippet: starting screen capture util: ' + captureUtil + ' with args=' + captureUtilArgs);
|
||||
|
@ -1,5 +1,11 @@
|
||||
const electron = require('electron');
|
||||
const app = electron.app;
|
||||
const path = require("path");
|
||||
const fs = require('fs');
|
||||
|
||||
const log = require('../log.js');
|
||||
const logLevels = require('../enums/logLevels.js');
|
||||
|
||||
let language;
|
||||
let loadedTranslations = {};
|
||||
|
||||
@ -16,7 +22,22 @@ const setLanguage = function(lng) {
|
||||
loadedTranslations = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'locale', language + '.json'), 'utf8'));
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the current locale
|
||||
* @return {*|string}
|
||||
*/
|
||||
const getLanguage = function() {
|
||||
let sysLocale;
|
||||
try {
|
||||
sysLocale = app.getLocale();
|
||||
} catch (err) {
|
||||
log.send(logLevels.WARN, `i18n: Failed to fetch app.getLocale with an ${err}`);
|
||||
}
|
||||
return language || sysLocale || 'en-US';
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
setLanguage: setLanguage,
|
||||
getMessageFor: getMessageFor
|
||||
getMessageFor: getMessageFor,
|
||||
getLanguage: getLanguage,
|
||||
};
|
@ -134,7 +134,7 @@
|
||||
"winreg": "1.2.4"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"screen-snippet": "git+https://github.com/symphonyoss/ScreenSnippet.git#v1.0.1",
|
||||
"screen-snippet": "git+https://github.com/symphonyoss/ScreenSnippet.git#v1.0.2",
|
||||
"electron-utils": "git+https://github.com/symphonyoss/electron-utils.git#v1.0.5"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user