-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
There was a problem hiding this 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.
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? Then we could merge? |
@markconroy could you check this still does what it should? |
Closing this in favour of #157 |
Closes #144