Updated: Comment #0

Problem/Motivation

Field configuration does not yet have a UI for translation.

Proposed resolution

We would build the form, and add a Translate link from the field lists.

Remaining tasks

  • Strategize

User interface changes

yes. add a ui for translating field config.

API changes

No.

(A list of related issues.)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

YesCT’s picture

FileSize
206.72 KB

this is a current field list.
we want to add a translate operation to the drop down operations.

fields.png

Gábor Hojtsy’s picture

So I think the trick part is there is no global list of fields. There is one in Admin > Reports > Field list. But that does not have operations. So we should put in the translate operation into the lists for each entity. If those use entity list controllers (which they likely(?) don't) and if field configs are proper config entities then the translate operation would show up. We should still wire in the paths with the entity or config group mapper as appropriate.

vijaycs85’s picture

Status: Active » Needs review
FileSize
743 bytes

Adding this few lines brings the overview page with list of issues

1. There is no tab/link in drop-down
2. Add link can't make {bundle} to correct value.
3. Still no add/edit/delete pages.

Status: Needs review » Needs work

The last submitted patch, 2028137-config-translation-field.instance-3.patch, failed testing.

vijaycs85’s picture

Status: Needs work » Needs review
FileSize
586 bytes
696 bytes

Removing debug code.

Status: Needs review » Needs work

The last submitted patch, 2028137-config-translation-field.instance-5.patch, failed testing.

vijaycs85’s picture

Status: Needs work » Needs review
FileSize
1.7 KB
1.53 KB

Updating {bundle} in URL.

vijaycs85’s picture

Small code fix...

YesCT’s picture

This is just my first read. Mostly asking questions so I can try and understand. :)

  1. +++ b/config_translation.moduleundefined
    @@ -251,6 +251,31 @@ function config_translation_config_translation_group_info() {
    +  // Fields.
    

    If there are other sections like this,
    we should make the inline comments be sentences...

    We could do that in the whole file in a clean up issue.

    I (or someone) should check this patch in the context of the whole file. I'll do that, but just saving this for now.

  2. +++ b/config_translation.moduleundefined
    @@ -251,6 +251,31 @@ function config_translation_config_translation_group_info() {
    +    // Make sure entity type is fieldable.
    +    if ($entity_info['fieldable'] && isset($entity_info['route_base_path'])) {
    

    the if, makes sure it's fieldable..
    and also
    that it has a route base path?

    What is the second part of the condition mean in words?

  3. +++ b/config_translation.moduleundefined
    @@ -251,6 +251,31 @@ function config_translation_config_translation_group_info() {
    +        // Remove bundle prefix, if present.
    +        if (isset($entity_info['bundle_prefix']) && strpos($bundle, $entity_info['bundle_prefix']) === 0) {
    +          $bundle = str_replace($entity_info['bundle_prefix'], '', $bundle);
    +        }
    +        // Replace {bundle} placeholder on path.
    +        $path = str_replace('{bundle}', $bundle, $entity_info['route_base_path']) . '/fields/{field_instance}';
    

    what is an example of bundle that has a bundle prefix that needs to be removed.

    is it like:
    comment_node_article
    has comment_node removed,
    so we only use
    article as the bundle?

    ag bundle_prefix core
    yields:
    core/lib/Drupal/Core/Entity/Annotation/EntityType.php
    222: public $bundle_prefix;

    which says:

      /**
       * The prefix for the bundles of this entity type.
       *
       * For example, the comment bundle is prefixed with 'comment_node_'.
       *
       * @var string (optional)
       */
      public $bundle_prefix;
    
  4. +++ b/config_translation.moduleundefined
    @@ -251,6 +251,31 @@ function config_translation_config_translation_group_info() {
    +        // To avoid duplicates, save in an array and update $items.
    +        $field_items[$path] = $path;
    

    save what?
    save the path pattern?
    and looks like it updates $field_items, not $items.

    How does saving it avoid duplicates?

  5. +++ b/config_translation.moduleundefined
    @@ -251,6 +251,31 @@ function config_translation_config_translation_group_info() {
    +  // Add to group info.
    

    add what to group info?

vijaycs85’s picture

Thanks for the review @YesCT. here is some updates in #9.

#1 - ok
#2 - updated comment
#3 - Exact same lines are in entityManager::getAdminPath(). Trust me, I didn't copy :D

+++ b/config_translation.moduleundefined
@@ -251,6 +251,31 @@ function config_translation_config_translation_group_info() {
+        // Remove bundle prefix, if present.
+        if (isset($entity_info['bundle_prefix']) && strpos($bundle, $entity_info['bundle_prefix']) === 0) {
+          $bundle = str_replace($entity_info['bundle_prefix'], '', $bundle);
+        }
+        // Replace {bundle} placeholder on path.

#4 & #5 no more exist because of #3 change.

YesCT’s picture

Status: Needs review » Needs work
+++ b/config_translation.moduleundefined
@@ -253,28 +253,17 @@ function config_translation_config_translation_group_info() {
   // Fields.

I checked the other sections are the same. So just leave this.

+++ b/config_translation.moduleundefined
@@ -253,28 +253,17 @@ function config_translation_config_translation_group_info() {
-  foreach ($entity_manager->getDefinitions() as $entity_type => $entity_info) {
-    // Make sure entity type is fieldable.
+    foreach ($entity_manager->getDefinitions() as $entity_type => $entity_info) {
+    // Make sure entity type is fieldable and has base path.

the foreach is gone, so now the code that is there should have indent corrected.

+++ b/config_translation.moduleundefined
@@ -253,28 +253,17 @@ function config_translation_config_translation_group_info() {
+          $items[] = new ConfigEntityMapper("$path/fields/{field_instance}" , 'field_instance', t('@label field'), MENU_CALLBACK);

$path . '/fields/{...'

Gabor says we do concat with single quotes usually

YesCT’s picture

  1. going to the field, both the edit and field settings tab do not have the subtabs to translate
  2. but if guess the url, like:
    http://localhost/drupal2/admin/structure/types/manage/article/fields/nod...

    do see the translate table. :)

  3. clicking on add gives:

    The requested page "/admin/structure/types/manage/article/fields/node.article.body/translate/add/af" could not be found.

oh, and we have yet to add the code to make the translate operation show on the field drop buttons. so that does not work yet either.

Maybe the usual subjects for not working is:
the wrong url (like changing to manage url pattern),
or if the source file has langcode und we will get access denied [this is not happening here, but I'm writing down so I remember in case].

plopesc’s picture

Working on this one...
Regards

plopesc’s picture

Status: Needs work » Needs review
FileSize
1.1 KB
1.05 KB

Hello.

Attaching patch including YesCT suggestions in #2028137-11: Integrate field configuration translation on the user interface.

However, I'm not able to show the link or fix the not found page problem.

Regards

Gábor Hojtsy’s picture

Title: add UI to translation field configuration » Integrate field configuration translation on the user interface
vijaycs85’s picture

Status: Needs review » Postponed
Gábor Hojtsy’s picture

Uhm, hum, not very good :/

vijaycs85’s picture

Seems #274270: Future of menu depth? has a history or would be a big change. not sure about the possibility of getting it in D8. May need to try for some alternative?

Gábor Hojtsy’s picture

I sincerely hoped the limit would go away with the switch out from the old routing system. If that switching out will not happen, then meh. Yeah, we need to find something else to solve this in that case.

vijaycs85’s picture

Status: Postponed » Needs review
FileSize
7.4 KB
8.48 KB

Ok, attached patch addresses 3 items:

1. path for translation pages
- overview page has no change - [base path]/translate
- Add translation page changed from [base path]/translate/add/[langcode] to [base path]/translate?action=add&langcode=[langcode]
- Edit translation page changed from [base path]/translate/edit/[langcode] to [base path]/translate?action=edit&langcode=[langcode]
- Delete translation page changed from [base path]/translate/delete/[langcode] to [base path]/translate?action=delete&langcode=[langcode]

At least it resolves field translation page issues (for now).

2. Typo in comments \Symfony\Component\HttpFoundatio\Request to \Symfony\Component\HttpFoundation\Request
3. ConfirmFormBase change wasn't there. change of protected => public for 3 methods.

Status: Needs review » Needs work

The last submitted patch, 2028137-config-translation-field.instance-20.patch, failed testing.

vijaycs85’s picture

Yep, Test cases need to be updated as per current URL change...

vijaycs85’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
12.05 KB
20.93 KB

- Updated all test cases to reflect the URL change
- Removing 'Needs test' as depth restriction is a known core issue.

Seems there are some issue with confirmFormBase (hope, not related to this change). So there is a possibility to get some fails, but not 60+ as we have in #20 :)

vijaycs85’s picture

Green1!!! @Gábor Hojtsy are we OK to go with this approach for now?. We can roll back, if MENU_MAX_DEPTH removed from core

Gábor Hojtsy’s picture

Yeah, this seems to be our only possibility. One thing I don't understand is why do the confirm form methods need to be public now all of a sudden. Other changes look good.

vijaycs85’s picture

@Gábor Hojtsy, This change went in as part of 73fbcf80 commit on 17th June.

vijaycs85’s picture

vijaycs85’s picture

Status: Needs review » Fixed

Committed 4018bd1 and pushed to 8.x-1.x. Thanks!

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