Problem/Motivation

View more link in recipe cards is not fully translated. The bundle is always in English because we are using the bundle machine name.

Proposed resolution

Use the type label() for rendering the translated type name.

Remaining tasks

Patch

User interface changes

None (in English), but will make this translatable.

API changes

None

Data model changes

None

Comments

penyaskito created an issue. See original summary.

penyaskito’s picture

Status: Active » Needs review
StatusFileSize
new1.33 KB

Changed twig templates for taking the translated bundle name.

penyaskito’s picture

StatusFileSize
new99.02 KB
new99.14 KB

Screenshots

Before:

After:

markconroy’s picture

Status: Needs review » Reviewed & tested by the community

This is a very clever and simple patch. Thanks so much for taking the time to make Out of the Box even better @penyaskito.

Tested with default language (English) and also Irish. Marking as RTBC.

mpp’s picture

Indeed RTBC.

lauriii’s picture

Status: Reviewed & tested by the community » Needs review

Do you think it would make sense to add test coverage for this type of bugs?

mpp’s picture

Status: Needs review » Reviewed & tested by the community

@lauriii, there should already be a test that checks if label() returns the proper translation.

Adding tests to see whether all strings used in templates are translated or not doesn't seem to make sense to me (we'd have to add thousands of tests).

borisson_’s picture

Adding tests to see whether all strings used in templates are translated or not doesn't seem to make sense to me (we'd have to add thousands of tests).

I agree with this.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 2: 2999908-view-more-bundle-translatable-2.patch, failed testing. View results

penyaskito’s picture

Status: Needs work » Reviewed & tested by the community

That was a testbot failure.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/profiles/demo_umami/themes/umami/templates/content/node--card-common.html.twig
@@ -94,7 +94,7 @@
+    <a class="read-more__link" href="{{ url }}">{{ 'View'|t }} {{ node.type.entity.label() }}</a>

+++ b/core/profiles/demo_umami/themes/umami/templates/content/node--card.html.twig
@@ -95,7 +95,7 @@
+    <a class="read-more__link" href="{{ url }}">{{ 'View'|t }} {{ node.type.entity.label() }}</a>

The label should be rendered through a placeholder in the translation string to make sure we are compatible with all languages.

gábor hojtsy’s picture

Agreed. Some languages need the verb and the label swapped in order which is not possible this way.

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new1.36 KB

Fixed with {% trans %}.

webflo’s picture

Status: Needs review » Reviewed & tested by the community

Looks great, i wrote the exact same patch a few minutes ago. I should have searched the issue first. @penyaskito++

  • lauriii committed 552c6ff on 8.7.x
    Issue #2999908 by penyaskito: View more link in recipe cards is not...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed 24773d8 and pushed to 8.7.x. Also cherry-picked to 8.6.x. Thanks!

  • lauriii committed ac9662b on 8.6.x
    Issue #2999908 by penyaskito: View more link in recipe cards is not...
penyaskito’s picture

Thanks! Tagging for tracking.

Status: Fixed » Closed (fixed)

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