add translation for backup.js

This commit is contained in:
Nriver 2024-08-14 11:07:00 +08:00
parent a9b094bf27
commit b231905981
3 changed files with 42 additions and 11 deletions

View File

@ -1,45 +1,46 @@
import { t } from "../../../services/i18n.js";
import server from "../../../services/server.js";
import toastService from "../../../services/toast.js";
import OptionsWidget from "./options_widget.js";
const TPL = `
<div class="options-section">
<h4>Automatic backup</h4>
<h4>${t('backup.automatic_backup')}</h4>
<p>Trilium can back up the database automatically:</p>
<p>${t('backup.automatic_backup_description')}</p>
<ul style="list-style: none">
<li>
<label>
<input type="checkbox" class="daily-backup-enabled">
Enable daily backup
${t('backup.enable_daily_backup')}
</label>
</li>
<li>
<label>
<input type="checkbox" class="weekly-backup-enabled">
Enable weekly backup
${t('backup.enable_weekly_backup')}
</label>
</li>
<li>
<label>
<input type="checkbox" class="monthly-backup-enabled">
Enable monthly backup
${t('backup.enable_monthly_backup')}
</label>
</li>
</ul>
<p>It's recommended to keep the backup turned on, but this can make application startup slow with large databases and/or slow storage devices.</p>
<p>${t('backup.backup_recommendation')}</p>
</div>
<div class="options-section">
<h4>Backup now</h4>
<h4>${t('backup.backup_now')}</h4>
<button class="backup-database-button btn">Backup database now</button>
<button class="backup-database-button btn">${t('backup.backup_database_now')}</button>
</div>
<div class="options-section">
<h4>Existing backups</h4>
<h4>${t('backup.existing_backups')}</h4>
<ul class="existing-backup-list"></ul>
</div>
@ -54,7 +55,7 @@ export default class BackupOptions extends OptionsWidget {
this.$backupDatabaseButton.on('click', async () => {
const {backupFile} = await server.post('database/backup-database');
toastService.showMessage(`Database has been backed up to ${backupFile}`, 10000);
toastService.showMessage(`${t('backup.database_backed_up_to')} ${backupFile}`, 10000);
this.refresh();
});
@ -84,7 +85,7 @@ export default class BackupOptions extends OptionsWidget {
this.$existingBackupList.empty();
if (!backupFiles.length) {
backupFiles = [{filePath: "no backup yet", mtime: ''}];
backupFiles = [{filePath: t('backup.no_backup_yet'), mtime: ''}];
}
for (const {filePath, mtime} of backupFiles) {

View File

@ -1114,5 +1114,22 @@
"title": "自动只读大小",
"description": "自动只读笔记大小是超过该大小后,笔记将以只读模式显示(出于性能考虑)。",
"label": "自动只读大小(文本笔记)"
},
"i18n": {
"title": "本地化",
"language": "语言"
},
"backup": {
"automatic_backup": "自动备份",
"automatic_backup_description": "Trilium 可以自动备份数据库:",
"enable_daily_backup": "启用每日备份",
"enable_weekly_backup": "启用每周备份",
"enable_monthly_backup": "启用每月备份",
"backup_recommendation": "建议打开备份功能,但这可能会使大型数据库和/或慢速存储设备的应用程序启动变慢。",
"backup_now": "立即备份",
"backup_database_now": "立即备份数据库",
"existing_backups": "已有备份",
"database_backed_up_to": "数据库已备份到",
"no_backup_yet": "尚无备份"
}
}

View File

@ -1119,5 +1119,18 @@
"i18n": {
"title": "Localization",
"language": "Language"
},
"backup": {
"automatic_backup": "Automatic backup",
"automatic_backup_description": "Trilium can back up the database automatically:",
"enable_daily_backup": "Enable daily backup",
"enable_weekly_backup": "Enable weekly backup",
"enable_monthly_backup": "Enable monthly backup",
"backup_recommendation": "It's recommended to keep the backup turned on, but this can make application startup slow with large databases and/or slow storage devices.",
"backup_now": "Backup now",
"backup_database_now": "Backup database now",
"existing_backups": "Existing backups",
"database_backed_up_to": "Database has been backed up to",
"no_backup_yet": "no backup yet"
}
}