Comments

Anas_maw created an issue. See original summary.

johnv’s picture

You can translate by using the core Translation modules (like any configuration text). I noticed a string is only added to the list if it is first shown on some screen.

anas_maw’s picture

Hello @johnv
You can translate any added field, but you can't translate states.
I have all multilingual modules provided by core enabled. I think there is something missing in configuration declaration.
If i'm missing something please guide me.
Thanks.

johnv’s picture

THe Workflow Types can be translated here: /admin/config/regional/config-translation/workflow_type .
I'll be looking for the workflow_states.

This is the online help page for Config Translation: https://www.drupal.org/docs/8/multilingual/translating-configuration
It refers to a page with Maintenance Schema settings: https://www.drupal.org/docs/8/api/configuration-api/configuration-schema...

It seems the annotation for workflow_state is not complete.

johnv’s picture

Installing the config inpector module reveils that the 'label' is not exported.
Inspecting the Config Translation code reveils that the WorkflowState Entity needs an Edit form in the annotation and in workflow_ui.routing.yml file. I will try to add an existing subclass of EntityForm.

johnv’s picture

Status: Active » Needs work
StatusFileSize
new1.53 KB

Attached patch could do the trick. However, it generates an 'Access denied' error, even though all permissions are granted.

johnv’s picture

After enablng 'Content translation', you need to visit /admin/config/regional/content-language where you can enable content types for translation.

After enabling Configuration Translation, visit /admin/config/regional/config-translation to enable config entities (like Workflow, Workflow State, Workflow executed transition-fields).

According to this issue #2272363-10: Config translation - access denied , translatable fields must be of type 'label' or 'text', not 'string'.

johnv’s picture

Title: Workflow state translation » Make Workflow types and states translatable
johnv’s picture

The commit 'Make Workflow type labels translatable' is here: http://cgit.drupalcode.org/workflow/commit/?id=578412c
It is not shown due to an incomplete commit message.

  • johnv committed 35a5a89 on 8.x-1.x
    Issue #2923097: Make labels for Workflow State and Transition...
johnv’s picture

Issue tags: +menu, +Config novice, +php-novice
StatusFileSize
new1.9 KB

Attached patch should do the trick, but both links in the path are colliding.

Requesting for a volunteer that likes meddling with the menu system.

anas_maw’s picture

I can confirm the last patch make states translatable. but it break states page: /admin/config/workflow/workflow/MY_WORKFLOW/states
and the following comment should be removed from patch "// This collides workflow config and config_translation"

bgronek’s picture

Please see below...I left this comment in error.

bgronek’s picture

Priority: Normal » Major

I suggest that this be increased to Major as it causes these two very important core features to be incompatible with each other.

johnv’s picture

Any help is welcome. I don't know how to solve this.

ivan berezhnov’s picture

Issue tags: +CSKyiv18
johnv’s picture

Perhaps the error occurs because the following routes have the same path: '/admin/config/workflow/workflow/{workflow_type}'
- entity.workflow_type.canonical:
- entity.workflow_type.edit_form:

johnv’s picture

The following page gives an example for the canonical link: https://www.drupal.org/docs/8/api/entity-api/introduction-to-entity-api-...

geek-merlin’s picture

Title: Make Workflow types and states translatable » Add translation tab for Workflow types and states
Priority: Major » Normal
Issue tags: -menu, -Config novice, -php-novice

Adjusting title as seemingly basic translation was added in #10.

anas_maw’s picture

Status: Needs work » Needs review
StatusFileSize
new2.99 KB

This patch will fix this issue and will add the ability to translate states and transition labels

Status: Needs review » Needs work

The last submitted patch, 20: states-transitions-translation-2923097-20.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

anas_maw’s picture

Status: Needs work » Needs review
anas_maw’s picture

Fix the last patch as it causes the transition label to be empty

Status: Needs review » Needs work

The last submitted patch, 23: states-transitions-translation-2923097-23.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

johnv’s picture

Thanks for your patch @Anas_maw.

I have changed the route path: '/admin/config/workflow/workflow/state/{workflow_state}', adding an extra '/workflow'

The UX is not nice, yet. After translation, you cannot easily go back to the original States List.
I tried path: '/admin/config/workflow/workflow/{workflow_type}/state/{workflow_state}', but the following error appears.

Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("workflow_type") to generate a URL for route "entity.workflow_state.config_translation_overview". in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 182 of core\lib\Drupal\Core\Routing\UrlGenerator.php).

We need some extra work here. The same goes for workflow_config_transition.
However, I cannot find the translate link for transition (labels). I would expect /admin/config/workflow/workflow/MY_WF/transition_labels

anas_maw’s picture

Reroll to work on latest dev version

adaragao’s picture

On Drupal 10.3.2, still have the same problem described on #25.

Unfortunately I'm not a programmer, so I would really appreciate if someone can look and fix this.

Thank you.

suhaib_mayyas’s picture

Title: Add translation tab for Workflow types and states » Make Workflow state and transition labels translatable through Configuration Translation
Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs work » Needs review
StatusFileSize
new5.71 KB

I created this patch to make Workflow state labels and Workflow configuration transition labels translatable through Drupal core’s Configuration Translation system.

The main goal is to allow Workflow labels to be translated from the admin UI and exported/imported through Drupal configuration sync.

This patch covers two Workflow config entities:

  • workflow_state
  • workflow_config_transition

What this patch does

1. Makes Workflow states translatable

In WorkflowState.php, I changed the config entity definition from:

translatable = FALSE

to:

translatable = TRUE

I also added an edit form handler and an edit-form link template.

This is needed because Drupal’s Configuration Translation system depends on translatable config entities having the correct route/link structure in order to expose translation forms.

2. Makes Workflow transition labels translatable

In WorkflowConfigTransition.php, I also changed the config entity definition to:

translatable = TRUE

I added an edit form handler and an edit-form link template for transition config entities as well.

This allows transition labels to be handled by Configuration Translation in the same way as Workflow state labels.

3. Adds edit routes for Configuration Translation

I added edit-form routes for both entities:

entity.workflow_state.edit_form
entity.workflow_config_transition.edit_form

These routes are mainly required so Drupal can build the Configuration Translation routes correctly.

They are not intended to replace the existing Workflow admin UI.

4. Adds a Translate action for transition labels

In WorkflowConfigTransitionLabelForm.php, I added a Translate column/action when the current user has the translate configuration permission.

This makes it possible to access the translation page directly from the transition labels form.

5. Fixes editable config names for transition labels

I also fixed the editable config names in WorkflowConfigTransitionLabelForm.php.

The form was using:

$this->workflow->getStates();

But for transition labels, it should use:

$this->workflow->getTransitions();

This ensures the correct transition config entities are tracked by the form.

How to implement the patch

To apply the patch, place the patch file in the project under:

patches/workflow-config-entity-translation.patch

Then open composer.json and add the patch under extra.patches.drupal/workflow:

{
  "extra": {
    "patches": {
      "drupal/workflow": {
        "Make Workflow state and transition labels config-translatable": "patches/workflow-config-entity-translation.patch"
      }
    }
  }
}

After that, run Composer so the patch is applied:

ddev composer install

If the dependencies are already installed and only the patches need to be reapplied, run:

ddev composer patches-repatch

Then rebuild Drupal caches:

ddev drush cr

You can also confirm that Composer recorded the patch:

cat patches.lock.json

Required modules and permissions

This patch depends on Drupal core’s existing configuration translation system.

The following modules should be enabled:

language
locale
config_translation

The user also needs this permission:

translate configuration

After applying the patch, caches/routes should be rebuilt:

drush cr

Configuration sync behavior

This patch works with Drupal’s normal configuration sync process.

Base Workflow config is exported under:

config/sync/workflow.state.*
config/sync/workflow.transition.*

Translated labels are exported under the language override directory:

config/sync/language/{langcode}/workflow.state.*
config/sync/language/{langcode}/workflow.transition.*

So the normal commands work as expected:

drush cex
drush cim

drush cex exports the translated labels, and drush cim imports them back into the correct language config collection.

Notes

This patch solves the issue of making Workflow state labels and Workflow transition labels translatable through Drupal’s Configuration Translation system.

A few notes:

  • Tested locally with Drupal 10.6.8 and Workflow 2.2.2
  • The edit routes are mainly added to support Configuration Translation route generation.
  • The existing Workflow UI remains the main place for managing Workflow states and transition labels.
  • The patch does not change workflow behavior or permissions.
  • Since this changes contrib module code, it should be rechecked when the Workflow module is updated.
suhaib_mayyas’s picture

suhaib_mayyas’s picture

Version: 2.0.x-dev » 2.1.x-dev
StatusFileSize
new5.71 KB

I created this patch to make Workflow state labels and Workflow configuration transition labels translatable through Drupal core’s Configuration Translation system.

The main goal is to allow Workflow labels to be translated from the admin UI and exported/imported through Drupal configuration sync.

This patch covers two Workflow config entities:

  • workflow_state
  • workflow_config_transition

What this patch does

1. Makes Workflow states translatable

In WorkflowState.php, I changed the config entity definition from:

translatable = FALSE

to:

translatable = TRUE

I also added an edit form handler and an edit-form link template.

This is needed because Drupal’s Configuration Translation system depends on translatable config entities having the correct route/link structure in order to expose translation forms.

2. Makes Workflow transition labels translatable

In WorkflowConfigTransition.php, I also changed the config entity definition to:

translatable = TRUE

I added an edit form handler and an edit-form link template for transition config entities as well.

This allows transition labels to be handled by Configuration Translation in the same way as Workflow state labels.

3. Adds edit routes for Configuration Translation

I added edit-form routes for both entities:

entity.workflow_state.edit_form
entity.workflow_config_transition.edit_form

These routes are mainly required so Drupal can build the Configuration Translation routes correctly.

They are not intended to replace the existing Workflow admin UI.

4. Adds a Translate action for transition labels

In WorkflowConfigTransitionLabelForm.php, I added a Translate column/action when the current user has the translate configuration permission.

This makes it possible to access the translation page directly from the transition labels form.

5. Fixes editable config names for transition labels

I also fixed the editable config names in WorkflowConfigTransitionLabelForm.php.

The form was using:

$this->workflow->getStates();

But for transition labels, it should use:

$this->workflow->getTransitions();

This ensures the correct transition config entities are tracked by the form.

How to implement the patch

To apply the patch, place the patch file in the project under:

patches/workflow-config-entity-translation.patch

Then open composer.json and add the patch under extra.patches.drupal/workflow:

{
  "extra": {
    "patches": {
      "drupal/workflow": {
        "Make Workflow state and transition labels config-translatable": "patches/workflow-config-entity-translation.patch"
      }
    }
  }
}

After that, run Composer so the patch is applied:

ddev composer install

If the dependencies are already installed and only the patches need to be reapplied, run:

ddev composer patches-repatch

Then rebuild Drupal caches:

ddev drush cr

You can also confirm that Composer recorded the patch:

cat patches.lock.json

Required modules and permissions

This patch depends on Drupal core’s existing configuration translation system.

The following modules should be enabled:

language
locale
config_translation

The user also needs this permission:

translate configuration

After applying the patch, caches/routes should be rebuilt:

drush cr

Configuration sync behavior

This patch works with Drupal’s normal configuration sync process.

Base Workflow config is exported under:

config/sync/workflow.state.*
config/sync/workflow.transition.*

Translated labels are exported under the language override directory:

config/sync/language/{langcode}/workflow.state.*
config/sync/language/{langcode}/workflow.transition.*

So the normal commands work as expected:

drush cex
drush cim

drush cex exports the translated labels, and drush cim imports them back into the correct language config collection.

Notes

This patch solves the issue of making Workflow state labels and Workflow transition labels translatable through Drupal’s Configuration Translation system.

A few notes:

  • Tested locally with Drupal 10.6.8 and Workflow 2.2.2
  • The edit routes are mainly added to support Configuration Translation route generation.
  • The existing Workflow UI remains the main place for managing Workflow states and transition labels.
  • The patch does not change workflow behavior or permissions.
  • Since this changes contrib module code, it should be rechecked when the Workflow module is updated.
johnv’s picture

Status: Needs review » Fixed
Issue tags: -CSKyiv18

Thanks a lot. I made some small change to the patch. This was already open for a long time.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.