Problem/Motivation

Split off from #2998539, which bundled S3 support and translation into a single ticket. This issue covers only translation so both concerns can be reviewed and released independently.

On path_file 2.1.1, path_file_entity is not translatable. Multilingual sites cannot maintain per-language values for name, path, or fid, and there is no /translations UI on the entity.

Steps to reproduce

N/A — feature request.

Proposed resolution

Mark the entity type as translatable (add translatable = TRUE, a data_table, and the content_translation handler in the annotation), and flag translatable base fields (name, path, fid) with setTranslatable(TRUE). Provide a hook_update_N to migrate existing schemas.

Remaining tasks

  • Open a merge request against 2.1.x.
  • Add kernel/functional test coverage for translated entities.
  • Verify on a multilingual site with the content_translation module enabled.
  • Update README with a note about translation support.

User interface changes

Adds a "Translate" tab and per-language add/edit forms on each path_file_entity when content_translation is enabled.

API changes

None for existing consumers.

Data model changes

Adds a path_file_entity_field_data data table with a langcode column. Existing installs migrate via a hook_update_N.

CommentFileSizeAuthor
#4 Screenshot From 2026-08-28 12-42-01.png97.43 KBarjenk

Issue fork path_file-3616156

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

batigolix created an issue. See original summary.

batigolix’s picture

Status: Active » Needs review

Here is a first attempt for translating path files.

arjenk’s picture

Status: Needs review » Needs work
StatusFileSize
new97.43 KB

The concept is good, i could translate the file paths (after some work). Issues i found:

1. The update hook gives an error on existing content:

 [error]  Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'default_langcode' cannot be null: INSERT INTO "tmp_375d8dpath_file_entity" ("id", "uuid", "langcode", "name", "fid__target_id", "fid__display", "fid__description", "user_id", "status", "created", "changed", "default_langcode") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11); Array

and if there is no content, it does not correctly convert the entity, and new file paths are not translatable.

I got it to work with this patch:

 function path_file_update_10006(&$sandbox) {
   $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
-  $entity_type = $entity_definition_update_manager->getEntityType('path_file_entity');
-  $field_storage_definitions = \Drupal::service('entity_field.manager')
+  $entity_type_manager = \Drupal::entityTypeManager();
+  $entity_type_manager->useCaches(FALSE);
+  $entity_field_manager = \Drupal::service('entity_field.manager');
+  $entity_field_manager->useCaches(FALSE);
+  $entity_type = $entity_type_manager->getDefinition('path_file_entity');
+  $field_storage_definitions = $entity_field_manager
     ->getFieldStorageDefinitions('path_file_entity');
   $entity_definition_update_manager->updateFieldableEntityType(
     $entity_type,
     $field_storage_definitions,
     $sandbox
   );

2. In getViewsData(), this is not correct anymore

   $data['path_file_entity']['table']['base'] = [
     'field' => 'id',
     'title' => $this->t('Path file entity'),
     'help' => $this->t('The Path file entity ID.'),
   ];

This will result in 2 entries:
views UI

3. PathFileTranslationTest doesn't request the /nl/ version (minor)

The test does do a GET('path-file/' . $entity_id) but not the translation, i suggest adding:
$this->drupalGet('nl/path-file/' . $entity_id);