Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Translate to content language

Security covered Maintenance fixes only 20 sites

This module helps translate fixed strings to the content language when it differs from the interface language. It automatically adjusts template translations and provides new functions and Twig filters for translating to either content or interface language, with a submodule to handle configuration object translations.

Synopsis

When the content and the interface languages are different, Drupal core doesn't provide a way to translate fixed strings to the content language. To help modules and templates both, this module:

  • automatically changes the t and trans filters and the % trans % tag in the templates under the default theme directory to use the content language as default instead of the interface language.
  • Adds the tc function
  • Adds the TrancTranslationManager::CONTENT_LANGCODE constant, usable in any t / format_plural / new TranslatableMarkup / string_translation service calls.
  • Adds new twig filters: tc / transc translates to the content language in any theme, ti / transi translates to the interface language in any theme.

Also, config objects -- webforms, views -- do not work properly in this scenario. The tranc_config submodule is provided for this purpose.

Known problems

  • There is no way to force the % trans % tag to translate to the interface language in the default theme as it is unlikely the shorter strings of interface would require this tag.
  • In a template not under the default theme, translating to the content language with the % trans % tag requires the constant() Twig function. This has not been tested.
Drupal 9–11

Ask your assistant about Translate to content language

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
6
Tracked since
Apr 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
1.0.5 Stable 9–11 Mar 25, 2024
1.0.4 Stable 9–11 Mar 25, 2024
1.0.3 Stable 9–10 Nov 23, 2023
1.0.x-dev Dev 10–11 Nov 23, 2023
1.1.x-dev Dev 9–10 Nov 1, 2023
1.0.2 Stable 8–9 Apr 17, 2023