mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 19:26:33 +00:00
patch: fixed mac sudo on other languages
This commit is contained in:
parent
407138c999
commit
19d1e093fc
@ -39,4 +39,6 @@ i18next.use(initReactI18next).init({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const supportedLocales = ['en', 'zh'];
|
||||||
|
|
||||||
export default i18next;
|
export default i18next;
|
||||||
|
@ -20,6 +20,7 @@ import { env } from 'process';
|
|||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
|
|
||||||
import { getAppPath } from '../utils';
|
import { getAppPath } from '../utils';
|
||||||
|
import { supportedLocales } from '../../gui/app/i18n';
|
||||||
|
|
||||||
const execFileAsync = promisify(execFile);
|
const execFileAsync = promisify(execFile);
|
||||||
|
|
||||||
@ -32,6 +33,12 @@ export async function sudo(
|
|||||||
try {
|
try {
|
||||||
let lang = Intl.DateTimeFormat().resolvedOptions().locale;
|
let lang = Intl.DateTimeFormat().resolvedOptions().locale;
|
||||||
lang = lang.substr(0, 2);
|
lang = lang.substr(0, 2);
|
||||||
|
if (supportedLocales.indexOf(lang) > -1) {
|
||||||
|
// language should be present
|
||||||
|
} else {
|
||||||
|
// fallback to eng
|
||||||
|
lang = 'en';
|
||||||
|
}
|
||||||
|
|
||||||
const { stdout, stderr } = await execFileAsync(
|
const { stdout, stderr } = await execFileAsync(
|
||||||
'sudo',
|
'sudo',
|
||||||
@ -43,7 +50,7 @@ export async function sudo(
|
|||||||
SUDO_ASKPASS: join(
|
SUDO_ASKPASS: join(
|
||||||
getAppPath(),
|
getAppPath(),
|
||||||
__dirname,
|
__dirname,
|
||||||
'sudo-askpass.osascript-' + lang + '.js',
|
`sudo-askpass.osascript-${lang}.js`,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user