changes_3
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// Note: User-facing toast and modal copy is centralized here.
|
||||
const APP_MESSAGES = {
|
||||
export const messagesSource = `
|
||||
|
||||
const APP_MESSAGES = {
|
||||
actions: {
|
||||
raw_torrent: 'Add torrent',
|
||||
add: 'Add torrent',
|
||||
@@ -18,21 +19,21 @@ const APP_MESSAGES = {
|
||||
},
|
||||
|
||||
toast: {
|
||||
operationStarted: ({ action }) => `${actionLabel(action)} started`,
|
||||
operationStarted: ({ action }) => \`\${actionLabel(action)} started\`,
|
||||
|
||||
operationDone: ({ action }) => `${actionLabel(action)} done`,
|
||||
operationDone: ({ action }) => \`\${actionLabel(action)} done\`,
|
||||
|
||||
operationFailed: ({ action, error }) =>
|
||||
`${actionLabel(action)} failed: ${error || 'unknown error'}`,
|
||||
\`\${actionLabel(action)} failed: \${error || 'unknown error'}\`,
|
||||
|
||||
actionQueued: ({ action, parts }) =>
|
||||
Number(parts || 1) > 1
|
||||
? `${actionLabel(action)} queued in ${parts} parts`
|
||||
: `${actionLabel(action)} queued`,
|
||||
? \`\${actionLabel(action)} queued in \${parts} parts\`
|
||||
: \`\${actionLabel(action)} queued\`,
|
||||
|
||||
moveQueued: ({ parts, physical }) =>
|
||||
Number(parts || 1) > 1
|
||||
? `Move queued in ${parts} parts`
|
||||
? \`Move queued in \${parts} parts\`
|
||||
: physical
|
||||
? 'Physical move queued'
|
||||
: 'Move queued',
|
||||
@@ -40,7 +41,7 @@ const APP_MESSAGES = {
|
||||
addQueued: () => 'Torrent add queued',
|
||||
|
||||
addQueuedSkipped: ({ count }) =>
|
||||
`Torrent add queued, skipped ${count} duplicate torrent(s)`,
|
||||
\`Torrent add queued, skipped \${count} duplicate torrent(s)\`,
|
||||
|
||||
addTooLarge: () =>
|
||||
'One or more .torrent files exceed the current rTorrent XML-RPC upload limit. Open rTorrent config and set network.xmlrpc.size_limit to e.g. 16M.',
|
||||
@@ -48,12 +49,12 @@ const APP_MESSAGES = {
|
||||
dropOnlyTorrents: () => 'Drop .torrent files only',
|
||||
|
||||
droppedAddedSkipped: ({ queued, skipped }) =>
|
||||
`Added ${queued} torrent(s), skipped ${skipped} duplicate(s)`,
|
||||
\`Added \${queued} torrent(s), skipped \${skipped} duplicate(s)\`,
|
||||
|
||||
droppedAdded: ({ queued }) => `Added ${queued} torrent(s)`,
|
||||
droppedAdded: ({ queued }) => \`Added \${queued} torrent(s)\`,
|
||||
|
||||
droppedSkipped: ({ skipped }) =>
|
||||
`Skipped ${skipped} duplicate torrent(s)`,
|
||||
\`Skipped \${skipped} duplicate torrent(s)\`,
|
||||
|
||||
droppedNone: () => 'No torrents were added',
|
||||
|
||||
@@ -65,9 +66,9 @@ const APP_MESSAGES = {
|
||||
|
||||
downloadStarted: () => 'Download started',
|
||||
|
||||
chunkActionDone: ({ action }) => `${actionLabel(action)} done`,
|
||||
chunkActionDone: ({ action }) => \`\${actionLabel(action)} done\`,
|
||||
|
||||
trackerActionDone: ({ action }) => `${actionLabel(action)} done`,
|
||||
trackerActionDone: ({ action }) => \`\${actionLabel(action)} done\`,
|
||||
|
||||
pathPickerUnavailable: () => 'Path picker is unavailable',
|
||||
|
||||
@@ -78,60 +79,52 @@ const APP_MESSAGES = {
|
||||
recommendedColumnsApplied: () => 'Recommended columns applied',
|
||||
|
||||
jobLogsCleared: ({ deleted }) =>
|
||||
`Cleared ${deleted || 0} finished job log(s)`,
|
||||
\`Cleared \${deleted || 0} finished job log(s)\`,
|
||||
|
||||
emergencyJobLogsCleared: ({ deleted }) =>
|
||||
`Emergency cleanup removed ${deleted || 0} job log(s)`,
|
||||
\`Emergency cleanup removed \${deleted || 0} job log(s)\`,
|
||||
|
||||
rtorrentConfigSaved: ({ updated }) =>
|
||||
`rTorrent config saved (${updated || 0})`,
|
||||
\`rTorrent config saved (\${updated || 0})\`,
|
||||
|
||||
rtorrentConfigReset: ({ removed }) =>
|
||||
`rTorrent config reset (${removed || 0} override(s) removed)`,
|
||||
\`rTorrent config reset (\${removed || 0} override(s) removed)\`,
|
||||
|
||||
automationLogsDeleted: ({ deleted }) =>
|
||||
`Automation logs deleted: ${deleted || 0}`,
|
||||
\`Automation logs deleted: \${deleted || 0}\`,
|
||||
|
||||
cleanupDone: ({ deleted }) => `Cleanup done (${deleted})`,
|
||||
cleanupDone: ({ deleted }) => \`Cleanup done (\${deleted})\`,
|
||||
|
||||
plannerApplied: ({ dryRun, paused, resumed, limitsChanged }) =>
|
||||
`${dryRun ? 'Planner dry-run' : 'Planner applied'}: paused ${
|
||||
paused || 0
|
||||
}, resumed ${resumed || 0}, limits ${
|
||||
limitsChanged ? 'changed' : 'unchanged'
|
||||
}`,
|
||||
\`\${dryRun ? 'Planner dry-run' : 'Planner applied'}: paused \${paused || 0}, resumed \${resumed || 0}, limits \${limitsChanged ? 'changed' : 'unchanged'}\`,
|
||||
|
||||
rssQueued: ({ queued }) => `RSS queued ${queued || 0} item(s)`,
|
||||
rssQueued: ({ queued }) => \`RSS queued \${queued || 0} item(s)\`,
|
||||
|
||||
smartQueueCheckQueued: () =>
|
||||
'Smart Queue check queued. It will continue in the background.',
|
||||
|
||||
automationForceRunDone: ({ count }) =>
|
||||
`Automation force run done (${count || 0} torrent item(s))`,
|
||||
\`Automation force run done (\${count || 0} torrent item(s))\`,
|
||||
|
||||
automationsApplied: ({ count, batches }) =>
|
||||
batches
|
||||
? `Automations applied ${count || 0} torrent(s) in ${
|
||||
batches || 0
|
||||
} batch(es)`
|
||||
: `Automations applied ${count || 0} item(s)`,
|
||||
? \`Automations applied \${count || 0} torrent(s) in \${batches || 0} batch(es)\`
|
||||
: \`Automations applied \${count || 0} item(s)\`,
|
||||
|
||||
torrentStatsError: ({ error }) => `Torrent stats: ${error}`,
|
||||
torrentStatsError: ({ error }) => \`Torrent stats: \${error}\`,
|
||||
|
||||
startupConfigApplied: ({ count }) =>
|
||||
`Startup rTorrent config applied (${count || 0})`,
|
||||
\`Startup rTorrent config applied (\${count || 0})\`,
|
||||
|
||||
startupConfigFailed: ({ error }) =>
|
||||
`Startup rTorrent config: ${error}`,
|
||||
\`Startup rTorrent config: \${error}\`,
|
||||
|
||||
plannerSocketResult: ({ paused, resumed, dryRun }) =>
|
||||
`Planner: paused ${paused || 0}, resumed ${resumed || 0}${
|
||||
dryRun ? ' dry-run' : ''
|
||||
}`
|
||||
\`Planner: paused \${paused || 0}, resumed \${resumed || 0}\${dryRun ? ' dry-run' : ''}\`
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function actionLabel(action) {
|
||||
function actionLabel(action) {
|
||||
const key = String(action || '').trim();
|
||||
|
||||
if (APP_MESSAGES.actions[key]) {
|
||||
@@ -139,18 +132,19 @@ function actionLabel(action) {
|
||||
}
|
||||
|
||||
return key
|
||||
? key.replace(/[_-]+/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase())
|
||||
? key.replace(/[_-]+/g, ' ').replace(/\\b\\w/g, (c) => c.toUpperCase())
|
||||
: 'Operation';
|
||||
}
|
||||
}
|
||||
|
||||
function appMessage(key, params = {}) {
|
||||
function appMessage(key, params = {}) {
|
||||
const fn = key
|
||||
.split('.')
|
||||
.reduce((acc, part) => acc && acc[part], APP_MESSAGES);
|
||||
|
||||
return typeof fn === 'function' ? fn(params) : String(fn || key);
|
||||
}
|
||||
}
|
||||
|
||||
function toastMessage(key, type = 'secondary', params = {}) {
|
||||
function toastMessage(key, type = 'secondary', params = {}) {
|
||||
toast(appMessage(key, params), type);
|
||||
}
|
||||
}
|
||||
`;
|
||||
Reference in New Issue
Block a user