From 635649d3bd14dea99541f1e8d7f3835c8cd735af Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 24 Oct 2025 23:59:13 -0700 Subject: [PATCH] add translations --- models/project/workflows.go | 24 ++-- options/locale/locale_en-US.ini | 33 +++++ templates/projects/workflows.tmpl | 34 +++++ .../components/projects/ProjectWorkflow.vue | 132 +++++++++++------- .../js/components/projects/WorkflowStore.ts | 18 +-- web_src/js/features/projects/workflow.ts | 54 ++++++- 6 files changed, 225 insertions(+), 70 deletions(-) diff --git a/models/project/workflows.go b/models/project/workflows.go index 4c726e5b6c..24a1eae5c6 100644 --- a/models/project/workflows.go +++ b/models/project/workflows.go @@ -16,19 +16,21 @@ import ( type WorkflowEvent string const ( - WorkflowEventItemOpened WorkflowEvent = "item_opened" - WorkflowEventItemAddedToProject WorkflowEvent = "item_added_to_project" - WorkflowEventItemReopened WorkflowEvent = "item_reopened" - WorkflowEventItemClosed WorkflowEvent = "item_closed" - WorkflowEventItemColumnChanged WorkflowEvent = "item_column_changed" - WorkflowEventCodeChangesRequested WorkflowEvent = "code_changes_requested" - WorkflowEventCodeReviewApproved WorkflowEvent = "code_review_approved" - WorkflowEventPullRequestMerged WorkflowEvent = "pull_request_merged" + WorkflowEventItemOpened WorkflowEvent = "item_opened" + WorkflowEventItemAddedToProject WorkflowEvent = "item_added_to_project" + WorkflowEventItemRemovedFromProject WorkflowEvent = "item_removed_from_project" + WorkflowEventItemReopened WorkflowEvent = "item_reopened" + WorkflowEventItemClosed WorkflowEvent = "item_closed" + WorkflowEventItemColumnChanged WorkflowEvent = "item_column_changed" + WorkflowEventCodeChangesRequested WorkflowEvent = "code_changes_requested" + WorkflowEventCodeReviewApproved WorkflowEvent = "code_review_approved" + WorkflowEventPullRequestMerged WorkflowEvent = "pull_request_merged" ) var workflowEvents = []WorkflowEvent{ WorkflowEventItemOpened, WorkflowEventItemAddedToProject, + WorkflowEventItemRemovedFromProject, WorkflowEventItemReopened, WorkflowEventItemClosed, WorkflowEventItemColumnChanged, @@ -56,6 +58,8 @@ func (we WorkflowEvent) LangKey() string { return "projects.workflows.event.item_opened" case WorkflowEventItemAddedToProject: return "projects.workflows.event.item_added_to_project" + case WorkflowEventItemRemovedFromProject: + return "projects.workflows.event.item_removed_from_project" case WorkflowEventItemReopened: return "projects.workflows.event.item_reopened" case WorkflowEventItemClosed: @@ -122,6 +126,10 @@ func GetWorkflowEventCapabilities() map[WorkflowEvent]WorkflowEventCapabilities AvailableFilters: []WorkflowFilterType{WorkflowFilterTypeIssueType, WorkflowFilterTypeLabels}, AvailableActions: []WorkflowActionType{WorkflowActionTypeColumn, WorkflowActionTypeAddLabels, WorkflowActionTypeRemoveLabels, WorkflowActionTypeIssueState}, }, + WorkflowEventItemRemovedFromProject: { + AvailableFilters: []WorkflowFilterType{WorkflowFilterTypeIssueType, WorkflowFilterTypeLabels}, + AvailableActions: []WorkflowActionType{WorkflowActionTypeAddLabels, WorkflowActionTypeRemoveLabels, WorkflowActionTypeIssueState}, + }, WorkflowEventItemReopened: { AvailableFilters: []WorkflowFilterType{WorkflowFilterTypeIssueType, WorkflowFilterTypeLabels}, AvailableActions: []WorkflowActionType{WorkflowActionTypeColumn, WorkflowActionTypeAddLabels, WorkflowActionTypeRemoveLabels}, diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index dbc615dc7c..ced3c9a697 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -3924,12 +3924,45 @@ workflows = Workflows exit_fullscreen = Exit Fullscreen workflows.event.item_opened = Item opened workflows.event.item_added_to_project = Item added to project +workflows.event.item_removed_from_project = Item removed from project workflows.event.item_reopened = Item reopened workflows.event.item_closed = Item closed workflows.event.item_column_changed = Item column changed workflows.event.code_changes_requested = Code changes requested workflows.event.code_review_approved = Code review approved workflows.event.pull_request_merged = Pull request merged +workflows.view_workflow_configuration = View workflow configuration +workflows.configure_workflow = Configure automated actions for this workflow +workflows.when = When +workflows.run_when = This workflow will run when: +workflows.filters = Filters +workflows.apply_to = Apply to +workflows.when_moved_from_column = When moved from column +workflows.when_moved_to_column = When moved to column +workflows.only_if_has_labels = Only if has labels +workflows.default_workflows = Default Workflows +workflows.actions = Actions +workflows.move_to_column = Move to column +workflows.add_labels = Add labels +workflows.remove_labels = Remove labels +workflows.any_label = Any label +workflows.any_column = Any column +workflows.issue_state = Issue state +workflows.none = None +workflows.no_change = No change +workflows.edit = Edit +workflows.delete = Delete +workflows.save = Save +workflows.clone = Clone +workflows.cancel = Cancel +workflows.disable = Disable +workflows.disabled = Disabled +workflows.enable = Enable +workflows.enabled = Enabled +workflows.issuesAndPullRequests = Issues and Pull Requests +workflows.issues_only = Issues only +workflows.pull_requests_only = Pull Requests only +workflows.select_column = Select column ... [git.filemode] changed_filemode = %[1]s → %[2]s diff --git a/templates/projects/workflows.tmpl b/templates/projects/workflows.tmpl index e9222a667e..f7d18bf180 100644 --- a/templates/projects/workflows.tmpl +++ b/templates/projects/workflows.tmpl @@ -2,6 +2,40 @@
diff --git a/web_src/js/components/projects/ProjectWorkflow.vue b/web_src/js/components/projects/ProjectWorkflow.vue index a95914ce55..0b61a85063 100644 --- a/web_src/js/components/projects/ProjectWorkflow.vue +++ b/web_src/js/components/projects/ProjectWorkflow.vue @@ -4,15 +4,52 @@ import {createWorkflowStore} from './WorkflowStore.ts'; import {svg} from '../../svg.ts'; import {confirmModal} from '../../features/comp/ConfirmModal.ts'; import {fomanticQuery} from '../../modules/fomantic/base.ts'; +import { locale } from 'dayjs'; const elRoot = useTemplateRef('elRoot'); -const props = defineProps({ - projectLink: {type: String, required: true}, - eventID: {type: String, required: true}, -}); +const props = defineProps<{ + projectLink: string; + eventID: string; + locale: { + defaultWorkflows: string; + moveToColumn: string; + viewWorkflowConfiguration: string; + configureWorkflow: string; + when: string; + runWhen: string; + filters: string; + applyTo: string; + whenMovedFromColumn: string; + whenMovedToColumn: string; + onlyIfHasLabels: string; + actions: string; + addLabels: string; + removeLabels: string; + anyLabel: string; + anyColumn: string; + issueState: string; + none: string; + noChange: string; + edit: string; + delete: string; + save: string; + clone: string; + cancel: string; + disable: string; + disabled: string; + enabled: string; + enable: string; + issuesAndPullRequests: string; + issuesOnly: string; + pullRequestsOnly: string; + selectColumn: string; + closeIssue: string; + reopenIssue: string; + }, +}>(); -const store = createWorkflowStore(props); +const store = createWorkflowStore(props.projectLink, props.eventID); // Track edit state directly on workflow objects const previousSelection = ref(null); @@ -648,7 +685,7 @@ onUnmounted(() => {
@@ -709,12 +744,12 @@ onUnmounted(() => { class="workflow-status" :class="store.selectedWorkflow.enabled ? 'status-enabled' : 'status-disabled'" > - {{ store.selectedWorkflow.enabled ? 'Enabled' : 'Disabled' }} + {{ store.selectedWorkflow.enabled ? locale.enabled : locale.disabled }} -

Configure automated actions for this workflow

-

Configure automated actions for this workflow

-

View workflow configuration

+

{{ locale.configureWorkflow }}

+

{{ locale.configureWorkflow }}

+

{{ locale.viewWorkflowConfiguration }}

@@ -726,7 +761,7 @@ onUnmounted(() => { @click="toggleEditMode" > - Cancel + {{ locale.cancel }} @@ -736,7 +771,7 @@ onUnmounted(() => { :disabled="store.saving" > - Save + {{ locale.save }} @@ -746,7 +781,7 @@ onUnmounted(() => { @click="deleteWorkflow" > - Delete + {{ locale.delete }} @@ -758,7 +793,7 @@ onUnmounted(() => { @click="toggleEditMode" > - Edit + {{ locale.edit }} @@ -766,10 +801,9 @@ onUnmounted(() => { class="btn" :class="store.selectedWorkflow.enabled ? 'btn-outline-danger' : 'btn-success'" @click="toggleWorkflowStatus" - :title="store.selectedWorkflow.enabled ? 'Disable workflow' : 'Enable workflow'" > - {{ store.selectedWorkflow.enabled ? 'Disable' : 'Enable' }} + {{ store.selectedWorkflow.enabled ? locale.disable : locale.enable }} @@ -779,7 +813,7 @@ onUnmounted(() => { title="Clone this workflow" > - Clone + {{ locale.clone }}
@@ -788,77 +822,77 @@ onUnmounted(() => {
- +
- This workflow will run when: {{ store.selectedWorkflow.display_name }} + {{ locale.runWhen }}{{ store.selectedWorkflow.display_name }}
- +
- +
- {{ store.workflowFilters.issue_type === 'issue' ? 'Issues' : - store.workflowFilters.issue_type === 'pull_request' ? 'Pull requests' : - 'Issues And Pull Requests' }} + {{ store.workflowFilters.issue_type === 'issue' ? locale.issuesOnly : + store.workflowFilters.issue_type === 'pull_request' ? locale.pullRequestsOnly : + locale.issuesAndPullRequests }}
- +
- {{ store.projectColumns.find(c => String(c.id) === store.workflowFilters.source_column)?.title || 'Any column' }} + {{ store.projectColumns.find(c => String(c.id) === store.workflowFilters.source_column)?.title || locale.anyColumn }}
- +
- {{ store.projectColumns.find(c => String(c.id) === store.workflowFilters.target_column)?.title || 'Any column' }} + {{ store.projectColumns.find(c => String(c.id) === store.workflowFilters.target_column)?.title || locale.anyColumn }}
- +