Update:Added string localization for tasks #3303 #3352

This commit is contained in:
advplyr
2024-09-21 14:02:57 -05:00
parent 8512d5e693
commit 1dec8ae122
13 changed files with 213 additions and 83 deletions

View File

@ -57,8 +57,14 @@ class Task {
action: this.action,
data: this.data ? { ...this.data } : {},
title: this.title,
titleKey: this.titleKey,
titleSubs: this.titleSubs,
description: this.description,
descriptionKey: this.descriptionKey,
descriptionSubs: this.descriptionSubs,
error: this.error,
errorKey: this.errorKey,
errorSubs: this.errorSubs,
showSuccess: this.showSuccess,
isFailed: this.isFailed,
isFinished: this.isFinished,
@ -104,30 +110,19 @@ class Task {
this.setFinished()
}
/**
* Set task as failed without translation key
* TODO: Remove this method after all tasks are using translation keys
*
* @param {string} message
*/
setFailedText(message) {
this.error = message
this.errorKey = null
this.errorSubs = null
this.isFailed = true
this.failedAt = Date.now()
this.setFinished()
}
/**
* Set task as finished
* TODO: Update to use translation keys
*
* @param {string} [newDescription] update description
* @param {TaskString} [newDescriptionString] update description
* @param {boolean} [clearDescription] clear description
*/
setFinished(newDescription = null) {
if (newDescription) {
this.description = newDescription
setFinished(newDescriptionString = null, clearDescription = false) {
if (newDescriptionString) {
this.description = newDescriptionString.text
this.descriptionKey = newDescriptionString.key || null
this.descriptionSubs = newDescriptionString.subs || null
} else if (clearDescription) {
this.description = null
this.descriptionKey = null
this.descriptionSubs = null
}