Skip to content

Comments

[MAINTENANCE] Translate Helper Refactoring#1839

Open
marco-lengua wants to merge 23 commits intokitodo:mainfrom
marco-lengua:feature_translateHelper
Open

[MAINTENANCE] Translate Helper Refactoring#1839
marco-lengua wants to merge 23 commits intokitodo:mainfrom
marco-lengua:feature_translateHelper

Conversation

@marco-lengua
Copy link
Contributor

This PR reduces excessive SQL backend querying for single entry translations and lazy loading of single entries to the cache variable. Now we have just a single call to the backend per request and table and PID (retrieving as batch) and else O(1) lookup for translations.

@sebastian-meyer sebastian-meyer added the ⟳ maintenance A task to keep the code up-to-date and manageable. label Feb 4, 2026
$entryArray['year'] = $entry['year'];
$entryArray['orderlabel'] = $entry['orderlabel'];
$entryArray['type'] = $entry['type'];
$entryArray['type'] = $this->getTranslatedType($entry['type']);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change disables the option to display document type icons. This functions is used for e.g. in DFG Viewer <span class="meta-type-icon meta-type-{child.type}">{child.type}</span>. It is necessary that type is in English instead be translated here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for your feedback, i was not aware of this. What i don't understand is why in the current version (branch 6) it is the same way. I think we made the change in one PR and now wanted to revert it. The purpose of this is a batch translation and a speed gain. It was like this before. Could you explain why it would not be working anymore now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use case is as mentioned above, the template contains span with the meta-type-{child.type}, then there is css for this class e.g.

&.meta-type-article {
    background-position: -60px -30px;
}

If this is translated than css class is not working anymore.

<f:format.crop maxCharacters="55" append="&nbsp;..."><f:format.htmlspecialchars doubleEncode="false">{child.title}</f:format.htmlspecialchars></f:format.crop>
</f:then>
<f:else>
<f:format.crop maxCharacters="55" append="&nbsp;..."><f:format.htmlspecialchars doubleEncode="false"><f:translate key="LLL:EXT:dlf/Resources/Private/Language/locallang_structure.xlf:structure.{child.type}" /></f:format.htmlspecialchars><f:if condition="{child.volume}"> &nbsp;<f:format.htmlspecialchars doubleEncode="false">{child.volume}</f:format.htmlspecialchars></f:if></f:format.crop>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translation should be kept here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have the translated "entry.Type" we can use that translation in this fluid template, because it makes the page load much faster. That was the purpose of this PR. Do you know any case this is not feasible? Could you please provide me with more information on this topic. Please see also the GitHub Discussion for our usecases

Copy link
Collaborator

@beatrycze-volk beatrycze-volk Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Here is the example how this icons are used.
You can see next to the year the small newspaper icon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⟳ maintenance A task to keep the code up-to-date and manageable.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants