Problem/Motivation

We want to showcase Drupal's multilingual capabilities in Umami, but Umami currently only imports content in one language.
This issue is to change the structure of files and folders under demo_umami_content to better store multiple languages.

Proposed resolution

Add a subfolder demo_umami_content/default_content/languages/en
Move article_body, recipe_instructions, articles.csv, pages.csv, recipes.csv folders within this new folder
Move the term definitions to their own CSV files per vocabulary so they can be referenced by row number, making it possible to cross reference terms across languages.
Update content import code to use this new structure.

After implementation, the imported content should be identical to as it would be without this patch. But it we can then proceed in another issue to start adding the corresponding es folder and updating the content import to import translated content.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

Comments

Eli-T created an issue. See original summary.

rakesh.gectcr’s picture

Assigned: Unassigned » rakesh.gectcr
rakesh.gectcr’s picture

Status: Active » Needs review
StatusFileSize
new13.5 KB

As initial patch, moved all the english content from
/default_content/article_body/ to /default_content/languages/en/article_body
/default_content/recipe_instructions/ to /default_content/languages/en/recipe_instructions

After moving that, installed it in my local, looks ok,

Status: Needs review » Needs work

The last submitted patch, 3: 3028627-3.patch, failed testing. View results

rakesh.gectcr’s picture

Status: Needs work » Needs review
StatusFileSize
new16.22 KB

Just fixed the test and enabled the Spanish language

rakesh.gectcr’s picture

StatusFileSize
new1.89 KB

Sorry forgot to add the interdiff. :)

rakesh.gectcr’s picture

StatusFileSize
new14.53 KB
new1.02 KB

Removed the language configuration, applying the only the test fix,

The last submitted patch, 5: 3028627-4.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 7: 3028627-7.patch, failed testing. View results

penyaskito’s picture

eli-t’s picture

StatusFileSize
new14.55 KB

This is just a reroll of #7 to make it apply now chocolate-brownie-umami.html is renamed to vegan-chocolate-nut-brownies.html.

eli-t’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 12: 3028627-12.patch, failed testing. View results

eli-t’s picture

Status: Needs work » Needs review
StatusFileSize
new14.55 KB

Fixed tests. Hopefully.

eli-t’s picture

StatusFileSize
new29.61 KB

More work in progress - this splits the taxonomy terms out in to their own file so that they can be translated and crossed referenced between languages by their row number in the CSV.

The tag references in the articles/recipes CSVs are now integer references to the row numbers in the tags.csv, so the next step is to change the import code for the articles and recipes so it doesn't create the tags on the fly when creating nodes, but instead looks them up from those already created.

eli-t’s picture

StatusFileSize
new36.64 KB

This patch builds on the previous patches and removes all the just in time generation of terms from the recipe_category and tag vocabulary during node import. Now they are all generated in advance, and mapped from the recipes/articles files to the taxonomy files by row number. This makes it easier to cross reference taxonomy terms across languages.

Status: Needs review » Needs work

The last submitted patch, 17: 3028627_17.patch, failed testing. View results

eli-t’s picture

Status: Needs work » Needs review

Triggering retest

Status: Needs review » Needs work

The last submitted patch, 17: 3028627_17.patch, failed testing. View results

eli-t’s picture

Title: Enable Umami's content installation to import multiple languages » Restructure Umami's default content files so more than one language can be included
Issue summary: View changes
eli-t’s picture

Status: Needs work » Needs review
shaal’s picture

I tested it and saw that all content is imported as it should from the new location /languages/en/.

eli-t’s picture

Assigned: rakesh.gectcr » Unassigned
shaal’s picture

Status: Needs review » Reviewed & tested by the community

I tested Umami's content again.
I installed Umami in English and went through every piece of content and each taxonomy.
Later I installed Umami in Hebrew, to make sure that another language doesn't cause any new issues.

For the end user - everything looks the same as it was before the patch.
The file structure has all the content files under /languages/en/

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 17: 3028627_17.patch, failed testing. View results

shaal’s picture

Status: Needs work » Needs review
StatusFileSize
new36.46 KB

I fixed patch #17 by manually applying the changes in InstallHelper.php

shaal’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new36.47 KB
new471 bytes

patch #17 was created for 8.6.x
regular git apply -v 3028627_17.patch would fail with the message

Checking patch core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php...
error: while searching for:
  protected $state;

  /**
   * Constructs a new InstallHelper object.
   *
   * @param \Drupal\Core\Path\AliasManagerInterface $aliasManager

error: patch failed: core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php:47
error: core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php: patch does not apply

I found here https://www.drupal.org/patch/reroll#comment-8964453 about --3way option in git.
so running git apply -3 3028627_17.patch
resulted in

error: patch failed: core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php:47
Falling back to three-way merge...
Applied patch to 'core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php' with conflicts.
U core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php

Now all the files were staged, except for the merging conflict.
using GitKraken (which is awesome!) I could see clearly how to merge between the conflict of changes in the file since 8.6.x, and changes that are coming from the patch itself.

I found out that I missed 1 line of space, so I submitted this new patch.
I will RTBC it because there were no changes made since patch #17, just resolving a merge conflict.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

Looks great, except:

+++ b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/en/recipe_categories.csv
+Accompaniment
+Dessert
[...]
+++ b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/en/tags.csv
+Alcohol free
+Baked
[...]

I find it strange that we hardwire numbers into the other CSV files referring to these terms, but then autogenerate those numbers programatically elsewhere. It would be more consistent if we would include the numbers in the terms files as well, and just use them in the code too.

This feels fragile even if I cannot exactly cite a situation where it would badly break, it feels like better to include the ID we use to refer to it rather than inferring it given that the files are hand-edited.

smaz’s picture

Status: Needs work » Needs review
StatusFileSize
new36.56 KB
new6.52 KB

Updated to add IDs to the terms, so it's not reliant on row numbers matching up.

kjay’s picture

This latest patch installs without errors. Taxonomy terms are present as expected. Each term returns the tagged content on the term pages. The articles and recipes continue appear as expected.

shaal’s picture

Status: Needs review » Reviewed & tested by the community

Patch #30 works great.

I tested it as is,
then I created multiple modifications:

  • Changed tags' ID
  • Changed order of tags in the file while keeping original ID
  • Created new ID that is not referenced in any recipe
  • Added to recipes an ID that does not exist

It was working as intended and didn't produce any errors. On Umami itself - all taxonomy links behaved as expected, and nothing was linked to 404 pages.

  • Gábor Hojtsy committed b6a04ed on 8.7.x
    Issue #3028627 by Eli-T, rakesh.gectcr, shaal, smaz, Gábor Hojtsy, kjay...
gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Yay thanks! Committed. Let's get the translations (and their loading and exposure) happen next!

Status: Fixed » Closed (fixed)

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