Skip to content

Commit

Permalink
Fix translationLinksComponent dropdown (#1805)
Browse files Browse the repository at this point in the history
The $translations variable in translationLinksComponent needs to be a
property of $this in order to accessible by the template. Also adding in
a currentCulture flag to the getOtherCulturesAvailable method so that
the current culture can be excluded from the results.
  • Loading branch information
anvit committed May 3, 2024
1 parent 778beab commit d06b2d3
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,19 @@ public function execute($request)
return sfView::NONE;
}

$translations = self::getOtherCulturesAvailable($i18ns, $propertyName, $sourceCultureProperty);
$this->translations = self::getOtherCulturesAvailable($i18ns, $propertyName, $sourceCultureProperty, $currentCulture);
}

public static function getOtherCulturesAvailable($i18ns, $propertyName, $sourceCultureProperty)
public static function getOtherCulturesAvailable($i18ns, $propertyName, $sourceCultureProperty, $currentCulture = null)
{
// Get other cultures available
$translations = [];

foreach ($i18ns as $i18n) {
if ($currentCulture && $i18n->culture == $currentCulture) {
continue;
}

$name = isset($propertyName) && isset($i18n->{$propertyName}) ? $i18n->{$propertyName} : $sourceCultureProperty;
$langCode = $i18n->culture;
$langName = format_language($langCode);
Expand Down

0 comments on commit d06b2d3

Please sign in to comment.