Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds fix to respect translation for header and nav blocks #145

Closed

Conversation

markconroy
Copy link
Member

Closes #144

@markconroy markconroy requested a review from ekes February 23, 2024 14:51
Copy link
Member

@ekes ekes left a comment

Choose a reason for hiding this comment

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

You know during drop-in I was trying to remember what the one-line way of getting the translated entity was, but just couldn't remember:

EntityRepositoryInterface::getTranslationFromContext

There are a few reasons to use this in preference to getting the current language and requesting the translation:

  • The EntityRepository service uses the fallback language settings to get the most appropriate translation;
  • Additionally the service is designed to default to the interface language, adds some appropriate cache tags;
  • Getting the entity translation, on the other hand, makes a clone of the original default language if the translation doesn't exist. So this is more useful if you are wanting to create, or update, a translation of an entity.

So using \Drupal::service('entity.repository')->getTranslationFromContext($entity), or the appropriate equivalent having loaded entity.repository by dependency injection, would seem to be the better way of getting the desired translation.

@markconroy markconroy self-assigned this Mar 15, 2024
@ekes
Copy link
Member

ekes commented Apr 16, 2024

Just 9.4 failing. Should be removed from test matrix.

@markconroy I've just written the code, not tested it, do you want to check this still works for your site?
@stephen-cox Do you want to do an eye code check?

Then we could merge?

@ekes ekes requested a review from stephen-cox April 16, 2024 17:00
@finnlewis
Copy link
Member

@markconroy could you check this still does what it should?

ekes added a commit that referenced this pull request May 7, 2024
Taking apart PRs #145 and #155 to cover everything in them.
@finnlewis
Copy link
Member

Closing this in favour of #157

@finnlewis finnlewis closed this May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Guide title block and Guide Navigation links are not respecting translations
3 participants