Problem/Motivation

There is a hardcoded content translation status in ContentTranslationController::overview()

$status = '<span class="status">' . $status . '</span>' . (!empty($translation['outdated']) ? ' <span class="marker">' . $this->t('outdated') . '</span>' : '');

Proposed resolution

Add inline template to move this html to rendering level. see https://www.drupal.org/node/2311123

Remaining tasks

Contributor tasks needed
Task Novice task? Contributor instructions Complete?
Create a patch Yes Instructions
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards Instructions

User interface changes

N/A

API changes

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vlkff’s picture

Assigned: Unassigned » vlkff
Buratino42’s picture

Issue tags: -#Drupal8 #Theme +#Drupal8 #Theme #dcdn-sprint
FileSize
1.29 KB

Add theme function. Hope right understand issue )

Buratino42’s picture

Issue tags: -#Drupal8 #Theme #dcdn-sprint +#Drupal8 #Theme dcdn-sprint
Buratino42’s picture

Issue tags: -#Drupal8 #Theme dcdn-sprint +#Drupal8, +#theme, +dcdn-sprint
Buratino42’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: drupal-add_theme_function-2250841-2.patch, failed testing.

vlkff’s picture

Buratino42, thank you for your work, but your patch from #2 not exactly doing what requested in this issue and require a rework. You just wrapped the hardcoded code in a wrapper function, while we need to create and use a theme function.
Please rework your patch in this way:
* implement a theme using hook_theme
* replace hardcoded $status contents by drupal_render call
* please place in your theme function all status message markup, not only the marker.

Follow links may help you:
https://api.drupal.org/api/drupal/core%21modules%21system%21theme.api.ph...
https://api.drupal.org/api/drupal/core%21modules%21system%21system.api.p...
https://api.drupal.org/api/drupal/core%21includes%21common.inc/function/...

vlkff’s picture

Assigned: vlkff » Unassigned
piyuesh23’s picture

Assigned: Unassigned » piyuesh23
dcam’s picture

Issue summary: View changes
Issue tags: -dcdn-sprint

Updating in preparation for DrupalCon Austin sprints. See http://www.hook42.com/blog/prepping-drupalcon-austin-sprints-sprint-lead....

thechanceg’s picture

Status: Needs work » Needs review
FileSize
2.14 KB

Here is an attempt at a switching it over to hook_theme. It works, but I'm not sure if adding the hooks to the .module file is the commonly accepted approach. I'm still getting used to d8.

surandesilva’s picture

Status: Needs review » Reviewed & tested by the community

We tested against the latest dev version of Drupal 8 and confirmed that the theme hook worked correctly. Tested content translation module and made sure that the outdated string appeared correctly.

alexpott’s picture

Do we really need to a theme function for this? Why would someone override this?

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work

Also, let's not introduce new theme functions when our twig team is so hard at work converting them :-)

star-szr’s picture

I think @joelpittet would be one of the best people to ask about how this type of thing could fit in to the D8 "markup ecosystem" (I've left him a tell on IRC), but yes it would be nice to not introduce new theme functions. Thanks for the ping @alexpott :)

And yes thank you @tstoeckler, we have done a ton of work around #1757550: [Meta] Convert core theme functions to Twig templates so this would just be adding to that list.

In general IMO it's nice to be able to override markup, thinking of admin themes for this case. But it seems weird to introduce a theme function or template for this, it's so specific (we're trying to get rid of as many of these one-offs as possible when it makes sense) and there really isn't much markup. Hoping there is a better way. It may be significant that this is a "marker", I wonder if mark.html.twig could be a fit for at least part of this or if we could make mark__translation_status or something along those lines.

andypost’s picture

Status: Needs work » Needs review
FileSize
1.58 KB
3.71 KB
15.3 KB

This is really annoying bug, how it looks is #2251907: Wrong status on Translate tab for entities


how it looks now

markup

andypost’s picture

Title: Adding a theming method for outdated marker » Adding a inline template for content translation status
Assigned: piyuesh23 » Unassigned
Issue summary: View changes
Parent issue: » #2297711: Fix HTML escaping due to Twig autoescape
andypost’s picture

Category: Task » Bug report
star-szr’s picture

Status: Needs review » Reviewed & tested by the community

Code looks great and I manually tested it, works great. Thank you @andypost! I don't think all the issues fixing double escaping need tests added. RTBC from me.

andypost’s picture

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

I am confused, #2305799: HTML tags (raw) shown in Status column on Translations page was marked as duplicate of #2317557: renderInline not compatible with twig_auto_reload which now contains that as well.

+++ b/core/modules/content_translation/src/Controller/ContentTranslationController.php
@@ -136,9 +136,14 @@ public function overview(Request $request, $entity_type_id = NULL) {
+            '#context' => array(
+              'status' => !empty($translation['status']) ? $this->t('Published') : $this->t('Not published'),
+              'outdated' => !empty($translation['outdated']) ? $this->t('outdated') : '',
+            ),

we can also put all t() calls into the twig itself.

star-szr’s picture

I did mention that the t stuff could be in Twig in IRC, I'm not sure if that's equivalent to $this->t() or if it matters.

andypost’s picture

@dawehner There's no difference between trans and $this->t() both are parsed fine
My preference is t() because it much clear for translators (users of l.d.o) to get context from code not the templates

Gábor Hojtsy’s picture

Issue tags: +language-content
dawehner’s picture

@andypost
Sure, both are fine, though it feels just better to move this kind of stuff into templates as they don't really belong to the logic on the code.

andypost’s picture

Status: Needs work » Needs review
FileSize
1.32 KB
1.55 KB

@dawehner - as you wish ;) template is a bit longer... and less readable

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thank you!

vijaycs85’s picture

Tested manually. Looks good. +1 to RTBC.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Looks good.

Committed and pushed to 8.x. Thanks!

  • webchick committed a4b6e3b on 8.0.x
    Issue #2250841 by andypost, thechanceg, Buratino42 | vijaycs85: Fixed...

Status: Fixed » Closed (fixed)

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

jibran’s picture

Issue tags: +SafeMarkup