@bgm this seems strange that after fixing the CRM_Utils_System::languageNegotiationURL() I still didn't get the language prefix in URL. However, when I debugged the output it surely does return the URL with the current enabled language prefix as in https://example.org/
@bgm if you could review the PR then we might be able to close this. Thanks again for your various useful improvements that it would be good to get into core.
It seems like with KAM, this issue has shifted a bit. #19 (closed) is still a very valid issue, since it affects the l10n-js (and #19 (closed) fixes that), but with KAM the translation of the menu manifests itself differently.
public function url( $path = '', $query = '', $absolute = FALSE, $fragment = NULL, $frontend = FALSE, $forceBackend = FALSE ) { $query = html_entity_decode($query); // dev/drupal#21 Drupal8 does not like this path, so it would output '/*path*' // instead of the expected '/en/*path*' when using multilingual. if ($path == '*path*') { $path = 'civicrm/*path*'; } $url = \Drupal\civicrm\CivicrmHelper::parseURL("{$path}?{$query}"); $base = $absolute ? $config->userFrameworkBaseURL : 'internal:/'; // Not all links that CiviCRM generates are Drupal routes, so we use the weaker ::fromUri method. try { $url = \Drupal\Core\Url::fromUri("{$base}{$url['path']}", [ 'query' => $url['query'], 'fragment' => $fragment, 'absolute' => $absolute, ])->toString(); } catch (Exception $e) { // @Todo: log to watchdog $url = ''; } // Special case: CiviCRM passes us "*path*?*query*" as a skeleton, but asterisks // are invalid and Drupal will attempt to escape them. We unescape them here: if ($path == 'civicrm/*path*') { // First remove trailing equals sign that has been added since the key '?*query*' has no value. $url = rtrim($url, '='); $url = urldecode($url); // Remove the civicrm prefix that we added earlier in this function $url = str_replace('civicrm/*path*', '*path*', $url); } return $url; }
but I will wait for PR 12152 to be merged before submitting a patch.
This is not very elegant, and I looked at changing crmURL so that it uses civicrm/*path* instead of just *path*, but that would require more QA on WordPress and others (but WordPress has a specific check on addslashes, so it seems more tricky).