add about dialog i18n

fixes #2711
closes #2721
pull/2728/head
Mikael Finstad 5 months ago
parent 260128e165
commit 2601283032
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -5,6 +5,7 @@
"\"ffmpeg\" experimental flag": "\"ffmpeg\" experimental flag", "\"ffmpeg\" experimental flag": "\"ffmpeg\" experimental flag",
"(data tracks such as GoPro GPS, telemetry etc. are not copied over by default because ffmpeg cannot cut them, thus they will cause the media duration to stay the same after cutting video/audio)": "(data tracks such as GoPro GPS, telemetry etc. are not copied over by default because ffmpeg cannot cut them, thus they will cause the media duration to stay the same after cutting video/audio)", "(data tracks such as GoPro GPS, telemetry etc. are not copied over by default because ffmpeg cannot cut them, thus they will cause the media duration to stay the same after cutting video/audio)": "(data tracks such as GoPro GPS, telemetry etc. are not copied over by default because ffmpeg cannot cut them, thus they will cause the media duration to stay the same after cutting video/audio)",
"(detected)": "(detected)", "(detected)": "(detected)",
"{{appStoreType}} edition, based on GitHub v{{appVersion}}": "{{appStoreType}} edition, based on GitHub v{{appVersion}}",
"{{durationMsFormatted}} ms": "{{durationMsFormatted}} ms", "{{durationMsFormatted}} ms": "{{durationMsFormatted}} ms",
"{{frameCount}} frames": "{{frameCount}} frames", "{{frameCount}} frames": "{{frameCount}} frames",
"{{numFrames}} frames_one": "{{numFrames}} frames", "{{numFrames}} frames_one": "{{numFrames}} frames",
@ -143,6 +144,7 @@
"Copy selected segments times to clipboard": "Copy selected segments times to clipboard", "Copy selected segments times to clipboard": "Copy selected segments times to clipboard",
"Copy to clipboard": "Copy to clipboard", "Copy to clipboard": "Copy to clipboard",
"Copy to YouTube description/comment:": "Copy to YouTube description/comment:", "Copy to YouTube description/comment:": "Copy to YouTube description/comment:",
"Copyright": "Copyright",
"Could not open media due to error {{errorCode}}": "Could not open media due to error {{errorCode}}", "Could not open media due to error {{errorCode}}": "Could not open media due to error {{errorCode}}",
"Create byte sized segments": "Create byte sized segments", "Create byte sized segments": "Create byte sized segments",
"Create chapters from merged segments? (slow)": "Create chapters from merged segments (slow)", "Create chapters from merged segments? (slow)": "Create chapters from merged segments (slow)",

@ -1,6 +1,7 @@
import type { AboutPanelOptionsOptions } from 'electron'; import type { AboutPanelOptionsOptions } from 'electron';
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import { app } from 'electron'; import { app } from 'electron';
import { t } from 'i18next';
import { appName, copyrightYear } from './common.js'; import { appName, copyrightYear } from './common.js';
import { isLinux } from './util.js'; import { isLinux } from './util.js';
@ -15,7 +16,7 @@ export function getAboutPanelOptions() {
const aboutPanelLines = [ const aboutPanelLines = [
isStoreBuild ? homepageUrl : githubUrl, isStoreBuild ? homepageUrl : githubUrl,
'', '',
`Copyright © 2016-${copyrightYear} Mikael Finstad ❤️ 🇳🇴`, `${t('Copyright')} © 2016-${copyrightYear} Mikael Finstad ❤️ 🇳🇴`,
]; ];
const aboutPanelOptions: AboutPanelOptionsOptions = { const aboutPanelOptions: AboutPanelOptionsOptions = {
@ -30,7 +31,7 @@ export function getAboutPanelOptions() {
aboutPanelOptions.applicationVersion = appVersion; aboutPanelOptions.applicationVersion = appVersion;
} else if (isStoreBuild) { } else if (isStoreBuild) {
// https://github.com/mifi/lossless-cut/issues/1882 // https://github.com/mifi/lossless-cut/issues/1882
aboutPanelOptions.applicationVersion = `${process.windowsStore ? 'Microsoft Store' : 'App Store'} edition, based on GitHub v${appVersion}`; aboutPanelOptions.applicationVersion = t('{{appStoreType}} edition, based on GitHub v{{appVersion}}', { appStoreType: process.windowsStore ? 'Microsoft Store' : 'App Store', appVersion });
} }
return aboutPanelOptions; return aboutPanelOptions;

@ -8,7 +8,7 @@ import { commonI18nOptions, loadPath, addPath } from './i18nCommon.js';
// See also renderer // See also renderer
// https://github.com/i18next/i18next/issues/869 // https://github.com/i18next/i18next/issues/869
export default i18n export default await i18n
.use(Backend) .use(Backend)
.use({ type: 'languageDetector', async: false, detect: () => app.getLocale() }) .use({ type: 'languageDetector', async: false, detect: () => app.getLocale() })
// See also i18next.config.base.ts // See also i18next.config.base.ts

@ -58,9 +58,6 @@ if (isWindows) {
app.setAppUserModelId(app.name); app.setAppUserModelId(app.name);
} }
// https://www.electronjs.org/docs/latest/api/app#appsetaboutpaneloptionsoptions
app.setAboutPanelOptions(getAboutPanelOptions());
let filesToOpen: string[] = []; let filesToOpen: string[] = [];
// Keep a global reference of the window object, if you don't, the window will // Keep a global reference of the window object, if you don't, the window will
@ -197,6 +194,17 @@ function updateMenu() {
menu({ app, mainWindow, newVersion, isStoreBuild }); menu({ app, mainWindow, newVersion, isStoreBuild });
} }
async function changeLanguage(language: string | null) {
try {
await i18n.changeLanguage(language ?? undefined);
updateMenu();
// https://www.electronjs.org/docs/latest/api/app#appsetaboutpaneloptionsoptions
app.setAboutPanelOptions(getAboutPanelOptions());
} catch (err) {
logger.error('Failed to set language', err);
}
}
function openFilesEventually(paths: string[]) { function openFilesEventually(paths: string[]) {
if (rendererReady) openFiles(paths); if (rendererReady) openFiles(paths);
else filesToOpen = paths; else filesToOpen = paths;
@ -250,6 +258,7 @@ async function init() {
logger.info('Initialized config store'); logger.info('Initialized config store');
const allowMultipleInstances = configStore.get('allowMultipleInstances'); const allowMultipleInstances = configStore.get('allowMultipleInstances');
const language = configStore.get('language');
if (!allowMultipleInstances && !safeRequestSingleInstanceLock({ argv: process.argv })) { if (!allowMultipleInstances && !safeRequestSingleInstanceLock({ argv: process.argv })) {
logger.info('Found running instance, quitting'); logger.info('Found running instance, quitting');
@ -307,9 +316,7 @@ async function init() {
askBeforeClose = val; askBeforeClose = val;
}); });
ipcMain.on('setLanguage', (_e, language) => { ipcMain.on('setLanguage', (_e, newLanguage) => changeLanguage(newLanguage));
i18n.changeLanguage(language).then(() => updateMenu()).catch((err) => logger.error('Failed to set language', err));
});
ipcMain.handle('tryTrashItem', async (_e, path) => { ipcMain.handle('tryTrashItem', async (_e, path) => {
try { try {
@ -362,7 +369,8 @@ async function init() {
} }
createWindow(); createWindow();
updateMenu(); // will also updateMenu and set about panel options
await changeLanguage(language);
const enableUpdateCheck = configStore.get('enableUpdateCheck'); const enableUpdateCheck = configStore.get('enableUpdateCheck');

Loading…
Cancel
Save