TranslatableInterface::getDefaultTranslationLanguage and ::geDefaultTranslationLangcode for direct access to the default translation language

Created on 24 December 2016, over 8 years ago
Updated 4 September 2025, 6 days ago

Currently in order to retrieve the default language / language code we have to first retrieve the default entity translation object, but this is actually unnecessary as we have the information about the default translation on each entity translaton object under the property $defaultLangcode so it makes to provide direct access to it.

As of now to retrieve the default language and language code we have to do :
$entity->getUntranslated()->language();
$entity->getUntranslated()->language()->getId();
But this way we are going to initialize unnecessary a new entity translation object if there isn't an existing one in the entity translation object cache.

For performance reasons it makes sense to have a direct access to the default language without having to initialize the entity default translation.

✨ Feature request
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

entity system

Created by

πŸ‡©πŸ‡ͺGermany hchonov πŸ‡ͺπŸ‡ΊπŸ‡©πŸ‡ͺπŸ‡§πŸ‡¬

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

  • D8MI

    (Drupal 8 Multilingual Initiative) is the tag used by the multilingual initiative to mark core issues (and some contributed module issues). For versions other than Drupal 8, use the i18n (Internationalization) tag on issues which involve or affect multilingual / multinational support. That is preferred over Translation.

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for sharing your idea for improving Drupal.

    We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024