I would like to add support for language option in drupal_url function. So the usage would look like

{{ drupal_url('/node/1', {'language': 'en'}) }}

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Peter Törnstrand created an issue. See original summary.

Peter Törnstrand’s picture

Chi’s picture

Status: Active » Needs work

I think the option name should be langcode instead. It will be aligned with Drupal core naming conventions.

Also it would prevent possible BC break as some sites may pass language object to templates and use it in this function.

Drupal core has at least one Twig template which is supplied with language variable.
https://github.com/drupal/drupal/blob/8.6.12/core/themes/stable/template...

Peter Törnstrand’s picture

Changes key from language to langcode.

Syntax would then be {{ drupal_url('/node/1', {'langcode': 'en'}) }}

Chi’s picture

Status: Needs work » Needs review

  • Chi committed 5df4250 on 8.x-2.x
    Issue #3040238 by Peter Törnstrand: Add a test for langcode option
    
  • Chi committed 6fb5eeb on 8.x-2.x authored by Peter Törnstrand
    Issue #3040238 by Peter Törnstrand: Add language support to drupal_url
    
Chi’s picture

Title: Add language support to drupal_url » Add language support to drupal_url()
Status: Needs review » Fixed

Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.